cookstyle 5.4.13 → 5.5.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/config/cookstyle.yml +231 -129
  3. data/lib/cookstyle.rb +1 -0
  4. data/lib/cookstyle/version.rb +1 -1
  5. data/lib/rubocop/chef/cookbook_helpers.rb +67 -0
  6. data/lib/rubocop/cop/chef/correctness/block_guard_clause_string_only.rb +34 -31
  7. data/lib/rubocop/cop/chef/correctness/cb_depends_on_self.rb +16 -14
  8. data/lib/rubocop/cop/chef/correctness/default_maintainer_metadata.rb +22 -20
  9. data/lib/rubocop/cop/chef/correctness/insecure_cookbook_url.rb +32 -30
  10. data/lib/rubocop/cop/chef/correctness/invalid_license_string.rb +454 -453
  11. data/lib/rubocop/cop/chef/correctness/invalid_platform_metadata.rb +57 -57
  12. data/lib/rubocop/cop/chef/correctness/metadata_missing_name.rb +18 -16
  13. data/lib/rubocop/cop/chef/correctness/name_property_and_required.rb +61 -59
  14. data/lib/rubocop/cop/chef/correctness/node_normal.rb +29 -27
  15. data/lib/rubocop/cop/chef/correctness/node_normal_unless.rb +29 -27
  16. data/lib/rubocop/cop/chef/correctness/node_save.rb +46 -0
  17. data/lib/rubocop/cop/chef/correctness/ohai_default_recipe.rb +47 -0
  18. data/lib/rubocop/cop/chef/correctness/property_with_default_and_required.rb +35 -33
  19. data/lib/rubocop/cop/chef/correctness/property_with_name_attribute.rb +29 -27
  20. data/lib/rubocop/cop/chef/correctness/resource_sets_internal_properties.rb +52 -0
  21. data/lib/rubocop/cop/chef/correctness/resource_sets_name_property.rb +51 -0
  22. data/lib/rubocop/cop/chef/correctness/resource_with_none_action.rb +52 -0
  23. data/lib/rubocop/cop/chef/correctness/service_resource.rb +26 -24
  24. data/lib/rubocop/cop/chef/correctness/tmp_path.rb +30 -28
  25. data/lib/rubocop/cop/chef/deprecation/attribute_metadata.rb +22 -21
  26. data/lib/rubocop/cop/chef/deprecation/chef_rest.rb +56 -0
  27. data/lib/rubocop/cop/chef/deprecation/chocolatey_package_uninstall_action.rb +58 -0
  28. data/lib/rubocop/cop/chef/deprecation/conflicts_metadata.rb +18 -16
  29. data/lib/rubocop/cop/chef/deprecation/depends_compat_resource.rb +21 -19
  30. data/lib/rubocop/cop/chef/deprecation/depends_partial_search.rb +17 -15
  31. data/lib/rubocop/cop/chef/deprecation/depends_poise.rb +17 -15
  32. data/lib/rubocop/cop/chef/deprecation/deprecated_mixins.rb +39 -37
  33. data/lib/rubocop/cop/chef/deprecation/easy_install.rb +15 -13
  34. data/lib/rubocop/cop/chef/deprecation/epic_fail.rb +24 -22
  35. data/lib/rubocop/cop/chef/deprecation/erl_call.rb +15 -13
  36. data/lib/rubocop/cop/chef/deprecation/launchd_deprecated_hash_property.rb +55 -0
  37. data/lib/rubocop/cop/chef/deprecation/legacy_yum_cookbook_recipes.rb +24 -22
  38. data/lib/rubocop/cop/chef/deprecation/locale_lc_all_property.rb +45 -0
  39. data/lib/rubocop/cop/chef/deprecation/long_description_metadata.rb +21 -19
  40. data/lib/rubocop/cop/chef/deprecation/node_methods_not_attributes.rb +55 -53
  41. data/lib/rubocop/cop/chef/deprecation/node_set.rb +27 -25
  42. data/lib/rubocop/cop/chef/deprecation/node_set_unless.rb +27 -25
  43. data/lib/rubocop/cop/chef/deprecation/provides_metadata.rb +18 -16
  44. data/lib/rubocop/cop/chef/deprecation/replaces_metadata.rb +18 -16
  45. data/lib/rubocop/cop/chef/deprecation/require_recipe.rb +23 -21
  46. data/lib/rubocop/cop/chef/deprecation/suggests_metadata.rb +18 -16
  47. data/lib/rubocop/cop/chef/deprecation/use_inline_resources.rb +56 -0
  48. data/lib/rubocop/cop/chef/deprecation/user_supports_property.rb +53 -0
  49. data/lib/rubocop/cop/chef/deprecation/xml_ruby_recipe.rb +51 -0
  50. data/lib/rubocop/cop/chef/deprecation/yum_dnf_compat_recipe.rb +51 -0
  51. data/lib/rubocop/cop/chef/effortless/data_bags.rb +13 -11
  52. data/lib/rubocop/cop/chef/effortless/search_used.rb +13 -11
  53. data/lib/rubocop/cop/chef/modernize/apt_default_recipe.rb +22 -20
  54. data/lib/rubocop/cop/chef/modernize/berksfile_source.rb +31 -29
  55. data/lib/rubocop/cop/chef/modernize/build_essential.rb +25 -23
  56. data/lib/rubocop/cop/chef/modernize/chef_14_resources.rb +27 -25
  57. data/lib/rubocop/cop/chef/modernize/defines_chefspec_matchers.rb +25 -23
  58. data/lib/rubocop/cop/chef/modernize/execute_apt_update.rb +19 -17
  59. data/lib/rubocop/cop/chef/modernize/includes_mixin_shellout.rb +27 -25
  60. data/lib/rubocop/cop/chef/modernize/libarchive_file.rb +41 -0
  61. data/lib/rubocop/cop/chef/modernize/minitest_handler_usage.rb +21 -19
  62. data/lib/rubocop/cop/chef/modernize/powershell_expand_archive.rb +48 -0
  63. data/lib/rubocop/cop/chef/modernize/powershell_install_package.rb +51 -0
  64. data/lib/rubocop/cop/chef/modernize/powershell_install_windowsfeature.rb +54 -0
  65. data/lib/rubocop/cop/chef/modernize/resource_set_or_return.rb +25 -23
  66. data/lib/rubocop/cop/chef/modernize/resource_with_allowed_actions.rb +77 -0
  67. data/lib/rubocop/cop/chef/modernize/resource_with_attributes.rb +37 -35
  68. data/lib/rubocop/cop/chef/modernize/respond_to_metadata.rb +54 -0
  69. data/lib/rubocop/cop/chef/modernize/respond_to_provides.rb +25 -23
  70. data/lib/rubocop/cop/chef/modernize/respond_to_resource_name.rb +26 -24
  71. data/lib/rubocop/cop/chef/{effortless/node_save.rb → modernize/seven_zip_archive.rb} +16 -16
  72. data/lib/rubocop/cop/chef/modernize/shellouts_to_chocolatey.rb +59 -0
  73. data/lib/rubocop/cop/chef/modernize/whyrun_supported_true.rb +20 -18
  74. data/lib/rubocop/cop/chef/modernize/windows_default_recipe.rb +23 -21
  75. data/lib/rubocop/cop/chef/modernize/windows_version_helper.rb +20 -18
  76. data/lib/rubocop/cop/chef/modernize/windows_zipfile.rb +15 -13
  77. data/lib/rubocop/cop/chef/style/attribute_keys.rb +59 -57
  78. data/lib/rubocop/cop/chef/style/comment_sentence_spacing.rb +14 -12
  79. data/lib/rubocop/cop/chef/style/comments_copyright_format.rb +65 -63
  80. data/lib/rubocop/cop/chef/style/comments_format.rb +48 -45
  81. data/lib/rubocop/cop/chef/style/file_mode.rb +32 -30
  82. metadata +24 -9
  83. data/lib/rubocop/cop/chef/deprecation/respond_to_metadata.rb +0 -53
  84. data/lib/rubocop/cop/chef/modernize/ohai_default_recipe.rb +0 -45
  85. data/lib/rubocop/cop/chef/modernize/resource_with_allowed_action.rb +0 -75
  86. data/lib/rubocop/cop/chef/modernize/use_inline_resources.rb +0 -54
  87. data/lib/rubocop/cop/chef/modernize/xml_ruby_recipe.rb +0 -49
  88. data/lib/rubocop/cop/chef/modernize/yum_dnf_compat_recipe.rb +0 -49
@@ -31,6 +31,7 @@ module Cookstyle
31
31
  end
32
32
 
33
33
  require 'rubocop/chef'
34
+ require 'rubocop/chef/cookbook_helpers'
34
35
  require 'rubocop/chef/cookbook_only'
35
36
 
36
37
  # Chef specific cops
@@ -1,4 +1,4 @@
1
1
  module Cookstyle
2
- VERSION = "5.4.13".freeze # rubocop: disable Style/StringLiterals
2
+ VERSION = "5.5.7".freeze # rubocop: disable Style/StringLiterals
3
3
  RUBOCOP_VERSION = '0.72.0'.freeze
4
4
  end
@@ -0,0 +1,67 @@
1
+ module RuboCop
2
+ module Chef
3
+ # Common node helpers used for matching against Chef Infra Cookbooks
4
+ module CookbookHelpers
5
+ # Match particular properties within a resource
6
+ #
7
+ # @param [String] resource_name The name of the resource to match
8
+ # @param [String] property_name The name of the property to match (or action)
9
+ # @param [<Type>] node The rubocop ast node to search
10
+ #
11
+ # @yield
12
+ #
13
+ def match_property_in_resource?(resource_name, property_name, node)
14
+ return unless node.block_type? # resources are blocks if they have properties
15
+ return unless node.children.first.receiver.nil? # resource blocks don't have a receiver
16
+ return if node.send_node.arguments.first.is_a?(RuboCop::AST::SymbolNode) # resources have a string name. resource actions have symbols
17
+
18
+ # bail if the block doesn't have a name a resource *generally* has a name.
19
+ # This isn't 100% true with things like apt_update and build_essential, but we'll live
20
+ # with that for now to avoid the false positives of getting stuck in generic blocks in resources
21
+ return if node.children.first.arguments.empty?
22
+
23
+ # bail out if we're not in the resource we care about or nil was passed (all resources)
24
+ return unless resource_name.nil? || node.children.first.method?(resource_name.to_sym) # see if we're in the right resource
25
+
26
+ resource_block = node.children[2] # the 3rd child is the actual block in the resource
27
+ return unless resource_block # nil would be an empty block
28
+ if resource_block.begin_type? # if begin_type we need to iterate over the children
29
+ resource_block.children.each do |resource_blk_child|
30
+ extract_send_types(resource_blk_child) do |p|
31
+ yield(p) if p.method_name == property_name.to_sym
32
+ end
33
+ end
34
+ else # there's only a single property to check
35
+ extract_send_types(resource_block) do |p|
36
+ yield(p) if p.method_name == property_name.to_sym
37
+ end
38
+ end
39
+ end
40
+
41
+ def method_arg_ast_to_string(ast)
42
+ # a property without a value. This is totally bogus, but they exist
43
+ return if ast.children[2].nil?
44
+ # https://rubular.com/r/6uzOMd6WCHewOu
45
+ m = ast.children[2].source.match(/^("|')(.*)("|')$/)
46
+ return m[2] unless m.nil?
47
+ end
48
+
49
+ private
50
+
51
+ def extract_send_types(node)
52
+ return if node.nil? # there are cases we can be passed an empty node
53
+ case node.type
54
+ when :send
55
+ yield(node) if node.receiver.nil? # if it's not nil then we're not in a property foo we're in bar.foo
56
+ when :while
57
+ extract_send_types(node.body) { |t| yield(t) }
58
+ when :if
59
+ node.branches.each { |n| extract_send_types(n) { |t| yield(t) } }
60
+ when :case
61
+ node.when_branches.each { |n| extract_send_types(n.body) { |t| yield(t) } } # unless node.when_branches.nil?
62
+ extract_send_types(node.else_branch) { |t| yield(t) } if node.else_branch
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
@@ -17,41 +17,44 @@
17
17
  module RuboCop
18
18
  module Cop
19
19
  module Chef
20
- # Use secure Github and Gitlab URLs for source_url and issues_url
21
- #
22
- # @example
23
- #
24
- # # bad
25
- # template '/etc/foo' do
26
- # mode '0644'
27
- # source 'foo.erb'
28
- # only_if { 'test -f /etc/foo' }
29
- # end
30
- #
31
- # # good
32
- # template '/etc/foo' do
33
- # mode '0644'
34
- # source 'foo.erb'
35
- # only_if 'test -f /etc/foo'
36
- # end
37
- #
38
- class BlockGuardWithOnlyString < Cop
39
- MSG = 'A resource guard (not_if/only_if) that is a string should not be wrapped in {}. Wrapping a guard string in {} causes it be executed as Ruby code which will always returns true instead of a shell command that will actually run.'.freeze
20
+ module ChefCorrectness
21
+ # A resource guard (not_if/only_if) that is a string should not be wrapped in {}.
22
+ # Wrapping a guard string in {} causes it be executed as Ruby code which will always returns true instead of a shell command that will actually run.
23
+ #
24
+ # @example
25
+ #
26
+ # # bad
27
+ # template '/etc/foo' do
28
+ # mode '0644'
29
+ # source 'foo.erb'
30
+ # only_if { 'test -f /etc/foo' }
31
+ # end
32
+ #
33
+ # # good
34
+ # template '/etc/foo' do
35
+ # mode '0644'
36
+ # source 'foo.erb'
37
+ # only_if 'test -f /etc/foo'
38
+ # end
39
+ #
40
+ class BlockGuardWithOnlyString < Cop
41
+ MSG = 'A resource guard (not_if/only_if) that is a string should not be wrapped in {}. Wrapping a guard string in {} causes it be executed as Ruby code which will always returns true instead of a shell command that will actually run.'.freeze
40
42
 
41
- def_node_matcher :block_guard_with_only_string?, <<-PATTERN
42
- (block (send nil? ${:not_if :only_if}) (args) (str $_) )
43
- PATTERN
43
+ def_node_matcher :block_guard_with_only_string?, <<-PATTERN
44
+ (block (send nil? ${:not_if :only_if}) (args) (str $_) )
45
+ PATTERN
44
46
 
45
- def on_block(node)
46
- block_guard_with_only_string?(node) do
47
- add_offense(node, location: :expression, message: MSG, severity: :refactor)
47
+ def on_block(node)
48
+ block_guard_with_only_string?(node) do
49
+ add_offense(node, location: :expression, message: MSG, severity: :refactor)
50
+ end
48
51
  end
49
- end
50
52
 
51
- def autocorrect(node)
52
- lambda do |corrector|
53
- new_val = "#{node.method_name} #{node.body.source}"
54
- corrector.replace(node.loc.expression, new_val)
53
+ def autocorrect(node)
54
+ lambda do |corrector|
55
+ new_val = "#{node.method_name} #{node.body.source}"
56
+ corrector.replace(node.loc.expression, new_val)
57
+ end
55
58
  end
56
59
  end
57
60
  end
@@ -29,26 +29,28 @@ module RuboCop
29
29
  # # good
30
30
  # name 'foo'
31
31
  #
32
- class CookbooksDependsOnSelf < Cop
33
- MSG = 'A cookbook cannot depend on itself. This will fail on Chef Infra Client 13+'.freeze
32
+ module ChefCorrectness
33
+ class CookbooksDependsOnSelf < Cop
34
+ MSG = 'A cookbook cannot depend on itself. This will fail on Chef Infra Client 13+'.freeze
34
35
 
35
- def_node_search :dependencies, '(send nil? :depends str ...)'
36
- def_node_matcher :cb_name?, '(send nil? :name str ...)'
36
+ def_node_search :dependencies, '(send nil? :depends str ...)'
37
+ def_node_matcher :cb_name?, '(send nil? :name str ...)'
37
38
 
38
- def on_send(node)
39
- cb_name?(node) do
40
- dependencies(processed_source.ast).each do |dep|
41
- if dep.arguments == node.arguments
42
- node = dep # set our dependency node as the node for autocorrecting later
43
- add_offense(node, location: dep.source_range, message: MSG, severity: :refactor)
39
+ def on_send(node)
40
+ cb_name?(node) do
41
+ dependencies(processed_source.ast).each do |dep|
42
+ if dep.arguments == node.arguments
43
+ node = dep # set our dependency node as the node for autocorrecting later
44
+ add_offense(node, location: dep.source_range, message: MSG, severity: :refactor)
45
+ end
44
46
  end
45
47
  end
46
48
  end
47
- end
48
49
 
49
- def autocorrect(node)
50
- lambda do |corrector|
51
- corrector.remove(node.source_range)
50
+ def autocorrect(node)
51
+ lambda do |corrector|
52
+ corrector.remove(node.source_range)
53
+ end
52
54
  end
53
55
  end
54
56
  end
@@ -18,28 +18,30 @@
18
18
  module RuboCop
19
19
  module Cop
20
20
  module Chef
21
- # Metadata contains default maintainer information from the `chef generate cookbook`
22
- # command. This should be updated to reflect that actual maintainer of the cookbook.
23
- #
24
- # @example
25
- #
26
- # # bad
27
- # maintainer 'YOUR_COMPANY_NAME'
28
- # maintainer_email 'YOUR_EMAIL'
29
- #
30
- # # good
31
- # maintainer 'Bob Bobberson'
32
- # maintainer_email 'bob@bobberson.com'
33
- #
21
+ module ChefCorrectness
22
+ # Metadata contains default maintainer information from the `chef generate cookbook`
23
+ # command. This should be updated to reflect that actual maintainer of the cookbook.
24
+ #
25
+ # @example
26
+ #
27
+ # # bad
28
+ # maintainer 'YOUR_COMPANY_NAME'
29
+ # maintainer_email 'YOUR_EMAIL'
30
+ # maintainer 'The Authors'
31
+ # maintainer_email 'you@example.com'
32
+ # # good
33
+ # maintainer 'Bob Bobberson'
34
+ # maintainer_email 'bob@bobberson.com'
35
+ #
36
+ class DefaultMetadataMaintainer < Cop
37
+ MSG = 'Metadata contains default maintainer information from the cookbook generator. Add actual cookbook maintainer information to the metadata.rb.'.freeze
34
38
 
35
- class DefaultMetadataMaintainer < Cop
36
- MSG = 'Metadata contains default maintainer information from the cookbook generator. Add actual cookbook maintainer information to the metadata.rb.'.freeze
39
+ def_node_matcher :default_metadata?, '(send nil? {:maintainer :maintainer_email} (str {"YOUR_COMPANY_NAME" "The Authors" "YOUR_EMAIL" "you@example.com"}))'
37
40
 
38
- def_node_matcher :default_metadata?, '(send nil? {:maintainer :maintainer_email} (str {"YOUR_COMPANY_NAME" "YOUR_EMAIL"}))'
39
-
40
- def on_send(node)
41
- default_metadata?(node) do
42
- add_offense(node, location: :expression, message: MSG, severity: :refactor)
41
+ def on_send(node)
42
+ default_metadata?(node) do
43
+ add_offense(node, location: :expression, message: MSG, severity: :refactor)
44
+ end
43
45
  end
44
46
  end
45
47
  end
@@ -17,41 +17,43 @@
17
17
  module RuboCop
18
18
  module Cop
19
19
  module Chef
20
- # Use secure Github and Gitlab URLs for source_url and issues_url
21
- #
22
- # @example
23
- #
24
- # # bad
25
- # source_url 'http://github.com/something/something'
26
- # source_url 'http://www.github.com/something/something'
27
- # source_url 'http://www.gitlab.com/something/something'
28
- # source_url 'http://gitlab.com/something/something'
29
- #
30
- # # good
31
- # source_url 'http://github.com/something/something'
32
- # source_url 'http://gitlab.com/something/something'
33
- #
34
- class InsecureCookbookURL < Cop
35
- MSG = 'Insecure http Github or Gitlab URLs for metadata source_url/issues_url fields'.freeze
20
+ module ChefCorrectness
21
+ # Use secure Github and Gitlab URLs for source_url and issues_url
22
+ #
23
+ # @example
24
+ #
25
+ # # bad
26
+ # source_url 'http://github.com/something/something'
27
+ # source_url 'http://www.github.com/something/something'
28
+ # source_url 'http://www.gitlab.com/something/something'
29
+ # source_url 'http://gitlab.com/something/something'
30
+ #
31
+ # # good
32
+ # source_url 'http://github.com/something/something'
33
+ # source_url 'http://gitlab.com/something/something'
34
+ #
35
+ class InsecureCookbookURL < Cop
36
+ MSG = 'Insecure http Github or Gitlab URLs for metadata source_url/issues_url fields'.freeze
36
37
 
37
- def_node_matcher :insecure_cb_url?, <<-PATTERN
38
- (send nil? {:source_url :issues_url} (str #insecure_url?))
39
- PATTERN
38
+ def_node_matcher :insecure_cb_url?, <<-PATTERN
39
+ (send nil? {:source_url :issues_url} (str #insecure_url?))
40
+ PATTERN
40
41
 
41
- def insecure_url?(url)
42
- # https://rubular.com/r/dS6L6bQZvwWxWq
43
- url.match?(%r{http://(www.)*git(hub|lab)})
44
- end
42
+ def insecure_url?(url)
43
+ # https://rubular.com/r/dS6L6bQZvwWxWq
44
+ url.match?(%r{http://(www.)*git(hub|lab)})
45
+ end
45
46
 
46
- def on_send(node)
47
- insecure_cb_url?(node) do
48
- add_offense(node, location: :expression, message: MSG, severity: :refactor)
47
+ def on_send(node)
48
+ insecure_cb_url?(node) do
49
+ add_offense(node, location: :expression, message: MSG, severity: :refactor)
50
+ end
49
51
  end
50
- end
51
52
 
52
- def autocorrect(node)
53
- lambda do |corrector|
54
- corrector.replace(node.loc.expression, node.source.gsub(%r{http://(www.)*}, 'https://'))
53
+ def autocorrect(node)
54
+ lambda do |corrector|
55
+ corrector.replace(node.loc.expression, node.source.gsub(%r{http://(www.)*}, 'https://'))
56
+ end
55
57
  end
56
58
  end
57
59
  end
@@ -18,471 +18,472 @@
18
18
  module RuboCop
19
19
  module Cop
20
20
  module Chef
21
- # metadata.rb license field should include a SPDX compliant string
22
- # or "all right reserved" (not case sensitive)
23
- #
24
- # @example
25
- #
26
- # # bad
27
- # license 'Apache 2.0'
28
- #
29
- # # good
30
- # license 'Apache-2.0'
31
- # license 'all rights reserved'
32
- #
33
- # list of valid SPDX.org license strings. To build an array run this:
34
- # require 'json'
35
- # require 'net/http'
36
- # json_data = JSON.parse(Net::HTTP.get(URI('https://raw.githubusercontent.com/spdx/license-list-data/master/json/licenses.json')))
37
- # licenses = json_data['licenses'].map {|l| l['licenseId'] }.sort
38
- #
21
+ module ChefCorrectness
22
+ # metadata.rb license field should include a SPDX compliant string
23
+ # or "all right reserved" (not case sensitive)
24
+ #
25
+ # @example
26
+ #
27
+ # # bad
28
+ # license 'Apache 2.0'
29
+ #
30
+ # # good
31
+ # license 'Apache-2.0'
32
+ # license 'all rights reserved'
33
+ #
34
+ # list of valid SPDX.org license strings. To build an array run this:
35
+ # require 'json'
36
+ # require 'net/http'
37
+ # json_data = JSON.parse(Net::HTTP.get(URI('https://raw.githubusercontent.com/spdx/license-list-data/master/json/licenses.json')))
38
+ # licenses = json_data['licenses'].map {|l| l['licenseId'] }.sort
39
+ #
40
+ class InvalidLicenseString < Cop
41
+ VALID_LICENSE_STRING = %w(
42
+ 0BSD
43
+ AAL
44
+ ADSL
45
+ AFL-1.1
46
+ AFL-1.2
47
+ AFL-2.0
48
+ AFL-2.1
49
+ AFL-3.0
50
+ AGPL-1.0
51
+ AGPL-1.0-only
52
+ AGPL-1.0-or-later
53
+ AGPL-3.0
54
+ AGPL-3.0-only
55
+ AGPL-3.0-or-later
56
+ AMDPLPA
57
+ AML
58
+ AMPAS
59
+ ANTLR-PD
60
+ APAFML
61
+ APL-1.0
62
+ APSL-1.0
63
+ APSL-1.1
64
+ APSL-1.2
65
+ APSL-2.0
66
+ Abstyles
67
+ Adobe-2006
68
+ Adobe-Glyph
69
+ Afmparse
70
+ Aladdin
71
+ Apache-1.0
72
+ Apache-1.1
73
+ Apache-2.0
74
+ Artistic-1.0
75
+ Artistic-1.0-Perl
76
+ Artistic-1.0-cl8
77
+ Artistic-2.0
78
+ BSD-1-Clause
79
+ BSD-2-Clause
80
+ BSD-2-Clause-FreeBSD
81
+ BSD-2-Clause-NetBSD
82
+ BSD-2-Clause-Patent
83
+ BSD-3-Clause
84
+ BSD-3-Clause-Attribution
85
+ BSD-3-Clause-Clear
86
+ BSD-3-Clause-LBNL
87
+ BSD-3-Clause-No-Nuclear-License
88
+ BSD-3-Clause-No-Nuclear-License-2014
89
+ BSD-3-Clause-No-Nuclear-Warranty
90
+ BSD-3-Clause-Open-MPI
91
+ BSD-4-Clause
92
+ BSD-4-Clause-UC
93
+ BSD-Protection
94
+ BSD-Source-Code
95
+ BSL-1.0
96
+ Bahyph
97
+ Barr
98
+ Beerware
99
+ BitTorrent-1.0
100
+ BitTorrent-1.1
101
+ BlueOak-1.0.0
102
+ Borceux
103
+ CATOSL-1.1
104
+ CC-BY-1.0
105
+ CC-BY-2.0
106
+ CC-BY-2.5
107
+ CC-BY-3.0
108
+ CC-BY-4.0
109
+ CC-BY-NC-1.0
110
+ CC-BY-NC-2.0
111
+ CC-BY-NC-2.5
112
+ CC-BY-NC-3.0
113
+ CC-BY-NC-4.0
114
+ CC-BY-NC-ND-1.0
115
+ CC-BY-NC-ND-2.0
116
+ CC-BY-NC-ND-2.5
117
+ CC-BY-NC-ND-3.0
118
+ CC-BY-NC-ND-4.0
119
+ CC-BY-NC-SA-1.0
120
+ CC-BY-NC-SA-2.0
121
+ CC-BY-NC-SA-2.5
122
+ CC-BY-NC-SA-3.0
123
+ CC-BY-NC-SA-4.0
124
+ CC-BY-ND-1.0
125
+ CC-BY-ND-2.0
126
+ CC-BY-ND-2.5
127
+ CC-BY-ND-3.0
128
+ CC-BY-ND-4.0
129
+ CC-BY-SA-1.0
130
+ CC-BY-SA-2.0
131
+ CC-BY-SA-2.5
132
+ CC-BY-SA-3.0
133
+ CC-BY-SA-4.0
134
+ CC-PDDC
135
+ CC0-1.0
136
+ CDDL-1.0
137
+ CDDL-1.1
138
+ CDLA-Permissive-1.0
139
+ CDLA-Sharing-1.0
140
+ CECILL-1.0
141
+ CECILL-1.1
142
+ CECILL-2.0
143
+ CECILL-2.1
144
+ CECILL-B
145
+ CECILL-C
146
+ CERN-OHL-1.1
147
+ CERN-OHL-1.2
148
+ CNRI-Jython
149
+ CNRI-Python
150
+ CNRI-Python-GPL-Compatible
151
+ CPAL-1.0
152
+ CPL-1.0
153
+ CPOL-1.02
154
+ CUA-OPL-1.0
155
+ Caldera
156
+ ClArtistic
157
+ Condor-1.1
158
+ Crossword
159
+ CrystalStacker
160
+ Cube
161
+ D-FSL-1.0
162
+ DOC
163
+ DSDP
164
+ Dotseqn
165
+ ECL-1.0
166
+ ECL-2.0
167
+ EFL-1.0
168
+ EFL-2.0
169
+ EPL-1.0
170
+ EPL-2.0
171
+ EUDatagrid
172
+ EUPL-1.0
173
+ EUPL-1.1
174
+ EUPL-1.2
175
+ Entessa
176
+ ErlPL-1.1
177
+ Eurosym
178
+ FSFAP
179
+ FSFUL
180
+ FSFULLR
181
+ FTL
182
+ Fair
183
+ Frameworx-1.0
184
+ FreeImage
185
+ GFDL-1.1
186
+ GFDL-1.1-only
187
+ GFDL-1.1-or-later
188
+ GFDL-1.2
189
+ GFDL-1.2-only
190
+ GFDL-1.2-or-later
191
+ GFDL-1.3
192
+ GFDL-1.3-only
193
+ GFDL-1.3-or-later
194
+ GL2PS
195
+ GPL-1.0
196
+ GPL-1.0+
197
+ GPL-1.0-only
198
+ GPL-1.0-or-later
199
+ GPL-2.0
200
+ GPL-2.0+
201
+ GPL-2.0-only
202
+ GPL-2.0-or-later
203
+ GPL-2.0-with-GCC-exception
204
+ GPL-2.0-with-autoconf-exception
205
+ GPL-2.0-with-bison-exception
206
+ GPL-2.0-with-classpath-exception
207
+ GPL-2.0-with-font-exception
208
+ GPL-3.0
209
+ GPL-3.0+
210
+ GPL-3.0-only
211
+ GPL-3.0-or-later
212
+ GPL-3.0-with-GCC-exception
213
+ GPL-3.0-with-autoconf-exception
214
+ Giftware
215
+ Glide
216
+ Glulxe
217
+ HPND
218
+ HPND-sell-variant
219
+ HaskellReport
220
+ IBM-pibs
221
+ ICU
222
+ IJG
223
+ IPA
224
+ IPL-1.0
225
+ ISC
226
+ ImageMagick
227
+ Imlib2
228
+ Info-ZIP
229
+ Intel
230
+ Intel-ACPI
231
+ Interbase-1.0
232
+ JPNIC
233
+ JSON
234
+ JasPer-2.0
235
+ LAL-1.2
236
+ LAL-1.3
237
+ LGPL-2.0
238
+ LGPL-2.0+
239
+ LGPL-2.0-only
240
+ LGPL-2.0-or-later
241
+ LGPL-2.1
242
+ LGPL-2.1+
243
+ LGPL-2.1-only
244
+ LGPL-2.1-or-later
245
+ LGPL-3.0
246
+ LGPL-3.0+
247
+ LGPL-3.0-only
248
+ LGPL-3.0-or-later
249
+ LGPLLR
250
+ LPL-1.0
251
+ LPL-1.02
252
+ LPPL-1.0
253
+ LPPL-1.1
254
+ LPPL-1.2
255
+ LPPL-1.3a
256
+ LPPL-1.3c
257
+ Latex2e
258
+ Leptonica
259
+ LiLiQ-P-1.1
260
+ LiLiQ-R-1.1
261
+ LiLiQ-Rplus-1.1
262
+ Libpng
263
+ Linux-OpenIB
264
+ MIT
265
+ MIT-0
266
+ MIT-CMU
267
+ MIT-advertising
268
+ MIT-enna
269
+ MIT-feh
270
+ MITNFA
271
+ MPL-1.0
272
+ MPL-1.1
273
+ MPL-2.0
274
+ MPL-2.0-no-copyleft-exception
275
+ MS-PL
276
+ MS-RL
277
+ MTLL
278
+ MakeIndex
279
+ MirOS
280
+ Motosoto
281
+ Multics
282
+ Mup
283
+ NASA-1.3
284
+ NBPL-1.0
285
+ NCSA
286
+ NGPL
287
+ NLOD-1.0
288
+ NLPL
289
+ NOSL
290
+ NPL-1.0
291
+ NPL-1.1
292
+ NPOSL-3.0
293
+ NRL
294
+ NTP
295
+ Naumen
296
+ Net-SNMP
297
+ NetCDF
298
+ Newsletr
299
+ Nokia
300
+ Noweb
301
+ Nunit
302
+ OCCT-PL
303
+ OCLC-2.0
304
+ ODC-By-1.0
305
+ ODbL-1.0
306
+ OFL-1.0
307
+ OFL-1.1
308
+ OGL-UK-1.0
309
+ OGL-UK-2.0
310
+ OGL-UK-3.0
311
+ OGTSL
312
+ OLDAP-1.1
313
+ OLDAP-1.2
314
+ OLDAP-1.3
315
+ OLDAP-1.4
316
+ OLDAP-2.0
317
+ OLDAP-2.0.1
318
+ OLDAP-2.1
319
+ OLDAP-2.2
320
+ OLDAP-2.2.1
321
+ OLDAP-2.2.2
322
+ OLDAP-2.3
323
+ OLDAP-2.4
324
+ OLDAP-2.5
325
+ OLDAP-2.6
326
+ OLDAP-2.7
327
+ OLDAP-2.8
328
+ OML
329
+ OPL-1.0
330
+ OSET-PL-2.1
331
+ OSL-1.0
332
+ OSL-1.1
333
+ OSL-2.0
334
+ OSL-2.1
335
+ OSL-3.0
336
+ OpenSSL
337
+ PDDL-1.0
338
+ PHP-3.0
339
+ PHP-3.01
340
+ Parity-6.0.0
341
+ Plexus
342
+ PostgreSQL
343
+ Python-2.0
344
+ QPL-1.0
345
+ Qhull
346
+ RHeCos-1.1
347
+ RPL-1.1
348
+ RPL-1.5
349
+ RPSL-1.0
350
+ RSA-MD
351
+ RSCPL
352
+ Rdisc
353
+ Ruby
354
+ SAX-PD
355
+ SCEA
356
+ SGI-B-1.0
357
+ SGI-B-1.1
358
+ SGI-B-2.0
359
+ SHL-0.5
360
+ SHL-0.51
361
+ SISSL
362
+ SISSL-1.2
363
+ SMLNJ
364
+ SMPPL
365
+ SNIA
366
+ SPL-1.0
367
+ SSPL-1.0
368
+ SWL
369
+ Saxpath
370
+ Sendmail
371
+ Sendmail-8.23
372
+ SimPL-2.0
373
+ Sleepycat
374
+ Spencer-86
375
+ Spencer-94
376
+ Spencer-99
377
+ StandardML-NJ
378
+ SugarCRM-1.1.3
379
+ TAPR-OHL-1.0
380
+ TCL
381
+ TCP-wrappers
382
+ TMate
383
+ TORQUE-1.1
384
+ TOSL
385
+ TU-Berlin-1.0
386
+ TU-Berlin-2.0
387
+ UPL-1.0
388
+ Unicode-DFS-2015
389
+ Unicode-DFS-2016
390
+ Unicode-TOU
391
+ Unlicense
392
+ VOSTROM
393
+ VSL-1.0
394
+ Vim
395
+ W3C
396
+ W3C-19980720
397
+ W3C-20150513
398
+ WTFPL
399
+ Watcom-1.0
400
+ Wsuipa
401
+ X11
402
+ XFree86-1.1
403
+ XSkat
404
+ Xerox
405
+ Xnet
406
+ YPL-1.0
407
+ YPL-1.1
408
+ ZPL-1.1
409
+ ZPL-2.0
410
+ ZPL-2.1
411
+ Zed
412
+ Zend-2.0
413
+ Zimbra-1.3
414
+ Zimbra-1.4
415
+ Zlib
416
+ blessing
417
+ bzip2-1.0.5
418
+ bzip2-1.0.6
419
+ copyleft-next-0.3.0
420
+ copyleft-next-0.3.1
421
+ curl
422
+ diffmark
423
+ dvipdfm
424
+ eCos-2.0
425
+ eGenix
426
+ gSOAP-1.3b
427
+ gnuplot
428
+ iMatix
429
+ libpng-2.0
430
+ libtiff
431
+ mpich2
432
+ psfrag
433
+ psutils
434
+ wxWindows
435
+ xinetd
436
+ xpp
437
+ zlib-acknowledgement
438
+ ).freeze
39
439
 
40
- class InvalidLicenseString < Cop
41
- VALID_LICENSE_STRING = %w(
42
- 0BSD
43
- AAL
44
- ADSL
45
- AFL-1.1
46
- AFL-1.2
47
- AFL-2.0
48
- AFL-2.1
49
- AFL-3.0
50
- AGPL-1.0
51
- AGPL-1.0-only
52
- AGPL-1.0-or-later
53
- AGPL-3.0
54
- AGPL-3.0-only
55
- AGPL-3.0-or-later
56
- AMDPLPA
57
- AML
58
- AMPAS
59
- ANTLR-PD
60
- APAFML
61
- APL-1.0
62
- APSL-1.0
63
- APSL-1.1
64
- APSL-1.2
65
- APSL-2.0
66
- Abstyles
67
- Adobe-2006
68
- Adobe-Glyph
69
- Afmparse
70
- Aladdin
71
- Apache-1.0
72
- Apache-1.1
73
- Apache-2.0
74
- Artistic-1.0
75
- Artistic-1.0-Perl
76
- Artistic-1.0-cl8
77
- Artistic-2.0
78
- BSD-1-Clause
79
- BSD-2-Clause
80
- BSD-2-Clause-FreeBSD
81
- BSD-2-Clause-NetBSD
82
- BSD-2-Clause-Patent
83
- BSD-3-Clause
84
- BSD-3-Clause-Attribution
85
- BSD-3-Clause-Clear
86
- BSD-3-Clause-LBNL
87
- BSD-3-Clause-No-Nuclear-License
88
- BSD-3-Clause-No-Nuclear-License-2014
89
- BSD-3-Clause-No-Nuclear-Warranty
90
- BSD-3-Clause-Open-MPI
91
- BSD-4-Clause
92
- BSD-4-Clause-UC
93
- BSD-Protection
94
- BSD-Source-Code
95
- BSL-1.0
96
- Bahyph
97
- Barr
98
- Beerware
99
- BitTorrent-1.0
100
- BitTorrent-1.1
101
- BlueOak-1.0.0
102
- Borceux
103
- CATOSL-1.1
104
- CC-BY-1.0
105
- CC-BY-2.0
106
- CC-BY-2.5
107
- CC-BY-3.0
108
- CC-BY-4.0
109
- CC-BY-NC-1.0
110
- CC-BY-NC-2.0
111
- CC-BY-NC-2.5
112
- CC-BY-NC-3.0
113
- CC-BY-NC-4.0
114
- CC-BY-NC-ND-1.0
115
- CC-BY-NC-ND-2.0
116
- CC-BY-NC-ND-2.5
117
- CC-BY-NC-ND-3.0
118
- CC-BY-NC-ND-4.0
119
- CC-BY-NC-SA-1.0
120
- CC-BY-NC-SA-2.0
121
- CC-BY-NC-SA-2.5
122
- CC-BY-NC-SA-3.0
123
- CC-BY-NC-SA-4.0
124
- CC-BY-ND-1.0
125
- CC-BY-ND-2.0
126
- CC-BY-ND-2.5
127
- CC-BY-ND-3.0
128
- CC-BY-ND-4.0
129
- CC-BY-SA-1.0
130
- CC-BY-SA-2.0
131
- CC-BY-SA-2.5
132
- CC-BY-SA-3.0
133
- CC-BY-SA-4.0
134
- CC-PDDC
135
- CC0-1.0
136
- CDDL-1.0
137
- CDDL-1.1
138
- CDLA-Permissive-1.0
139
- CDLA-Sharing-1.0
140
- CECILL-1.0
141
- CECILL-1.1
142
- CECILL-2.0
143
- CECILL-2.1
144
- CECILL-B
145
- CECILL-C
146
- CERN-OHL-1.1
147
- CERN-OHL-1.2
148
- CNRI-Jython
149
- CNRI-Python
150
- CNRI-Python-GPL-Compatible
151
- CPAL-1.0
152
- CPL-1.0
153
- CPOL-1.02
154
- CUA-OPL-1.0
155
- Caldera
156
- ClArtistic
157
- Condor-1.1
158
- Crossword
159
- CrystalStacker
160
- Cube
161
- D-FSL-1.0
162
- DOC
163
- DSDP
164
- Dotseqn
165
- ECL-1.0
166
- ECL-2.0
167
- EFL-1.0
168
- EFL-2.0
169
- EPL-1.0
170
- EPL-2.0
171
- EUDatagrid
172
- EUPL-1.0
173
- EUPL-1.1
174
- EUPL-1.2
175
- Entessa
176
- ErlPL-1.1
177
- Eurosym
178
- FSFAP
179
- FSFUL
180
- FSFULLR
181
- FTL
182
- Fair
183
- Frameworx-1.0
184
- FreeImage
185
- GFDL-1.1
186
- GFDL-1.1-only
187
- GFDL-1.1-or-later
188
- GFDL-1.2
189
- GFDL-1.2-only
190
- GFDL-1.2-or-later
191
- GFDL-1.3
192
- GFDL-1.3-only
193
- GFDL-1.3-or-later
194
- GL2PS
195
- GPL-1.0
196
- GPL-1.0+
197
- GPL-1.0-only
198
- GPL-1.0-or-later
199
- GPL-2.0
200
- GPL-2.0+
201
- GPL-2.0-only
202
- GPL-2.0-or-later
203
- GPL-2.0-with-GCC-exception
204
- GPL-2.0-with-autoconf-exception
205
- GPL-2.0-with-bison-exception
206
- GPL-2.0-with-classpath-exception
207
- GPL-2.0-with-font-exception
208
- GPL-3.0
209
- GPL-3.0+
210
- GPL-3.0-only
211
- GPL-3.0-or-later
212
- GPL-3.0-with-GCC-exception
213
- GPL-3.0-with-autoconf-exception
214
- Giftware
215
- Glide
216
- Glulxe
217
- HPND
218
- HPND-sell-variant
219
- HaskellReport
220
- IBM-pibs
221
- ICU
222
- IJG
223
- IPA
224
- IPL-1.0
225
- ISC
226
- ImageMagick
227
- Imlib2
228
- Info-ZIP
229
- Intel
230
- Intel-ACPI
231
- Interbase-1.0
232
- JPNIC
233
- JSON
234
- JasPer-2.0
235
- LAL-1.2
236
- LAL-1.3
237
- LGPL-2.0
238
- LGPL-2.0+
239
- LGPL-2.0-only
240
- LGPL-2.0-or-later
241
- LGPL-2.1
242
- LGPL-2.1+
243
- LGPL-2.1-only
244
- LGPL-2.1-or-later
245
- LGPL-3.0
246
- LGPL-3.0+
247
- LGPL-3.0-only
248
- LGPL-3.0-or-later
249
- LGPLLR
250
- LPL-1.0
251
- LPL-1.02
252
- LPPL-1.0
253
- LPPL-1.1
254
- LPPL-1.2
255
- LPPL-1.3a
256
- LPPL-1.3c
257
- Latex2e
258
- Leptonica
259
- LiLiQ-P-1.1
260
- LiLiQ-R-1.1
261
- LiLiQ-Rplus-1.1
262
- Libpng
263
- Linux-OpenIB
264
- MIT
265
- MIT-0
266
- MIT-CMU
267
- MIT-advertising
268
- MIT-enna
269
- MIT-feh
270
- MITNFA
271
- MPL-1.0
272
- MPL-1.1
273
- MPL-2.0
274
- MPL-2.0-no-copyleft-exception
275
- MS-PL
276
- MS-RL
277
- MTLL
278
- MakeIndex
279
- MirOS
280
- Motosoto
281
- Multics
282
- Mup
283
- NASA-1.3
284
- NBPL-1.0
285
- NCSA
286
- NGPL
287
- NLOD-1.0
288
- NLPL
289
- NOSL
290
- NPL-1.0
291
- NPL-1.1
292
- NPOSL-3.0
293
- NRL
294
- NTP
295
- Naumen
296
- Net-SNMP
297
- NetCDF
298
- Newsletr
299
- Nokia
300
- Noweb
301
- Nunit
302
- OCCT-PL
303
- OCLC-2.0
304
- ODC-By-1.0
305
- ODbL-1.0
306
- OFL-1.0
307
- OFL-1.1
308
- OGL-UK-1.0
309
- OGL-UK-2.0
310
- OGL-UK-3.0
311
- OGTSL
312
- OLDAP-1.1
313
- OLDAP-1.2
314
- OLDAP-1.3
315
- OLDAP-1.4
316
- OLDAP-2.0
317
- OLDAP-2.0.1
318
- OLDAP-2.1
319
- OLDAP-2.2
320
- OLDAP-2.2.1
321
- OLDAP-2.2.2
322
- OLDAP-2.3
323
- OLDAP-2.4
324
- OLDAP-2.5
325
- OLDAP-2.6
326
- OLDAP-2.7
327
- OLDAP-2.8
328
- OML
329
- OPL-1.0
330
- OSET-PL-2.1
331
- OSL-1.0
332
- OSL-1.1
333
- OSL-2.0
334
- OSL-2.1
335
- OSL-3.0
336
- OpenSSL
337
- PDDL-1.0
338
- PHP-3.0
339
- PHP-3.01
340
- Parity-6.0.0
341
- Plexus
342
- PostgreSQL
343
- Python-2.0
344
- QPL-1.0
345
- Qhull
346
- RHeCos-1.1
347
- RPL-1.1
348
- RPL-1.5
349
- RPSL-1.0
350
- RSA-MD
351
- RSCPL
352
- Rdisc
353
- Ruby
354
- SAX-PD
355
- SCEA
356
- SGI-B-1.0
357
- SGI-B-1.1
358
- SGI-B-2.0
359
- SHL-0.5
360
- SHL-0.51
361
- SISSL
362
- SISSL-1.2
363
- SMLNJ
364
- SMPPL
365
- SNIA
366
- SPL-1.0
367
- SSPL-1.0
368
- SWL
369
- Saxpath
370
- Sendmail
371
- Sendmail-8.23
372
- SimPL-2.0
373
- Sleepycat
374
- Spencer-86
375
- Spencer-94
376
- Spencer-99
377
- StandardML-NJ
378
- SugarCRM-1.1.3
379
- TAPR-OHL-1.0
380
- TCL
381
- TCP-wrappers
382
- TMate
383
- TORQUE-1.1
384
- TOSL
385
- TU-Berlin-1.0
386
- TU-Berlin-2.0
387
- UPL-1.0
388
- Unicode-DFS-2015
389
- Unicode-DFS-2016
390
- Unicode-TOU
391
- Unlicense
392
- VOSTROM
393
- VSL-1.0
394
- Vim
395
- W3C
396
- W3C-19980720
397
- W3C-20150513
398
- WTFPL
399
- Watcom-1.0
400
- Wsuipa
401
- X11
402
- XFree86-1.1
403
- XSkat
404
- Xerox
405
- Xnet
406
- YPL-1.0
407
- YPL-1.1
408
- ZPL-1.1
409
- ZPL-2.0
410
- ZPL-2.1
411
- Zed
412
- Zend-2.0
413
- Zimbra-1.3
414
- Zimbra-1.4
415
- Zlib
416
- blessing
417
- bzip2-1.0.5
418
- bzip2-1.0.6
419
- copyleft-next-0.3.0
420
- copyleft-next-0.3.1
421
- curl
422
- diffmark
423
- dvipdfm
424
- eCos-2.0
425
- eGenix
426
- gSOAP-1.3b
427
- gnuplot
428
- iMatix
429
- libpng-2.0
430
- libtiff
431
- mpich2
432
- psfrag
433
- psutils
434
- wxWindows
435
- xinetd
436
- xpp
437
- zlib-acknowledgement
438
- ).freeze
440
+ COMMON_TYPOS = {
441
+ "all_rights": 'all rights reserved',
442
+ "apache 2.0": 'Apache-2.0',
443
+ "apache v2.0": 'Apache-2.0',
444
+ "apache license version 2.0": 'Apache-2.0',
445
+ "apache2": 'Apache-2.0',
446
+ "mit": 'MIT',
447
+ '3-clause bsd': 'BSD-3-Clause',
448
+ 'gnu public license 3.0': 'GPL-3.0',
449
+ 'gpl v2': 'GPL-2.0',
450
+ 'gpl v3': 'GPL-3.0',
451
+ 'gplv2': 'GPL-2.0',
452
+ 'gplv3': 'GPL-3.0',
453
+ 'mit license': 'MIT',
454
+ }.freeze
439
455
 
440
- COMMON_TYPOS = {
441
- "all_rights": 'all rights reserved',
442
- "apache 2.0": 'Apache-2.0',
443
- "apache v2.0": 'Apache-2.0',
444
- "apache license version 2.0": 'Apache-2.0',
445
- "apache2": 'Apache-2.0',
446
- "mit": 'MIT',
447
- '3-clause bsd': 'BSD-3-Clause',
448
- 'gnu public license 3.0': 'GPL-3.0',
449
- 'gpl v2': 'GPL-2.0',
450
- 'gpl v3': 'GPL-3.0',
451
- 'gplv2': 'GPL-2.0',
452
- 'gplv3': 'GPL-3.0',
453
- 'mit license': 'MIT',
454
- }.freeze
456
+ MSG = 'Cookbook metadata.rb does not use a SPDX compliant license string or "all rights reserved". See https://spdx.org/licenses/ for a complete list of license identifiers.'.freeze
455
457
 
456
- MSG = 'Cookbook metadata.rb does not use a SPDX compliant license string or "all rights reserved". See https://spdx.org/licenses/ for a complete list of license identifiers.'.freeze
458
+ def_node_matcher :license?, '(send nil? :license $str ...)'
457
459
 
458
- def_node_matcher :license?, '(send nil? :license $str ...)'
459
-
460
- def on_send(node)
461
- license?(node) do |license|
462
- unless valid_license?(license.str_content)
463
- add_offense(license, location: :expression, message: MSG, severity: :refactor)
460
+ def on_send(node)
461
+ license?(node) do |license|
462
+ unless valid_license?(license.str_content)
463
+ add_offense(license, location: :expression, message: MSG, severity: :refactor)
464
+ end
464
465
  end
465
466
  end
466
- end
467
467
 
468
- def autocorrect(node)
469
- correct_string = autocorrect_license_string(node.str_content)
470
- if correct_string
471
- lambda do |corrector|
472
- corrector.replace(node.loc.expression, "'#{correct_string}'")
468
+ def autocorrect(node)
469
+ correct_string = autocorrect_license_string(node.str_content)
470
+ if correct_string
471
+ lambda do |corrector|
472
+ corrector.replace(node.loc.expression, "'#{correct_string}'")
473
+ end
473
474
  end
474
475
  end
475
- end
476
476
 
477
- # private
477
+ # private
478
478
 
479
- def autocorrect_license_string(bad_string)
480
- COMMON_TYPOS[bad_string.delete(',').downcase.to_sym]
481
- end
479
+ def autocorrect_license_string(bad_string)
480
+ COMMON_TYPOS[bad_string.delete(',').downcase.to_sym]
481
+ end
482
482
 
483
- def valid_license?(license)
484
- VALID_LICENSE_STRING.include?(license) ||
485
- license.downcase == 'all rights reserved'
483
+ def valid_license?(license)
484
+ VALID_LICENSE_STRING.include?(license) ||
485
+ license.downcase == 'all rights reserved'
486
+ end
486
487
  end
487
488
  end
488
489
  end