Class: RuboCop::Cop::Chef::Correctness::MetadataMissingName
- Extended by:
- AutoCorrector
- Includes:
- RangeHelp
- Defined in:
- lib/rubocop/cop/chef/correctness/metadata_missing_name.rb
Overview
metadata.rb needs to include the name method or it will fail on Chef Infra Client 12 and later.
Constant Summary collapse
- MSG =
'metadata.rb needs to include the name method or it will fail on Chef Infra Client 12 and later.'
Instance Method Summary collapse
Methods inherited from Base
Instance Method Details
#on_new_investigation ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/rubocop/cop/chef/correctness/metadata_missing_name.rb', line 37 def on_new_investigation # handle an empty metdata.rb file return if processed_source.ast.nil? # Using range similar to RuboCop::Cop::Naming::Filename (file_name.rb) return if cb_name?(processed_source.ast) range = source_range(processed_source.buffer, 1, 0) add_offense(range, severity: :refactor) do |corrector| path = processed_source.path cb_name = File.basename(File.dirname(path)) corrector.insert_before(processed_source.ast, "name '#{cb_name}'\n") end end |