Class: RuboCop::Cop::Chef::ChefModernize::EmptyResourceInitializeMethod

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

Overview

There is no need for an empty initialize method in a resource

Examples:


# bad
def initialize(*args)
  super
end

Constant Summary collapse

MSG =
'There is no need for an empty initialize method in a resource'.freeze

Instance Method Summary collapse

Instance Method Details

#autocorrect(node) ⇒ Object



43
44
45
46
47
# File 'lib/rubocop/cop/chef/modernize/empty_resource_initialize.rb', line 43

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

#on_def(node) ⇒ Object



37
38
39
40
41
# File 'lib/rubocop/cop/chef/modernize/empty_resource_initialize.rb', line 37

def on_def(node)
  empty_initialize?(node) do
    add_offense(node, location: :expression, message: MSG, severity: :refactor)
  end
end