Class: RuboCop::Cop::Chef::Modernize::DatabagHelpers
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/chef/modernize/databag_helpers.rb
Overview
Use the ‘data_bag_item` helper instead of `Chef::DataBagItem.load` or `Chef::EncryptedDataBagItem.load`.
Constant Summary collapse
- MSG =
'Use the `data_bag_item` helper instead of `Chef::DataBagItem.load` or `Chef::EncryptedDataBagItem.load`.'
- RESTRICT_ON_SEND =
[:load].freeze
Instance Method Summary collapse
Methods inherited from Base
Instance Method Details
#on_send(node) ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/rubocop/cop/chef/modernize/databag_helpers.rb', line 47 def on_send(node) data_bag_class_load?(node) do add_offense(node, severity: :refactor) do |corrector| corrector.replace(node, node.source.gsub(/Chef::(EncryptedDataBagItem|DataBagItem).load/, 'data_bag_item')) end end end |