class RuboCop::Cop::Chef::Correctness::MetadataMissingName
metadata.rb needs to include the name method or it will fail on Chef
Infra Client 12 and later.
@example
#### correct name 'foo'
Constants
- MSG
Public Instance Methods
on_new_investigation()
click to toggle source
# 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