Class: RuboCop::Cop::Chef::ChefModernize::WhyRunSupportedTrue

Inherits:
RuboCop::Cop
  • Object
show all
Defined in:
lib/rubocop/cop/chef/modernize/whyrun_supported_true.rb

Overview

whyrun_supported? no longer needs to be set to true as that is the default in Chef Infra Client 13+

Examples:


# bad
def whyrun_supported?
 true
end

Constant Summary collapse

MSG =
'whyrun_supported? no longer needs to be set to true as it is the default in Chef Infra Client 13+'.freeze

Instance Method Summary collapse

Instance Method Details

#autocorrect(node) ⇒ Object



39
40
41
42
43
# File 'lib/rubocop/cop/chef/modernize/whyrun_supported_true.rb', line 39

def autocorrect(node)
  lambda do |corrector|
    corrector.remove(node.loc.expression)
  end
end

#on_def(node) ⇒ Object



33
34
35
36
37
# File 'lib/rubocop/cop/chef/modernize/whyrun_supported_true.rb', line 33

def on_def(node)
  if node.method_name == :whyrun_supported? && node.body == s(:true) # rubocop: disable Lint/BooleanSymbol
    add_offense(node, location: :expression, message: MSG, severity: :refactor)
  end
end