Skip to content

Commit

Permalink
Merge pull request #244 from chef/name_metadata_autocorrect
Browse files Browse the repository at this point in the history
Add autocorrect to MetadataMissingName
  • Loading branch information
tas50 authored Aug 26, 2019
2 parents d35cb96 + 087b9ca commit d89452d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/rubocop/cop/chef/correctness/metadata_missing_name.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ def investigate(processed_source)
end

def_node_search :cb_name, '(send nil? :name str ...)'

def autocorrect(_node)
lambda do |_corrector|
path = processed_source.path
cb_name = File.basename(File.dirname(path))

metadata = IO.read(path)
IO.write(path, "name '#{cb_name}'\n" + metadata)
end
end
end
end
end
Expand Down

0 comments on commit d89452d

Please sign in to comment.