Class: RuboCop::Cop::Chef::RedundantCode::OhaiAttributeToString
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/chef/redundant/ohai_attribute_to_string.rb
Overview
Many Ohai node attributes are already strings and don’t need to be cast to strings again
Constant Summary collapse
- MSG =
"This Ohai node attribute is already a string and doesn't need to be converted"
- RESTRICT_ON_SEND =
[:to_s].freeze
Instance Method Summary collapse
Methods inherited from Base
Instance Method Details
#on_send(node) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/rubocop/cop/chef/redundant/ohai_attribute_to_string.rb', line 54 def on_send(node) attribute_to_s?(node) do |method| add_offense(node, severity: :refactor) do |corrector| corrector.replace(node, "node['#{method.value}']") end end end |