cookstyle 6.16.4 → 6.16.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cookstyle/version.rb +1 -1
  3. data/lib/rubocop/cop/chef/correctness/invalid_default_action.rb +1 -0
  4. data/lib/rubocop/cop/chef/correctness/invalid_notification_timing.rb +1 -0
  5. data/lib/rubocop/cop/chef/correctness/invalid_platform_family_helper.rb +1 -0
  6. data/lib/rubocop/cop/chef/correctness/invalid_platform_helper.rb +1 -0
  7. data/lib/rubocop/cop/chef/correctness/invalid_platform_metadata.rb +1 -0
  8. data/lib/rubocop/cop/chef/correctness/invalid_value_for_platform_family_helper.rb +1 -0
  9. data/lib/rubocop/cop/chef/correctness/invalid_value_for_platform_helper.rb +1 -0
  10. data/lib/rubocop/cop/chef/correctness/malformed_value_for_platform.rb +2 -2
  11. data/lib/rubocop/cop/chef/correctness/service_resource.rb +1 -0
  12. data/lib/rubocop/cop/chef/correctness/supports_must_be_float.rb +1 -0
  13. data/lib/rubocop/cop/chef/correctness/tmp_path.rb +1 -0
  14. data/lib/rubocop/cop/chef/deprecation/ use_automatic_resource_name.rb +1 -2
  15. data/lib/rubocop/cop/chef/deprecation/cb_depends_on_self.rb +1 -0
  16. data/lib/rubocop/cop/chef/deprecation/chef_handler_recipe.rb +1 -0
  17. data/lib/rubocop/cop/chef/deprecation/chef_rest.rb +1 -0
  18. data/lib/rubocop/cop/chef/deprecation/chef_rewind.rb +1 -0
  19. data/lib/rubocop/cop/chef/deprecation/depends_compat_resource.rb +2 -1
  20. data/lib/rubocop/cop/chef/deprecation/depends_partial_search.rb +1 -0
  21. data/lib/rubocop/cop/chef/deprecation/depends_poise.rb +1 -0
  22. data/lib/rubocop/cop/chef/deprecation/deprecated_mixins.rb +1 -0
  23. data/lib/rubocop/cop/chef/deprecation/deprecated_shellout_methods.rb +10 -11
  24. data/lib/rubocop/cop/chef/deprecation/deprecated_windows_version_check.rb +2 -1
  25. data/lib/rubocop/cop/chef/deprecation/easy_install.rb +2 -1
  26. data/lib/rubocop/cop/chef/deprecation/eol_audit_mode.rb +1 -0
  27. data/lib/rubocop/cop/chef/deprecation/epic_fail.rb +1 -1
  28. data/lib/rubocop/cop/chef/deprecation/erl_call.rb +2 -1
  29. data/lib/rubocop/cop/chef/deprecation/legacy_notify_syntax.rb +1 -0
  30. data/lib/rubocop/cop/chef/deprecation/legacy_yum_cookbook_recipes.rb +1 -0
  31. data/lib/rubocop/cop/chef/deprecation/name_property_and_default.rb +1 -0
  32. data/lib/rubocop/cop/chef/deprecation/partial_search_helper_usage.rb +2 -1
  33. data/lib/rubocop/cop/chef/deprecation/poise_archive.rb +1 -0
  34. data/lib/rubocop/cop/chef/deprecation/require_recipe.rb +1 -0
  35. data/lib/rubocop/cop/chef/deprecation/resource_overrides_provides_method.rb +2 -3
  36. data/lib/rubocop/cop/chef/deprecation/resource_uses_dsl_name_method.rb +2 -1
  37. data/lib/rubocop/cop/chef/deprecation/resource_uses_only_resource_name.rb +1 -0
  38. data/lib/rubocop/cop/chef/deprecation/resource_uses_provider_base_method.rb +2 -1
  39. data/lib/rubocop/cop/chef/deprecation/ruby_27_keyword_argument_warnings.rb +1 -0
  40. data/lib/rubocop/cop/chef/deprecation/run_command_helper.rb +1 -0
  41. data/lib/rubocop/cop/chef/deprecation/search_uses_positional_parameters.rb +1 -0
  42. data/lib/rubocop/cop/chef/deprecation/use_inline_resources.rb +10 -11
  43. data/lib/rubocop/cop/chef/deprecation/xml_ruby_recipe.rb +1 -0
  44. data/lib/rubocop/cop/chef/deprecation/yum_dnf_compat_recipe.rb +1 -0
  45. data/lib/rubocop/cop/chef/effortless/data_bags.rb +2 -1
  46. data/lib/rubocop/cop/chef/effortless/node_environment.rb +2 -2
  47. data/lib/rubocop/cop/chef/effortless/node_policygroup.rb +2 -2
  48. data/lib/rubocop/cop/chef/effortless/node_roles.rb +2 -2
  49. data/lib/rubocop/cop/chef/effortless/search_for_environments_or_roles.rb +2 -2
  50. data/lib/rubocop/cop/chef/effortless/search_used.rb +2 -1
  51. data/lib/rubocop/cop/chef/modernize/apt_default_recipe.rb +1 -0
  52. data/lib/rubocop/cop/chef/modernize/berksfile_source.rb +1 -0
  53. data/lib/rubocop/cop/chef/modernize/build_essential.rb +1 -0
  54. data/lib/rubocop/cop/chef/modernize/chef_14_resources.rb +1 -0
  55. data/lib/rubocop/cop/chef/modernize/chef_gem_nokogiri.rb +1 -0
  56. data/lib/rubocop/cop/chef/modernize/conditional_using_test.rb +1 -0
  57. data/lib/rubocop/cop/chef/modernize/cron_manage_resource.rb +1 -1
  58. data/lib/rubocop/cop/chef/modernize/depends_zypper_cookbook.rb +1 -0
  59. data/lib/rubocop/cop/chef/modernize/dsl_include_in_resource.rb +1 -0
  60. data/lib/rubocop/cop/chef/modernize/execute_apt_update.rb +1 -0
  61. data/lib/rubocop/cop/chef/modernize/execute_sc_exe.rb +2 -1
  62. data/lib/rubocop/cop/chef/modernize/execute_sleep.rb +2 -1
  63. data/lib/rubocop/cop/chef/modernize/execute_sysctl.rb +2 -1
  64. data/lib/rubocop/cop/chef/modernize/execute_tzutil.rb +1 -0
  65. data/lib/rubocop/cop/chef/modernize/includes_mixin_shellout.rb +1 -0
  66. data/lib/rubocop/cop/chef/modernize/libarchive_file.rb +1 -0
  67. data/lib/rubocop/cop/chef/modernize/macos_user_defaults.rb +1 -1
  68. data/lib/rubocop/cop/chef/modernize/minitest_handler_usage.rb +1 -0
  69. data/lib/rubocop/cop/chef/modernize/ohai_default_recipe.rb +1 -0
  70. data/lib/rubocop/cop/chef/modernize/openssl_rsa_key_resource.rb +1 -1
  71. data/lib/rubocop/cop/chef/modernize/openssl_x509_resource.rb +1 -1
  72. data/lib/rubocop/cop/chef/modernize/osx_config_profile_resource.rb +1 -1
  73. data/lib/rubocop/cop/chef/modernize/property_with_name_attribute.rb +1 -0
  74. data/lib/rubocop/cop/chef/modernize/resource_set_or_return.rb +1 -1
  75. data/lib/rubocop/cop/chef/modernize/resource_with_attributes.rb +1 -0
  76. data/lib/rubocop/cop/chef/modernize/sc_windows_resource.rb +2 -1
  77. data/lib/rubocop/cop/chef/modernize/seven_zip_archive.rb +2 -1
  78. data/lib/rubocop/cop/chef/modernize/{systctl_param_resource.rb → sysctl_param_resource.rb} +1 -1
  79. data/lib/rubocop/cop/chef/modernize/unnecessary_mixlib_shellout_require.rb +1 -0
  80. data/lib/rubocop/cop/chef/modernize/use_require_relative.rb +1 -0
  81. data/lib/rubocop/cop/chef/modernize/windows_default_recipe.rb +1 -0
  82. data/lib/rubocop/cop/chef/modernize/windows_registry_uac.rb +2 -2
  83. data/lib/rubocop/cop/chef/modernize/windows_zipfile.rb +2 -1
  84. data/lib/rubocop/cop/chef/modernize/zipfile_resource.rb +1 -0
  85. data/lib/rubocop/cop/chef/modernize/zypper_repo.rb +1 -1
  86. data/lib/rubocop/cop/chef/redundant/attribute_metadata.rb +1 -1
  87. data/lib/rubocop/cop/chef/redundant/conflicts_metadata.rb +1 -1
  88. data/lib/rubocop/cop/chef/redundant/custom_resource_with_allowed_actions.rb +4 -9
  89. data/lib/rubocop/cop/chef/redundant/grouping_metadata.rb +1 -2
  90. data/lib/rubocop/cop/chef/redundant/long_description_metadata.rb +1 -2
  91. data/lib/rubocop/cop/chef/redundant/property_with_default_and_required.rb +1 -0
  92. data/lib/rubocop/cop/chef/redundant/provides_metadata.rb +1 -2
  93. data/lib/rubocop/cop/chef/redundant/recipe_metadata.rb +1 -2
  94. data/lib/rubocop/cop/chef/redundant/replaces_metadata.rb +1 -2
  95. data/lib/rubocop/cop/chef/redundant/sensitive_property_in_resource.rb +1 -0
  96. data/lib/rubocop/cop/chef/redundant/string_property_with_nil_default.rb +1 -0
  97. data/lib/rubocop/cop/chef/redundant/suggests_metadata.rb +1 -2
  98. data/lib/rubocop/cop/chef/redundant/unnecessary_desired_state.rb +1 -0
  99. data/lib/rubocop/cop/chef/redundant/unnecessary_name_property.rb +1 -0
  100. data/lib/rubocop/cop/chef/sharing/default_maintainer_metadata.rb +1 -0
  101. data/lib/rubocop/cop/chef/sharing/include_property_descriptions.rb +1 -0
  102. data/lib/rubocop/cop/chef/sharing/insecure_cookbook_url.rb +1 -0
  103. data/lib/rubocop/cop/chef/sharing/invalid_license_string.rb +1 -0
  104. data/lib/rubocop/cop/chef/style/file_mode.rb +1 -0
  105. data/lib/rubocop/cop/chef/style/immediate_notification_timing.rb +1 -0
  106. data/lib/rubocop/cop/chef/style/include_recipe_with_parentheses.rb +1 -0
  107. data/lib/rubocop/cop/chef/style/true_false_resource_properties.rb +2 -0
  108. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c12050a348d700990dba93b33e7e15d0151ff5f2fef01aed90bb4f8014a6c04b
4
- data.tar.gz: 62577299c8994813248be5f8c73e27680fd9907d7c2088656e0cb03f035f5932
3
+ metadata.gz: 478785b2c4e9672c7a684b3612420b4cff2191d7711238f9daa45e2b0a8b02d8
4
+ data.tar.gz: 6d2af42693cfa0f26cba72cdd6d0dc05ef5c1069f3573a22a0b4a2441564529d
5
5
  SHA512:
6
- metadata.gz: df19582100f6907be3fdb9d2fcd5f583c674b57538abce8d69d98e4112dab6232e65e3e298347479698a32dace5c41d6f99e6bd1ca83e48955c75f41ec982624
7
- data.tar.gz: 0ed13875d921f88edeb14a476b7bbd71342136e6d4f7a1b9ca83a17953951e949aa38ffc85e8792a4a48ecb774d3ad8387d4fe5aa48c757c0723830c06cb272c
6
+ metadata.gz: 7870c3d596adc50c7f6c6fd377513629ec373cb56b972115bb31887dbd38122730f0461fa03e86ae73598a3385d95413a760ece7128325e568f3b423afba2dd0
7
+ data.tar.gz: bbae89086e0358c8fcbc6e6eaabfe4f581954334be3983039720a025729750ef2acb1c772df5e00441fc1d0bc4f59a84217a4ea51dc758e5f46e02d1dac7bd9d
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  module Cookstyle
3
- VERSION = "6.16.4" # rubocop: disable Style/StringLiterals
3
+ VERSION = "6.16.7" # rubocop: disable Style/StringLiterals
4
4
  RUBOCOP_VERSION = '0.90.0'
5
5
  end
@@ -32,6 +32,7 @@ module RuboCop
32
32
  module ChefCorrectness
33
33
  class InvalidDefaultAction < Base
34
34
  MSG = 'Default actions in resources should be symbols or an array of symbols.'
35
+ RESTRICT_ON_SEND = [:default_action].freeze
35
36
 
36
37
  def_node_matcher :default_action?, '(send nil? :default_action $_)'
37
38
 
@@ -37,6 +37,7 @@ module RuboCop
37
37
  #
38
38
  class InvalidNotificationTiming < Base
39
39
  MSG = 'Valid notification timings are :immediately, :immediate (alias for :immediately), :delayed, and :before.'
40
+ RESTRICT_ON_SEND = [:notifies, :subscribes].freeze
40
41
 
41
42
  def_node_matcher :notification_with_timing?, <<-PATTERN
42
43
  (send nil? {:notifies :subscribes} (sym _) (...) $(sym _))
@@ -37,6 +37,7 @@ module RuboCop
37
37
  extend AutoCorrector
38
38
 
39
39
  MSG = 'Pass valid platform families to the platform_family? helper.'
40
+ RESTRICT_ON_SEND = [:platform_family?].freeze
40
41
 
41
42
  def_node_matcher :platform_family_helper?, <<-PATTERN
42
43
  (send nil? :platform_family? $str*)
@@ -36,6 +36,7 @@ module RuboCop
36
36
  include ::RuboCop::Chef::PlatformHelpers
37
37
 
38
38
  MSG = 'Pass valid platforms to the platform? helper.'
39
+ RESTRICT_ON_SEND = [:platform?].freeze
39
40
 
40
41
  def_node_matcher :platform_helper?, <<-PATTERN
41
42
  (send nil? :platform? $str*)
@@ -37,6 +37,7 @@ module RuboCop
37
37
  include ::RuboCop::Chef::PlatformHelpers
38
38
 
39
39
  MSG = 'metadata.rb "supports" platform is invalid'
40
+ RESTRICT_ON_SEND = [:supports].freeze
40
41
 
41
42
  def_node_matcher :supports?, '(send nil? :supports $str ...)'
42
43
 
@@ -39,6 +39,7 @@ module RuboCop
39
39
  include ::RuboCop::Chef::PlatformHelpers
40
40
 
41
41
  MSG = 'Pass valid platform families to the value_for_platform_family helper.'
42
+ RESTRICT_ON_SEND = [:value_for_platform_family].freeze
42
43
 
43
44
  def_node_matcher :value_for_platform_family?, <<-PATTERN
44
45
  (send nil? :value_for_platform_family
@@ -38,6 +38,7 @@ module RuboCop
38
38
  include ::RuboCop::Chef::PlatformHelpers
39
39
 
40
40
  MSG = 'Pass valid platforms to the value_for_platform helper.'
41
+ RESTRICT_ON_SEND = [:value_for_platform].freeze
41
42
 
42
43
  def_node_matcher :value_for_platform?, <<-PATTERN
43
44
  (send nil? :value_for_platform
@@ -45,9 +45,9 @@ module RuboCop
45
45
  # )
46
46
  #
47
47
  class MalformedPlatformValueForPlatformHelper < Base
48
- def on_send(node)
49
- return unless node.method_name == :value_for_platform
48
+ RESTRICT_ON_SEND = [:value_for_platform].freeze
50
49
 
50
+ def on_send(node)
51
51
  if node.arguments.count > 1
52
52
  msg = 'Malformed value_for_platform helper argument. The value_for_platform helper takes a single hash of platforms as an argument.'
53
53
  add_offense(node, message: msg, severity: :refactor)
@@ -29,6 +29,7 @@ module RuboCop
29
29
  #
30
30
  class ServiceResource < Base
31
31
  MSG = 'Use a service resource to start and stop services'
32
+ RESTRICT_ON_SEND = [:command].freeze
32
33
 
33
34
  def_node_matcher :execute_command?, <<-PATTERN
34
35
  (send nil? :command $str)
@@ -34,6 +34,7 @@ module RuboCop
34
34
  extend RuboCop::Cop::AutoCorrector
35
35
 
36
36
  MSG = 'Versions used in metadata.rb supports calls should be floats not integers.'
37
+ RESTRICT_ON_SEND = [:supports].freeze
37
38
 
38
39
  def_node_matcher :supports_with_constraint?, '(send nil? :supports str $str)'
39
40
 
@@ -32,6 +32,7 @@ module RuboCop
32
32
  #
33
33
  class TmpPath < Base
34
34
  MSG = 'Use file_cache_path rather than hard-coding tmp paths'
35
+ RESTRICT_ON_SEND = [:remote_file].freeze
35
36
 
36
37
  def_node_matcher :remote_file?, <<-PATTERN
37
38
  (send nil? :remote_file $str)
@@ -37,10 +37,9 @@ module RuboCop
37
37
  include RangeHelp
38
38
 
39
39
  MSG = 'The use_automatic_resource_name method was removed in Chef Infra Client 16. The resource name/provides should be set explicitly instead.'
40
+ RESTRICT_ON_SEND = [:use_automatic_resource_name].freeze
40
41
 
41
42
  def on_send(node)
42
- return unless node.method_name == :use_automatic_resource_name
43
-
44
43
  add_offense(node.loc.selector, message: MSG, severity: :warning) do |corrector|
45
44
  corrector.remove(range_with_surrounding_space(range: node.loc.expression, side: :left))
46
45
  end
@@ -36,6 +36,7 @@ module RuboCop
36
36
  include RangeHelp
37
37
 
38
38
  MSG = 'A cookbook cannot depend on itself. This will fail on Chef Infra Client 13+'
39
+ RESTRICT_ON_SEND = [:name].freeze
39
40
 
40
41
  def_node_search :dependencies, '(send nil? :depends str ...)'
41
42
  def_node_matcher :cb_name?, '(send nil? :name str ...)'
@@ -33,6 +33,7 @@ module RuboCop
33
33
  extend AutoCorrector
34
34
 
35
35
  MSG = 'There is no need to include the empty and deprecated chef_handler::default recipe in order to use the chef_handler resource'
36
+ RESTRICT_ON_SEND = [:include_recipe].freeze
36
37
 
37
38
  def_node_matcher :chef_handler_recipe?, <<-PATTERN
38
39
  (send nil? :include_recipe (str {"chef_handler" "chef_handler::default"}))
@@ -30,6 +30,7 @@ module RuboCop
30
30
  #
31
31
  class UsesChefRESTHelpers < Base
32
32
  MSG = "Don't use the helpers in Chef::REST which were removed in Chef Infra Client 13"
33
+ RESTRICT_ON_SEND = [:require].freeze
33
34
 
34
35
  def_node_matcher :require_rest?, <<-PATTERN
35
36
  (send nil? :require ( str "chef/rest"))
@@ -49,6 +49,7 @@ module RuboCop
49
49
  }.freeze
50
50
 
51
51
  MSG = 'Use delete_resource / edit_resource introduced in Chef Infra Client 12.10 instead of functionality in the deprecated chef-rewind gem'
52
+ RESTRICT_ON_SEND = [:chef_gem, :require, :rewind, :unwind].freeze
52
53
 
53
54
  def_node_matcher :rewind_gem_install?, <<-PATTERN
54
55
  (send nil? :chef_gem (str "chef-rewind"))
@@ -29,16 +29,17 @@ module RuboCop
29
29
  class CookbookDependsOnCompatResource < Base
30
30
  include RangeHelp
31
31
  extend TargetChefVersion
32
+ extend AutoCorrector
32
33
 
33
34
  minimum_target_chef_version '12.19'
34
35
 
35
36
  MSG = "Don't depend on the deprecated compat_resource cookbook made obsolete by Chef 12.19+"
37
+ RESTRICT_ON_SEND = [:depends].freeze
36
38
 
37
39
  def_node_matcher :depends_compat_resource?, <<-PATTERN
38
40
  (send nil? :depends (str {"compat_resource"}))
39
41
  PATTERN
40
42
 
41
- extend AutoCorrector
42
43
  def on_send(node)
43
44
  depends_compat_resource?(node) do
44
45
  add_offense(node, message: MSG, severity: :warning) do |corrector|
@@ -32,6 +32,7 @@ module RuboCop
32
32
  minimum_target_chef_version '13.0'
33
33
 
34
34
  MSG = "Don't depend on the deprecated partial_search cookbook made obsolete by Chef 13"
35
+ RESTRICT_ON_SEND = [:depends].freeze
35
36
 
36
37
  def_node_matcher :depends_partial_search?, <<-PATTERN
37
38
  (send nil? :depends (str "partial_search"))
@@ -29,6 +29,7 @@ module RuboCop
29
29
  #
30
30
  class CookbookDependsOnPoise < Base
31
31
  MSG = 'Cookbooks should not depend on the deprecated Poise framework'
32
+ RESTRICT_ON_SEND = [:depends].freeze
32
33
 
33
34
  def_node_matcher :depends_method?, <<-PATTERN
34
35
  (send nil? :depends $str)
@@ -39,6 +39,7 @@ module RuboCop
39
39
  extend AutoCorrector
40
40
 
41
41
  MSG = "Don't use deprecated Mixins no longer included in Chef Infra Client 14 and later."
42
+ RESTRICT_ON_SEND = [:include, :require].freeze
42
43
 
43
44
  def_node_matcher :deprecated_mixin?, <<-PATTERN
44
45
  (send nil? :include (const (const (const nil? :Chef) :Mixin) { :Language :LanguageIncludeAttribute :RecipeDefinitionDSLCore :LanguageIncludeRecipe }))
@@ -44,20 +44,19 @@ module RuboCop
44
44
 
45
45
  minimum_target_chef_version '14.3'
46
46
 
47
- DEPRECATED_SHELLOUT_METHODS = %i( shell_out_compact
48
- shell_out_compact!
49
- shell_out_compact_timeout
50
- shell_out_compact_timeout!
51
- shell_out_with_timeout
52
- shell_out_with_timeout!
53
- shell_out_with_systems_locale
54
- shell_out_with_systems_locale!
55
- ).freeze
56
-
57
47
  MSG = 'Many legacy specialized shell_out methods were replaced in Chef Infra Client 14.3 and removed in Chef Infra Client 15. Use shell_out and any additional options if necessary.'
48
+ RESTRICT_ON_SEND = %i( shell_out_compact
49
+ shell_out_compact!
50
+ shell_out_compact_timeout
51
+ shell_out_compact_timeout!
52
+ shell_out_with_timeout
53
+ shell_out_with_timeout!
54
+ shell_out_with_systems_locale
55
+ shell_out_with_systems_locale!
56
+ ).freeze
58
57
 
59
58
  def on_send(node)
60
- add_offense(node, message: MSG, severity: :warning) if DEPRECATED_SHELLOUT_METHODS.include?(node.method_name)
59
+ add_offense(node, message: MSG, severity: :warning)
61
60
  end
62
61
  end
63
62
  end
@@ -30,9 +30,10 @@ module RuboCop
30
30
  #
31
31
  class DeprecatedWindowsVersionCheck < Base
32
32
  MSG = "Don't use the deprecated older_than_win_2012_or_8? helper. Windows versions before 2012 and 8 are now end of life and this helper will always return false."
33
+ RESTRICT_ON_SEND = [:older_than_win_2012_or_8?].freeze
33
34
 
34
35
  def on_send(node)
35
- add_offense(node, message: MSG, severity: :warning) if node.method_name == :older_than_win_2012_or_8?
36
+ add_offense(node, message: MSG, severity: :warning)
36
37
  end
37
38
  end
38
39
  end
@@ -31,9 +31,10 @@ module RuboCop
31
31
  #
32
32
  class EasyInstallResource < Base
33
33
  MSG = "Don't use the deprecated easy_install resource removed in Chef Infra Client 13"
34
+ RESTRICT_ON_SEND = [:easy_install].freeze
34
35
 
35
36
  def on_send(node)
36
- add_offense(node, message: MSG, severity: :warning) if node.method_name == :easy_install
37
+ add_offense(node, message: MSG, severity: :warning)
37
38
  end
38
39
  end
39
40
  end
@@ -34,6 +34,7 @@ module RuboCop
34
34
 
35
35
  class EOLAuditModeUsage < Base
36
36
  MSG = 'The beta Audit Mode feature in Chef Infra Client was removed in Chef Infra Client 15.0. Users should instead use InSpec and the audit cookbook. See https://www.inspec.io/ for more information.'
37
+ RESTRICT_ON_SEND = [:control_group].freeze
37
38
 
38
39
  def_node_matcher :control_group?, '(send nil? :control_group ...)'
39
40
 
@@ -38,9 +38,9 @@ module RuboCop
38
38
  extend AutoCorrector
39
39
 
40
40
  MSG = 'Use ignore_failure method instead of the deprecated epic_fail method'
41
+ RESTRICT_ON_SEND = [:epic_fail].freeze
41
42
 
42
43
  def on_send(node)
43
- return unless node.method_name == :epic_fail
44
44
  add_offense(node, message: MSG, severity: :warning) do |corrector|
45
45
  corrector.replace(node.loc.expression, 'ignore_failure true')
46
46
  end
@@ -31,9 +31,10 @@ module RuboCop
31
31
  #
32
32
  class ErlCallResource < Base
33
33
  MSG = "Don't use the deprecated erl_call resource removed in Chef Infra Client 13"
34
+ RESTRICT_ON_SEND = [:erl_call].freeze
34
35
 
35
36
  def on_send(node)
36
- add_offense(node, message: MSG, severity: :warning) if node.method_name == :erl_call
37
+ add_offense(node, message: MSG, severity: :warning)
37
38
  end
38
39
  end
39
40
  end
@@ -61,6 +61,7 @@ module RuboCop
61
61
  extend AutoCorrector
62
62
 
63
63
  MSG = 'Use the new-style notification syntax which allows you to notify resources defined later in a recipe or resource.'
64
+ RESTRICT_ON_SEND = [:notifies, :subscribes].freeze
64
65
 
65
66
  def_node_matcher :legacy_notify?, <<-PATTERN
66
67
  (send nil? ${:notifies :subscribes} $(sym _) (send nil? :resources (hash (pair $(sym _) $(...) ) ) ) $... )
@@ -35,6 +35,7 @@ module RuboCop
35
35
  #
36
36
  class LegacyYumCookbookRecipes < Base
37
37
  MSG = 'The elrepo, epel, ius, remi, and repoforge recipes were split into their own cookbooks and the yum recipe was renamed to be default with the release of yum cookbook 3.0 (Dec 2013).'
38
+ RESTRICT_ON_SEND = [:include_recipe].freeze
38
39
 
39
40
  def_node_matcher :old_yum_recipe?, <<-PATTERN
40
41
  (send nil? :include_recipe (str {"yum::elrepo" "yum::epel" "yum::ius" "yum::remi" "yum::repoforge" "yum::yum"}))
@@ -36,6 +36,7 @@ module RuboCop
36
36
  extend AutoCorrector
37
37
 
38
38
  MSG = "A resource property can't be marked as a name_property and also have a default value. This will fail in Chef Infra Client 13 or later."
39
+ RESTRICT_ON_SEND = [:attribute, :property].freeze
39
40
 
40
41
  # match on a property or attribute that has any name and any type and a hash that
41
42
  # contains name_property/name_attribute true and any default value. These are wrapped in
@@ -49,9 +49,10 @@ module RuboCop
49
49
  #
50
50
  class PartialSearchHelperUsage < Base
51
51
  MSG = 'Legacy partial_search usage should be updated to use :filter_result in the search helper instead'
52
+ RESTRICT_ON_SEND = [:partial_search].freeze
52
53
 
53
54
  def on_send(node)
54
- add_offense(node, message: MSG, severity: :warning) if node.method_name == :partial_search
55
+ add_offense(node, message: MSG, severity: :warning)
55
56
  end
56
57
  end
57
58
  end
@@ -39,6 +39,7 @@ module RuboCop
39
39
  minimum_target_chef_version '15.0'
40
40
 
41
41
  MSG = 'The poise_archive resource in the deprecated poise-archive should be replaced with the archive_file resource found in Chef Infra Client 15+'
42
+ RESTRICT_ON_SEND = [:depends].freeze
42
43
 
43
44
  def_node_matcher :depends_poise_archive?, <<-PATTERN
44
45
  (send nil? :depends (str "poise-archive"))
@@ -34,6 +34,7 @@ module RuboCop
34
34
  extend AutoCorrector
35
35
 
36
36
  MSG = 'Use include_recipe instead of the require_recipe method'
37
+ RESTRICT_ON_SEND = [:require_recipe].freeze
37
38
 
38
39
  def_node_matcher :require_recipe?, <<-PATTERN
39
40
  (send nil? :require_recipe $str)
@@ -33,13 +33,12 @@ module RuboCop
33
33
  #
34
34
  class ResourceOverridesProvidesMethod < Base
35
35
  MSG = "Don't override the provides? method in a resource provider. Use provides :SOME_PROVIDER_NAME instead. This will cause failures in Chef Infra Client 13 and later."
36
+ RESTRICT_ON_SEND = [:provides?].freeze
36
37
 
37
38
  def_node_search :provides, '(send nil? :provides ...)'
38
39
 
39
40
  def on_def(node)
40
- if node.method_name == :provides?
41
- add_offense(node, message: MSG, severity: :warning) if provides(processed_source.ast).count == 0
42
- end
41
+ add_offense(node, message: MSG, severity: :warning) if provides(processed_source.ast).count == 0
43
42
  end
44
43
  end
45
44
  end
@@ -31,9 +31,10 @@ module RuboCop
31
31
  #
32
32
  class ResourceUsesDslNameMethod < Base
33
33
  MSG = 'Use resource_name instead of the dsl_name method in resources. This will cause failures in Chef Infra Client 13 and later.'
34
+ RESTRICT_ON_SEND = [:dsl_name].freeze
34
35
 
35
36
  def on_send(node)
36
- add_offense(node, message: MSG, severity: :warning) if node.method_name == :dsl_name
37
+ add_offense(node, message: MSG, severity: :warning)
37
38
  end
38
39
 
39
40
  # potential autocorrect is new_resource.updated_by_last_action true, but we need to actually see what class we were called from
@@ -33,6 +33,7 @@ module RuboCop
33
33
  extend AutoCorrector
34
34
 
35
35
  MSG = 'Starting with Chef Infra Client 16, using `resource_name` without also using `provides` will result in resource failures. Make sure to use both `resource_name` and `provides` to change the name of the resource. You can also omit `resource_name` entirely if the value set matches the name Chef Infra Client automatically assigns based on COOKBOOKNAME_FILENAME.'
36
+ RESTRICT_ON_SEND = [:resource_name].freeze
36
37
 
37
38
  def_node_matcher :resource_name?, '(send nil? :resource_name (sym $_ ))'
38
39
 
@@ -28,9 +28,10 @@ module RuboCop
28
28
  #
29
29
  class ResourceUsesProviderBaseMethod < Base
30
30
  MSG = "Don't use the deprecated provider_base method in a resource to specify the provider module to use. Instead, the provider should call provides to register itself, or the resource should call provider to specify the provider to use. This will cause failures in Chef Infra Client 13 and later."
31
+ RESTRICT_ON_SEND = [:provider_base].freeze
31
32
 
32
33
  def on_send(node)
33
- add_offense(node, message: MSG, severity: :warning) if node.method_name == :provider_base
34
+ add_offense(node, message: MSG, severity: :warning)
34
35
  end
35
36
  end
36
37
  end
@@ -36,6 +36,7 @@ module RuboCop
36
36
  extend RuboCop::Cop::AutoCorrector
37
37
 
38
38
  MSG = 'Pass options to shell_out helpers without the brackets to avoid Ruby 2.7 deprecation warnings.'
39
+ RESTRICT_ON_SEND = [:shell_out!, :shell_out].freeze
39
40
 
40
41
  def_node_matcher :positional_shellout?, <<-PATTERN
41
42
  (send nil? {:shell_out :shell_out!} ... $(hash ... ))
@@ -35,6 +35,7 @@ module RuboCop
35
35
  #
36
36
  class UsesRunCommandHelper < Base
37
37
  MSG = "Use 'shell_out!' instead of the legacy 'run_command' or 'run_command_with_systems_locale' helpers for shelling out. The run_command helper was removed in Chef Infra Client 13."
38
+ RESTRICT_ON_SEND = [:require, :run_command, :run_command_with_systems_locale, :include].freeze
38
39
 
39
40
  def_node_matcher :calls_run_command?, '(send nil? {:run_command :run_command_with_systems_locale} ...)'
40
41
  def_node_matcher :require_mixin_command?, '(send nil? :require (str "chef/mixin/command"))'
@@ -39,6 +39,7 @@ module RuboCop
39
39
  extend AutoCorrector
40
40
 
41
41
  MSG = "Don't use deprecated positional parameters in cookbook search queries."
42
+ RESTRICT_ON_SEND = [:search].freeze
42
43
 
43
44
  NAMED_PARAM_LOOKUP_TABLE = [nil, nil, 'start', 'rows', 'filter_result'].freeze
44
45
 
@@ -34,21 +34,20 @@ module RuboCop
34
34
  extend AutoCorrector
35
35
 
36
36
  MSG = 'use_inline_resources is now the default for resources in Chef Infra Client 13+ and does not need to be specified.'
37
+ RESTRICT_ON_SEND = [:use_inline_resources].freeze
37
38
 
38
39
  def on_send(node)
39
- if node.method_name == :use_inline_resources
40
- # don't alert on the use_inline_resources within the defined? check
41
- # that would result in 2 alerts on the same line and wouldn't be useful
42
- return if node.parent && node.parent.defined_type?
40
+ # don't alert on the use_inline_resources within the defined? check
41
+ # that would result in 2 alerts on the same line and wouldn't be useful
42
+ return if node.parent && node.parent.defined_type?
43
43
 
44
- # catch the full offense if the method is gated like this: use_inline_resources if defined?(use_inline_resources)
45
- if node.parent && node.parent.if_type? && %i(defined? respond_to?).include?(node.parent.children.first.method_name)
46
- node = node.parent
47
- end
44
+ # catch the full offense if the method is gated like this: use_inline_resources if defined?(use_inline_resources)
45
+ if node.parent && node.parent.if_type? && %i(defined? respond_to?).include?(node.parent.children.first.method_name)
46
+ node = node.parent
47
+ end
48
48
 
49
- add_offense(node, message: MSG, severity: :warning) do |corrector|
50
- corrector.remove(range_with_surrounding_space(range: node.loc.expression, side: :left))
51
- end
49
+ add_offense(node, message: MSG, severity: :warning) do |corrector|
50
+ corrector.remove(range_with_surrounding_space(range: node.loc.expression, side: :left))
52
51
  end
53
52
  end
54
53
  end