Class: RuboCop::Cop::Chef::Deprecations::UseInlineResourcesDefined
- Extended by:
- AutoCorrector
- Includes:
- RangeHelp
- Defined in:
- lib/rubocop/cop/chef/deprecation/use_inline_resources.rb
Overview
use_inline_resources became the default in Chef Infra Client 13+ and no longer needs to be called in resources
Constant Summary collapse
- MSG =
'use_inline_resources is now the default for resources in Chef Infra Client 13+ and does not need to be specified.'
- RESTRICT_ON_SEND =
[:use_inline_resources].freeze
Instance Method Summary collapse
Methods inherited from Base
Instance Method Details
#on_send(node) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rubocop/cop/chef/deprecation/use_inline_resources.rb', line 39 def on_send(node) # don't alert on the use_inline_resources within the defined? check # that would result in 2 alerts on the same line and wouldn't be useful return if node.parent && node.parent.defined_type? # catch the full offense if the method is gated like this: use_inline_resources if defined?(use_inline_resources) if node.parent && node.parent.if_type? && %i(defined? respond_to?).include?(node.parent.children.first.method_name) node = node.parent end add_offense(node, severity: :warning) do |corrector| corrector.remove(range_with_surrounding_space(range: node.loc.expression, side: :left)) end end |