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
@@ -17,18 +17,20 @@
17
17
  module RuboCop
18
18
  module Cop
19
19
  module Chef
20
- # Data bags cannot be used with the Effortless Infra pattern
21
- #
22
- # @example
23
- #
24
- # # bad
25
- # data_bag_item('admins', login)
26
- # data_bag(data_bag_name)
27
- class CookbookUsesDatabags < Cop
28
- MSG = 'Cookbook uses data bags, which cannot be used in the Effortless Infra pattern'.freeze
20
+ module ChefEffortless
21
+ # Data bags cannot be used with the Effortless Infra pattern
22
+ #
23
+ # @example
24
+ #
25
+ # # bad
26
+ # data_bag_item('admins', login)
27
+ # data_bag(data_bag_name)
28
+ class CookbookUsesDatabags < Cop
29
+ MSG = 'Cookbook uses data bags, which cannot be used in the Effortless Infra pattern'.freeze
29
30
 
30
- def on_send(node)
31
- add_offense(node, location: :expression, message: MSG, severity: :refactor) if %i(data_bag data_bag_item).include?(node.method_name)
31
+ def on_send(node)
32
+ add_offense(node, location: :expression, message: MSG, severity: :refactor) if %i(data_bag data_bag_item).include?(node.method_name)
33
+ end
32
34
  end
33
35
  end
34
36
  end
@@ -17,18 +17,20 @@
17
17
  module RuboCop
18
18
  module Cop
19
19
  module Chef
20
- # Search is not compatible with the Effortless Infra pattern
21
- #
22
- # @example
23
- #
24
- # # bad
25
- # search(:node, 'run_list:recipe\[bacula\:\:server\]')
26
- #
27
- class CookbookUsesSearch < Cop
28
- MSG = 'Cookbook uses search, which cannot be used in the Effortless Infra pattern'.freeze
20
+ module ChefEffortless
21
+ # Search is not compatible with the Effortless Infra pattern
22
+ #
23
+ # @example
24
+ #
25
+ # # bad
26
+ # search(:node, 'run_list:recipe\[bacula\:\:server\]')
27
+ #
28
+ class CookbookUsesSearch < Cop
29
+ MSG = 'Cookbook uses search, which cannot be used in the Effortless Infra pattern'.freeze
29
30
 
30
- def on_send(node)
31
- add_offense(node, location: :expression, message: MSG, severity: :refactor) if node.method_name == :search
31
+ def on_send(node)
32
+ add_offense(node, location: :expression, message: MSG, severity: :refactor) if node.method_name == :search
33
+ end
32
34
  end
33
35
  end
34
36
  end
@@ -17,28 +17,30 @@
17
17
  module RuboCop
18
18
  module Cop
19
19
  module Chef
20
- # Don't include the apt default recipe to update apt's package cache when you can
21
- # use the apt_update resource built into Chef Infra Client 12.7 and later.
22
- #
23
- # @example
24
- #
25
- # # bad
26
- # include_recipe 'apt::default'
27
- # include_recipe 'apt'
28
- #
29
- # # good
30
- # apt_update
31
- #
32
- class IncludingAptDefaultRecipe < Cop
33
- MSG = 'Do not include the Apt default recipe to update package cache. Instead use the apt_update resource, which is built into Chef Infra Client 12.7 and later.'.freeze
20
+ module ChefModernize
21
+ # Don't include the apt default recipe to update apt's package cache when you can
22
+ # use the apt_update resource built into Chef Infra Client 12.7 and later.
23
+ #
24
+ # @example
25
+ #
26
+ # # bad
27
+ # include_recipe 'apt::default'
28
+ # include_recipe 'apt'
29
+ #
30
+ # # good
31
+ # apt_update
32
+ #
33
+ class IncludingAptDefaultRecipe < Cop
34
+ MSG = 'Do not include the Apt default recipe to update package cache. Instead use the apt_update resource, which is built into Chef Infra Client 12.7 and later.'.freeze
34
35
 
35
- def_node_matcher :apt_recipe_usage?, <<-PATTERN
36
- (send nil? :include_recipe (str {"apt" "apt::default"}))
37
- PATTERN
36
+ def_node_matcher :apt_recipe_usage?, <<-PATTERN
37
+ (send nil? :include_recipe (str {"apt" "apt::default"}))
38
+ PATTERN
38
39
 
39
- def on_send(node)
40
- apt_recipe_usage?(node) do
41
- add_offense(node, location: :expression, message: MSG, severity: :refactor)
40
+ def on_send(node)
41
+ apt_recipe_usage?(node) do
42
+ add_offense(node, location: :expression, message: MSG, severity: :refactor)
43
+ end
42
44
  end
43
45
  end
44
46
  end
@@ -17,40 +17,42 @@
17
17
  module RuboCop
18
18
  module Cop
19
19
  module Chef
20
- # Over the course of years there have been many different valid community site / Supermarket
21
- # URLs to use in a cookbook's Berksfile. These old URLs continue to function via redirects,
22
- # but should be updated to point to the latest Supermarket URL.
23
- #
24
- # @example
25
- #
26
- # # bad
27
- # source 'http://community.opscode.com/api/v3'
28
- # source 'https://supermarket.getchef.com'
29
- # source 'https://api.berkshelf.com'
30
- #
31
- # # good
32
- # source 'https://supermarket.chef.io'
33
- #
34
- class LegacyBerksfileSource < Cop
35
- MSG = 'Do not use legacy Berksfile community sources. Use Chef Supermarket instead.'.freeze
20
+ module ChefModernize
21
+ # Over the course of years there have been many different valid community site / Supermarket
22
+ # URLs to use in a cookbook's Berksfile. These old URLs continue to function via redirects,
23
+ # but should be updated to point to the latest Supermarket URL.
24
+ #
25
+ # @example
26
+ #
27
+ # # bad
28
+ # source 'http://community.opscode.com/api/v3'
29
+ # source 'https://supermarket.getchef.com'
30
+ # source 'https://api.berkshelf.com'
31
+ #
32
+ # # good
33
+ # source 'https://supermarket.chef.io'
34
+ #
35
+ class LegacyBerksfileSource < Cop
36
+ MSG = 'Do not use legacy Berksfile community sources. Use Chef Supermarket instead.'.freeze
36
37
 
37
- def_node_matcher :berksfile_source?, <<-PATTERN
38
- (send nil? :source (str #old_berkshelf_url?))
39
- PATTERN
38
+ def_node_matcher :berksfile_source?, <<-PATTERN
39
+ (send nil? :source (str #old_berkshelf_url?))
40
+ PATTERN
40
41
 
41
- def old_berkshelf_url?(url)
42
- %w(http://community.opscode.com/api/v3 https://supermarket.getchef.com https://api.berkshelf.com).include?(url)
43
- end
42
+ def old_berkshelf_url?(url)
43
+ %w(http://community.opscode.com/api/v3 https://supermarket.getchef.com https://api.berkshelf.com).include?(url)
44
+ end
44
45
 
45
- def on_send(node)
46
- berksfile_source?(node) do
47
- add_offense(node, location: :expression, message: MSG, severity: :refactor)
46
+ def on_send(node)
47
+ berksfile_source?(node) do
48
+ add_offense(node, location: :expression, message: MSG, severity: :refactor)
49
+ end
48
50
  end
49
- end
50
51
 
51
- def autocorrect(node)
52
- lambda do |corrector|
53
- corrector.replace(node.loc.expression, "source 'https://supermarket.chef.io'")
52
+ def autocorrect(node)
53
+ lambda do |corrector|
54
+ corrector.replace(node.loc.expression, "source 'https://supermarket.chef.io'")
55
+ end
54
56
  end
55
57
  end
56
58
  end
@@ -17,33 +17,35 @@
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
- # depends 'build-essential'
26
- # include_recipe 'build-essential::default'
27
- # include_recipe 'build-essential'
28
- #
29
- # # good
30
- # build_essential 'install compilation tools'
31
- class UseBuildEssentialResource < Cop
32
- MSG = 'Use the build_essential resource instead of the legacy build-essential recipe. This resource ships in the build-essential cookbook v5.0+ and is built into Chef Infra Client 14+'.freeze
20
+ module ChefModernize
21
+ # Use secure Github and Gitlab URLs for source_url and issues_url
22
+ #
23
+ # @example
24
+ #
25
+ # # bad
26
+ # depends 'build-essential'
27
+ # include_recipe 'build-essential::default'
28
+ # include_recipe 'build-essential'
29
+ #
30
+ # # good
31
+ # build_essential 'install compilation tools'
32
+ class UseBuildEssentialResource < Cop
33
+ MSG = 'Use the build_essential resource instead of the legacy build-essential recipe. This resource ships in the build-essential cookbook v5.0+ and is built into Chef Infra Client 14+'.freeze
33
34
 
34
- def_node_matcher :build_essential_recipe_usage?, <<-PATTERN
35
- (send nil? :include_recipe (str {"build-essential" "build-essential::default"}))
36
- PATTERN
35
+ def_node_matcher :build_essential_recipe_usage?, <<-PATTERN
36
+ (send nil? :include_recipe (str {"build-essential" "build-essential::default"}))
37
+ PATTERN
37
38
 
38
- def on_send(node)
39
- build_essential_recipe_usage?(node) do
40
- add_offense(node, location: :expression, message: MSG, severity: :refactor)
39
+ def on_send(node)
40
+ build_essential_recipe_usage?(node) do
41
+ add_offense(node, location: :expression, message: MSG, severity: :refactor)
42
+ end
41
43
  end
42
- end
43
44
 
44
- def autocorrect(node)
45
- lambda do |corrector|
46
- corrector.replace(node.loc.expression, "build_essential 'install compilation tools'")
45
+ def autocorrect(node)
46
+ lambda do |corrector|
47
+ corrector.replace(node.loc.expression, "build_essential 'install compilation tools'")
48
+ end
47
49
  end
48
50
  end
49
51
  end
@@ -17,35 +17,37 @@
17
17
  module RuboCop
18
18
  module Cop
19
19
  module Chef
20
- # Don't depend on cookbooks made obsolete by Chef 14
21
- #
22
- # @example
23
- #
24
- # # bad
25
- # depends 'build-essential'
26
- # depends 'chef_handler'
27
- # depends 'chef_hostname'
28
- # depends 'dmg'
29
- # depends 'mac_os_x'
30
- # depends 'swap'
31
- # depends 'sysctl'
32
- #
33
- class UnnecessaryDependsChef14 < Cop
34
- MSG = "Don't depend on cookbooks made obsolete by Chef 14".freeze
20
+ module ChefModernize
21
+ # Don't depend on cookbooks made obsolete by Chef 14
22
+ #
23
+ # @example
24
+ #
25
+ # # bad
26
+ # depends 'build-essential'
27
+ # depends 'chef_handler'
28
+ # depends 'chef_hostname'
29
+ # depends 'dmg'
30
+ # depends 'mac_os_x'
31
+ # depends 'swap'
32
+ # depends 'sysctl'
33
+ #
34
+ class UnnecessaryDependsChef14 < Cop
35
+ MSG = "Don't depend on cookbooks made obsolete by Chef 14".freeze
35
36
 
36
- def_node_matcher :legacy_depends?, <<-PATTERN
37
- (send nil? :depends (str {"build-essential" "chef_handler" "chef_hostname" "dmg" "mac_os_x" "swap" "sysctl"}))
38
- PATTERN
37
+ def_node_matcher :legacy_depends?, <<-PATTERN
38
+ (send nil? :depends (str {"build-essential" "chef_handler" "chef_hostname" "dmg" "mac_os_x" "swap" "sysctl"}))
39
+ PATTERN
39
40
 
40
- def on_send(node)
41
- legacy_depends?(node) do
42
- add_offense(node, location: :expression, message: MSG, severity: :refactor)
41
+ def on_send(node)
42
+ legacy_depends?(node) do
43
+ add_offense(node, location: :expression, message: MSG, severity: :refactor)
44
+ end
43
45
  end
44
- end
45
46
 
46
- def autocorrect(node)
47
- lambda do |corrector|
48
- corrector.remove(node.loc.expression)
47
+ def autocorrect(node)
48
+ lambda do |corrector|
49
+ corrector.remove(node.loc.expression)
50
+ end
49
51
  end
50
52
  end
51
53
  end
@@ -17,33 +17,35 @@
17
17
  module RuboCop
18
18
  module Cop
19
19
  module Chef
20
- # ChefSpec 7.1 and later auto generate ChefSpec matchers. Matchers in cookbooks can now be removed.
21
- #
22
- # @example
23
- #
24
- # # bad
25
- # if defined?(ChefSpec)
26
- # def create_yum_repository(resource_name)
27
- # ChefSpec::Matchers::ResourceMatcher.new(:yum_repository, :create, resource_name)
28
- # end
29
- # end
30
- #
31
- class DefinesChefSpecMatchers < Cop
32
- MSG = 'ChefSpec matchers are now auto generated by ChefSpec 7.1+ and do not need to be defined in a cookbook'.freeze
20
+ module ChefModernize
21
+ # ChefSpec 7.1 and later auto generate ChefSpec matchers. Matchers in cookbooks can now be removed.
22
+ #
23
+ # @example
24
+ #
25
+ # # bad
26
+ # if defined?(ChefSpec)
27
+ # def create_yum_repository(resource_name)
28
+ # ChefSpec::Matchers::ResourceMatcher.new(:yum_repository, :create, resource_name)
29
+ # end
30
+ # end
31
+ #
32
+ class DefinesChefSpecMatchers < Cop
33
+ MSG = 'ChefSpec matchers are now auto generated by ChefSpec 7.1+ and do not need to be defined in a cookbook'.freeze
33
34
 
34
- def_node_matcher :chefspec_matcher?, <<-PATTERN
35
- (if ( :defined? (const nil? :ChefSpec)) ... )
36
- PATTERN
35
+ def_node_matcher :chefspec_matcher?, <<-PATTERN
36
+ (if ( :defined? (const nil? :ChefSpec)) ... )
37
+ PATTERN
37
38
 
38
- def on_if(node)
39
- chefspec_matcher?(node) do
40
- add_offense(node, location: :expression, message: MSG, severity: :refactor)
39
+ def on_if(node)
40
+ chefspec_matcher?(node) do
41
+ add_offense(node, location: :expression, message: MSG, severity: :refactor)
42
+ end
41
43
  end
42
- end
43
44
 
44
- def autocorrect(node)
45
- lambda do |corrector|
46
- corrector.remove(node.loc.expression)
45
+ def autocorrect(node)
46
+ lambda do |corrector|
47
+ corrector.remove(node.loc.expression)
48
+ end
47
49
  end
48
50
  end
49
51
  end
@@ -17,25 +17,27 @@
17
17
  module RuboCop
18
18
  module Cop
19
19
  module Chef
20
- # Instead of using the execute resource to to run the `apt-get update` use Chef Infra Client's built-n
21
- # apt_update resource which is available in Chef Infra Client 12.7 and later.
22
- #
23
- # # bad
24
- # execute 'apt-get update'
25
- #
26
- # # good
27
- # apt_update
28
- #
29
- class ExecuteAptUpdate < Cop
30
- MSG = 'Use the apt_update resource instead of the execute resource to run an apt-get update package cache update'.freeze
20
+ module ChefModernize
21
+ # Instead of using the execute resource to to run the `apt-get update` use Chef Infra Client's built-n
22
+ # apt_update resource which is available in Chef Infra Client 12.7 and later.
23
+ #
24
+ # # bad
25
+ # execute 'apt-get update'
26
+ #
27
+ # # good
28
+ # apt_update
29
+ #
30
+ class ExecuteAptUpdate < Cop
31
+ MSG = 'Use the apt_update resource instead of the execute resource to run an apt-get update package cache update'.freeze
31
32
 
32
- def_node_matcher :execute_apt_update?, <<-PATTERN
33
- (send nil? :execute (str "apt-get update"))
34
- PATTERN
33
+ def_node_matcher :execute_apt_update?, <<-PATTERN
34
+ (send nil? :execute (str "apt-get update"))
35
+ PATTERN
35
36
 
36
- def on_send(node)
37
- execute_apt_update?(node) do
38
- add_offense(node, location: :expression, message: MSG, severity: :refactor)
37
+ def on_send(node)
38
+ execute_apt_update?(node) do
39
+ add_offense(node, location: :expression, message: MSG, severity: :refactor)
40
+ end
39
41
  end
40
42
  end
41
43
  end
@@ -18,38 +18,40 @@
18
18
  module RuboCop
19
19
  module Cop
20
20
  module Chef
21
- # There is no need to include Chef::Mixin::ShellOut in resources or providers as this is already done by Chef Infra Client.
22
- #
23
- # @example
24
- #
25
- # # bad
26
- # require 'chef/mixin/shell_out'
27
- # include Chef::Mixin::ShellOut
21
+ module ChefModernize
22
+ # There is no need to include Chef::Mixin::ShellOut in resources or providers as this is already done by Chef Infra Client.
23
+ #
24
+ # @example
25
+ #
26
+ # # bad
27
+ # require 'chef/mixin/shell_out'
28
+ # include Chef::Mixin::ShellOut
28
29
 
29
- class IncludingMixinShelloutInResources < Cop
30
- MSG = 'There is no need to include Chef::Mixin::ShellOut in resources or providers as this is already done by Chef Infra Client.'.freeze
30
+ class IncludingMixinShelloutInResources < Cop
31
+ MSG = 'There is no need to include Chef::Mixin::ShellOut in resources or providers as this is already done by Chef Infra Client.'.freeze
31
32
 
32
- def_node_matcher :include_shellout?, <<-PATTERN
33
- (send nil? :include (const (const (const nil? :Chef) :Mixin) :ShellOut))
34
- PATTERN
33
+ def_node_matcher :include_shellout?, <<-PATTERN
34
+ (send nil? :include (const (const (const nil? :Chef) :Mixin) :ShellOut))
35
+ PATTERN
35
36
 
36
- def_node_matcher :require_shellout?, <<-PATTERN
37
- (send nil? :require ( str "chef/mixin/shell_out"))
38
- PATTERN
37
+ def_node_matcher :require_shellout?, <<-PATTERN
38
+ (send nil? :require ( str "chef/mixin/shell_out"))
39
+ PATTERN
39
40
 
40
- def on_send(node)
41
- require_shellout?(node) do
42
- add_offense(node, location: :expression, message: MSG, severity: :refactor)
43
- end
41
+ def on_send(node)
42
+ require_shellout?(node) do
43
+ add_offense(node, location: :expression, message: MSG, severity: :refactor)
44
+ end
44
45
 
45
- include_shellout?(node) do
46
- add_offense(node, location: :expression, message: MSG, severity: :refactor)
46
+ include_shellout?(node) do
47
+ add_offense(node, location: :expression, message: MSG, severity: :refactor)
48
+ end
47
49
  end
48
- end
49
50
 
50
- def autocorrect(node)
51
- lambda do |corrector|
52
- corrector.remove(node.loc.expression)
51
+ def autocorrect(node)
52
+ lambda do |corrector|
53
+ corrector.remove(node.loc.expression)
54
+ end
53
55
  end
54
56
  end
55
57
  end