Class: RuboCop::Cop::Chef::Deprecations::NodeMethodsInsteadofAttributes
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Chef::Deprecations::NodeMethodsInsteadofAttributes
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/chef/deprecation/node_methods_not_attributes.rb
Overview
Use node attributes to access data provided by Ohai instead of using node methods to access that data.
Constant Summary collapse
- MSG =
'Use node attributes to access Ohai data instead of node methods, which were deprecated in Chef Infra Client 13.'
- RESTRICT_ON_SEND =
%i( current_user domain fqdn hostname ip6address ipaddress macaddress machinename ohai_time os os_version platform platform_build platform_family platform_version root_group shard_seed uptime uptime_seconds).freeze
Instance Method Summary collapse
Methods inherited from Base
Instance Method Details
#on_send(node) ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/rubocop/cop/chef/deprecation/node_methods_not_attributes.rb', line 69 def on_send(node) node_ohai_methods?(node) do add_offense(node.loc.selector, severity: :warning) do |corrector| corrector.replace(node, "node['#{node.method_name}']") end end end |