Class: RuboCop::Cop::Chef::RedundantCode::ResourceWithNothingAction

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Includes:
RangeHelp
Defined in:
lib/rubocop/cop/chef/redundant/resource_with_nothing_action.rb

Overview

Chef Infra Client provides the :nothing action by default for every resource. There is no need to define a :nothing action in your resource code.

Examples:


### incorrect
action :nothing
  # let's do nothing
end

Constant Summary collapse

MSG =
'There is no need to define a :nothing action in your resource as Chef Infra Client provides the :nothing action by default for every resource.'

Instance Method Summary collapse

Methods inherited from Base

#target_chef_version

Instance Method Details

#on_block(node) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/rubocop/cop/chef/redundant/resource_with_nothing_action.rb', line 41

def on_block(node)
  nothing_action?(node) do
    add_offense(node, severity: :refactor) do |corrector|
      corrector.remove(range_with_surrounding_space(range: node.loc.expression, side: :left))
    end
  end
end