Class: RuboCop::Cop::Chef::Modernize::FoodcriticComments

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Defined in:
lib/rubocop/cop/chef/modernize/foodcritic_comments.rb

Overview

Remove legacy code comments that disable Foodcritic rules. These comments are no longer necessary if you’ve migrated from Foodcritic to Cookstyle for cookbook linting.

Examples:


### incorrect
# ~FC013

Constant Summary collapse

MSG =
'Remove legacy code comments that disable Foodcritic rules'

Instance Method Summary collapse

Methods inherited from Base

#target_chef_version

Instance Method Details

#on_new_investigationObject



34
35
36
37
38
39
40
41
# File 'lib/rubocop/cop/chef/modernize/foodcritic_comments.rb', line 34

def on_new_investigation
  processed_source.comments.each do |comment|
    next unless comment.text.match?(/#\s*~FC\d{3}.*/)
    add_offense(comment, severity: :refactor) do |corrector|
      corrector.remove(comment)
    end
  end
end