Class: RuboCop::Cop::Chef::Modernize::RespondToProvides

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Defined in:
lib/rubocop/cop/chef/modernize/respond_to_provides.rb

Overview

In Chef Infra Client 12+ is is no longer necessary to gate the use of the provides methods in resources with ‘if respond_to?(:provides)` or `if defined? provides`.

Examples:


### incorrect
provides :foo if respond_to?(:provides)

provides :foo if defined? provides

### correct
provides :foo

Constant Summary collapse

MSG =
'Using `respond_to?(:provides)` or `if defined? provides` in resources is no longer necessary in Chef Infra Client 12+.'

Instance Method Summary collapse

Methods inherited from Base

#target_chef_version

Instance Method Details

#on_if(node) ⇒ Object



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

def on_if(node)
  if_respond_to_provides?(node) do
    add_offense(node, severity: :refactor) do |corrector|
      corrector.replace(node, node.children[1].source)
    end
  end
end