Class: RuboCop::Cop::Chef::Ruby::GemspecLicense

Inherits:
Base
  • Object
show all
Includes:
RangeHelp
Defined in:
lib/rubocop/cop/chef/ruby/gemspec_license.rb

Overview

All gemspec files should define their license.

Examples:


# good
spec.license = "Apache-2.0"

Constant Summary collapse

MSG =
"All gemspec files should define their license."

Instance Method Summary collapse

Instance Method Details

#on_new_investigationObject


43
44
45
46
47
48
49
50
# File 'lib/rubocop/cop/chef/ruby/gemspec_license.rb', line 43

def on_new_investigation
  # exit if we find a license statement or any eval since that usually happens
  # when we have a windows platform gem that evals the main gemspec
  return if license(processed_source.ast).first || eval_method(processed_source.ast).first

  range = source_range(processed_source.buffer, 1, 0)
  add_offense(range, message: MSG, severity: :warning)
end