Class: RuboCop::Cop::Chef::Style::DefaultCopyrightComments

Inherits:
Base
  • Object
show all
Defined in:
lib/rubocop/cop/chef/style/comments_default_copyright.rb

Overview

Checks for default copyright comments from the chef generator cookbook command

Examples:


### incorrect
Copyright:: 2019 YOUR_NAME
Copyright:: 2019 YOUR_COMPANY_NAME

### correct
Copyright:: 2019 Tim Smith
Copyright:: 2019 Chef Software, Inc.

Constant Summary collapse

MSG =
'Cookbook copyright comment headers should be updated for a real person or organization.'

Instance Method Summary collapse

Methods inherited from Base

#target_chef_version

Instance Method Details

#on_new_investigationObject



37
38
39
40
41
42
43
44
45
# File 'lib/rubocop/cop/chef/style/comments_default_copyright.rb', line 37

def on_new_investigation
  return unless processed_source.ast

  processed_source.comments.each do |comment|
    next unless comment.inline? &&  # headers aren't in blocks
                /# (?:Copyright\W*).*YOUR_(NAME|COMPANY_NAME)/.match?(comment.text)
    add_offense(comment, severity: :refactor)
  end
end