class RuboCop::Cop::Betterment::UnsafeJob
Constants
- MSG
Attributes
class_regex[RW]
sensitive_params[RW]
Public Class Methods
new(config = nil, options = nil)
click to toggle source
Calls superclass method
# File lib/rubocop/cop/betterment/unsafe_job.rb, line 14 def initialize(config = nil, options = nil) super(config, options) config = @config.for_cop(self) @sensitive_params = config.fetch("sensitive_params", []).map(&:to_sym) @class_regex = Regexp.new config.fetch("class_regex", ".*Job$") end
Public Instance Methods
on_def(node)
click to toggle source
# File lib/rubocop/cop/betterment/unsafe_job.rb, line 21 def on_def(node) return unless %i(perform initialize).include?(node.method_name) return unless @class_regex.match(node.parent_module_name) node.arguments.any? do |argument| name, = *argument add_offense(argument) if @sensitive_params.include?(name) end end