Class: RuboCop::Cop::InSpec::Deprecations::AttributeHelper

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Defined in:
lib/rubocop/cop/inspec/deprecation/attribute_helper.rb

Overview

Chef InSpec attributes have been renamed to inputs. Use the ‘input` method not the deprecation `attribute` method to access these values.

Examples:


### incorrect
 = attribute('login_defs_umask', value: '077', description: 'Default umask to set in login.defs')

### correct
 = input('login_defs_umask', value: '077', description: 'Default umask to set in login.defs')

Constant Summary collapse

MSG =
'InSpec attributes have been renamed to inputs. Use the `input` method not the deprecation `attribute` method to access these values.'
RESTRICT_ON_SEND =
[:attribute].freeze

Instance Method Summary collapse

Methods inherited from Base

#target_chef_version

Instance Method Details

#on_send(node) ⇒ Object



38
39
40
41
42
# File 'lib/rubocop/cop/inspec/deprecation/attribute_helper.rb', line 38

def on_send(node)
  add_offense(node, severity: :warning) do |corrector|
    corrector.replace(node.loc.expression, node.loc.expression.source.gsub(/^attribute/, 'input'))
  end
end