Class: RuboCop::Cop::Chef::ChefStyle::CopyrightCommentFormat
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::Chef::ChefStyle::CopyrightCommentFormat
- Defined in:
- lib/rubocop/cop/chef/style/comments_copyright_format.rb
Overview
Checks for incorrectly formatted copyright comments.
Constant Summary collapse
- MSG =
'Properly format copyrights header comments'.freeze
Instance Method Summary collapse
Instance Method Details
#autocorrect(comment) ⇒ Object
57 58 59 60 |
# File 'lib/rubocop/cop/chef/style/comments_copyright_format.rb', line 57 def autocorrect(comment) correct_comment = "# Copyright:: #{copyright_date_range(comment)}, #{copyright_holder(comment)}" ->(corrector) { corrector.replace(comment.loc.expression, correct_comment) } end |
#investigate(processed_source) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/rubocop/cop/chef/style/comments_copyright_format.rb', line 45 def investigate(processed_source) return unless processed_source.ast processed_source.comments.each do |comment| next unless comment.inline? # headers aren't in blocks if invalid_copyright_comment?(comment) add_offense(comment, location: comment.loc.expression, message: MSG, severity: :refactor) end end end |