cookstyle 5.4.13 → 5.5.7

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -18,30 +18,32 @@
18
18
  module RuboCop
19
19
  module Cop
20
20
  module Chef
21
- # Make sure ignore_failure is used instead of epic_fail
22
- #
23
- # @example
24
- #
25
- # # bad
26
- # package "foo" do
27
- # epic_fail true
28
- # end
29
- #
30
- # # good
31
- # package "foo" do
32
- # ignore_failure true
33
- # end
34
- #
35
- class EpicFail < Cop
36
- MSG = 'Use ignore_failure method instead of the deprecated epic_fail method'.freeze
21
+ module ChefDeprecations
22
+ # Make sure ignore_failure is used instead of epic_fail
23
+ #
24
+ # @example
25
+ #
26
+ # # bad
27
+ # package "foo" do
28
+ # epic_fail true
29
+ # end
30
+ #
31
+ # # good
32
+ # package "foo" do
33
+ # ignore_failure true
34
+ # end
35
+ #
36
+ class EpicFail < Cop
37
+ MSG = 'Use ignore_failure method instead of the deprecated epic_fail method'.freeze
37
38
 
38
- def on_send(node)
39
- add_offense(node, location: :expression, message: MSG, severity: :refactor) if node.method_name == :epic_fail
40
- end
39
+ def on_send(node)
40
+ add_offense(node, location: :expression, message: MSG, severity: :refactor) if node.method_name == :epic_fail
41
+ end
41
42
 
42
- def autocorrect(node)
43
- lambda do |corrector|
44
- corrector.replace(node.loc.expression, 'ignore_failure true')
43
+ def autocorrect(node)
44
+ lambda do |corrector|
45
+ corrector.replace(node.loc.expression, 'ignore_failure true')
46
+ end
45
47
  end
46
48
  end
47
49
  end
@@ -18,20 +18,22 @@
18
18
  module RuboCop
19
19
  module Cop
20
20
  module Chef
21
- # Don't use the deprecated erl_call resource
22
- #
23
- # @example
24
- #
25
- # # bad
26
- # erl_call "foo" do
27
- # bar
28
- # end
29
- #
30
- class ErlCallResource < Cop
31
- MSG = "Don't use the deprecated erl_call resource removed in Chef 13".freeze
21
+ module ChefDeprecations
22
+ # Don't use the deprecated erl_call resource
23
+ #
24
+ # @example
25
+ #
26
+ # # bad
27
+ # erl_call "foo" do
28
+ # bar
29
+ # end
30
+ #
31
+ class ErlCallResource < Cop
32
+ MSG = "Don't use the deprecated erl_call resource removed in Chef 13".freeze
32
33
 
33
- def on_send(node)
34
- add_offense(node, location: :expression, message: MSG, severity: :refactor) if node.method_name == :erl_call
34
+ def on_send(node)
35
+ add_offense(node, location: :expression, message: MSG, severity: :refactor) if node.method_name == :erl_call
36
+ end
35
37
  end
36
38
  end
37
39
  end
@@ -0,0 +1,55 @@
1
+ #
2
+ # Copyright:: 2019, Chef Software, Inc.
3
+ # Author:: Tim Smith (<tsmith@chef.io>)
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+ module RuboCop
18
+ module Cop
19
+ module Chef
20
+ module ChefDeprecations
21
+ # The launchd resource's hash property was renamed to plist_hash in Chef Infra Client 13+ to avoid conflicts with Ruby's hash class.
22
+ #
23
+ # @example
24
+ #
25
+ # # bad
26
+ # launchd 'foo' do
27
+ # hash foo: 'bar'
28
+ # end
29
+ #
30
+ # # good
31
+ # launchd 'foo' do
32
+ # plist_hash foo: 'bar'
33
+ # end
34
+ #
35
+ class LaunchdDeprecatedHashProperty < Cop
36
+ include RuboCop::Chef::CookbookHelpers
37
+
38
+ MSG = "The launchd resource's hash property was renamed to plist_hash in Chef Infra Client 13+ to avoid conflicts with Ruby's hash class.".freeze
39
+
40
+ def on_block(node)
41
+ match_property_in_resource?(:launchd, 'hash', node) do |hash_prop|
42
+ add_offense(hash_prop, location: :expression, message: MSG, severity: :refactor)
43
+ end
44
+ end
45
+
46
+ def autocorrect(node)
47
+ lambda do |corrector|
48
+ corrector.replace(node.loc.expression, node.loc.expression.source.gsub(/^hash/, 'plist_hash'))
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -17,30 +17,32 @@
17
17
  module RuboCop
18
18
  module Cop
19
19
  module Chef
20
- # The Ohai default recipe previously allowed a user to ship custom Ohai plugins to a system by including them
21
- # in a directory in the Ohai cookbook. This functionality was replaced with the ohai_plugin resource, which
22
- # should be used instead as it doesn't require forking the ohai cookbook.
23
- #
24
- # @example
25
- #
26
- # # bad
27
- # include_recipe 'yum::elrepo'
28
- # include_recipe 'yum::epel'
29
- # include_recipe 'yum::ius'
30
- # include_recipe 'yum::remi'
31
- # include_recipe 'yum::repoforge'
32
- # include_recipe 'yum::yum'
33
- #
34
- class LegacyYumCookbookRecipes < Cop
35
- 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).'.freeze
20
+ module ChefDeprecations
21
+ # The Ohai default recipe previously allowed a user to ship custom Ohai plugins to a system by including them
22
+ # in a directory in the Ohai cookbook. This functionality was replaced with the ohai_plugin resource, which
23
+ # should be used instead as it doesn't require forking the ohai cookbook.
24
+ #
25
+ # @example
26
+ #
27
+ # # bad
28
+ # include_recipe 'yum::elrepo'
29
+ # include_recipe 'yum::epel'
30
+ # include_recipe 'yum::ius'
31
+ # include_recipe 'yum::remi'
32
+ # include_recipe 'yum::repoforge'
33
+ # include_recipe 'yum::yum'
34
+ #
35
+ class LegacyYumCookbookRecipes < Cop
36
+ 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).'.freeze
36
37
 
37
- def_node_matcher :old_yum_recipe?, <<-PATTERN
38
- (send nil? :include_recipe (str {"yum::elrepo" "yum::epel" "yum::ius" "yum::remi" "yum::repoforge" "yum::yum"}))
39
- PATTERN
38
+ def_node_matcher :old_yum_recipe?, <<-PATTERN
39
+ (send nil? :include_recipe (str {"yum::elrepo" "yum::epel" "yum::ius" "yum::remi" "yum::repoforge" "yum::yum"}))
40
+ PATTERN
40
41
 
41
- def on_send(node)
42
- old_yum_recipe?(node) do
43
- add_offense(node, location: :expression, message: MSG, severity: :refactor)
42
+ def on_send(node)
43
+ old_yum_recipe?(node) do
44
+ add_offense(node, location: :expression, message: MSG, severity: :refactor)
45
+ end
44
46
  end
45
47
  end
46
48
  end
@@ -0,0 +1,45 @@
1
+ #
2
+ # Copyright:: 2019, Chef Software, Inc.
3
+ # Author:: Tim Smith (<tsmith@chef.io>)
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+ module RuboCop
18
+ module Cop
19
+ module Chef
20
+ module ChefDeprecations
21
+ # The local resource's lc_all property has been deprecated and will be removed in Chef Infra Client 16
22
+ #
23
+ # @example
24
+ #
25
+ # # bad
26
+ # locale 'set locale' do
27
+ # lang 'en_gb.utf-8'
28
+ # lc_all 'en_gb.utf-8'
29
+ # end
30
+ #
31
+ class LocaleDeprecatedLcAllProperty < Cop
32
+ include RuboCop::Chef::CookbookHelpers
33
+
34
+ MSG = "The local resource's lc_all property has been deprecated and will be removed in Chef Infra Client 16".freeze
35
+
36
+ def on_block(node)
37
+ match_property_in_resource?(:locale, 'lc_all', node) do |property|
38
+ add_offense(property, location: :expression, message: MSG, severity: :refactor)
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -18,30 +18,32 @@
18
18
  module RuboCop
19
19
  module Cop
20
20
  module Chef
21
- # The long_description metadata.rb method is not used and is unnecessary in cookbooks
22
- #
23
- # @example
24
- #
25
- # # bad
26
- # long_description 'this is my cookbook and this description will never be seen'
27
- #
21
+ module ChefDeprecations
22
+ # The long_description metadata.rb method is not used and is unnecessary in cookbooks
23
+ #
24
+ # @example
25
+ #
26
+ # # bad
27
+ # long_description 'this is my cookbook and this description will never be seen'
28
+ #
28
29
 
29
- class LongDescriptionMetadata < Cop
30
- MSG = 'The long_description metadata.rb method is not used and is unnecessary in cookbooks'.freeze
30
+ class LongDescriptionMetadata < Cop
31
+ MSG = 'The long_description metadata.rb method is not used and is unnecessary in cookbooks'.freeze
31
32
 
32
- def_node_matcher :long_description?, <<-PATTERN
33
- (send nil? :long_description ... )
34
- PATTERN
33
+ def_node_matcher :long_description?, <<-PATTERN
34
+ (send nil? :long_description ... )
35
+ PATTERN
35
36
 
36
- def on_send(node)
37
- long_description?(node) do
38
- add_offense(node, location: :expression, message: MSG, severity: :refactor) if node.method_name == :long_description
37
+ def on_send(node)
38
+ long_description?(node) do
39
+ add_offense(node, location: :expression, message: MSG, severity: :refactor) if node.method_name == :long_description
40
+ end
39
41
  end
40
- end
41
42
 
42
- def autocorrect(node)
43
- lambda do |corrector|
44
- corrector.remove(node.loc.expression)
43
+ def autocorrect(node)
44
+ lambda do |corrector|
45
+ corrector.remove(node.loc.expression)
46
+ end
45
47
  end
46
48
  end
47
49
  end
@@ -17,66 +17,68 @@
17
17
  module RuboCop
18
18
  module Cop
19
19
  module Chef
20
- # Incorrectly using node methods for Ohai data when you really want node attributes
21
- #
22
- # @example
23
- #
24
- # # bad
25
- # node.fqdn
26
- # node.platform
27
- # node.platform_family
28
- # node.platform_version
29
- # node.hostname
30
- #
31
- # # good
32
- # node['fqdn']
33
- # node['platform']
34
- # node['platform_family']
35
- # node['platform_version']
36
- # node['hostname']
37
- #
38
- class NodeMethodsInsteadofAttributes < Cop
39
- MSG = 'Use node attributes to access Ohai data instead of node methods, which were deprecated in Chef Infra Client 13.'.freeze
20
+ module ChefDeprecations
21
+ # Incorrectly using node methods for Ohai data when you really want node attributes
22
+ #
23
+ # @example
24
+ #
25
+ # # bad
26
+ # node.fqdn
27
+ # node.platform
28
+ # node.platform_family
29
+ # node.platform_version
30
+ # node.hostname
31
+ #
32
+ # # good
33
+ # node['fqdn']
34
+ # node['platform']
35
+ # node['platform_family']
36
+ # node['platform_version']
37
+ # node['hostname']
38
+ #
39
+ class NodeMethodsInsteadofAttributes < Cop
40
+ MSG = 'Use node attributes to access Ohai data instead of node methods, which were deprecated in Chef Infra Client 13.'.freeze
40
41
 
41
- def_node_matcher :node_ohai_methods?, <<-PATTERN
42
- (send (send nil? :node) #non_nested_ohai_attribute?)
43
- PATTERN
42
+ def_node_matcher :node_ohai_methods?, <<-PATTERN
43
+ (send (send nil? :node) #non_nested_ohai_attribute?)
44
+ PATTERN
44
45
 
45
- def on_send(node)
46
- node_ohai_methods?(node) do
47
- add_offense(node, location: :selector, message: MSG, severity: :refactor)
46
+ def on_send(node)
47
+ node_ohai_methods?(node) do
48
+ add_offense(node, location: :selector, 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, "node['#{node.method_name}']")
52
+ def autocorrect(node)
53
+ lambda do |corrector|
54
+ corrector.replace(node.loc.expression, "node['#{node.method_name}']")
55
+ end
54
56
  end
55
- end
56
57
 
57
- private
58
+ private
58
59
 
59
- def non_nested_ohai_attribute?(attribute)
60
- %i(
61
- current_user
62
- domain
63
- fqdn
64
- hostname
65
- ip6address
66
- ipaddress
67
- macaddress
68
- machinename
69
- ohai_time
70
- os
71
- os_version
72
- platform
73
- platform_build
74
- platform_family
75
- platform_version
76
- root_group
77
- shard_seed
78
- uptime
79
- uptime_seconds).include?(attribute)
60
+ def non_nested_ohai_attribute?(attribute)
61
+ %i(
62
+ current_user
63
+ domain
64
+ fqdn
65
+ hostname
66
+ ip6address
67
+ ipaddress
68
+ macaddress
69
+ machinename
70
+ ohai_time
71
+ os
72
+ os_version
73
+ platform
74
+ platform_build
75
+ platform_family
76
+ platform_version
77
+ root_group
78
+ shard_seed
79
+ uptime
80
+ uptime_seconds).include?(attribute)
81
+ end
80
82
  end
81
83
  end
82
84
  end
@@ -16,35 +16,37 @@
16
16
  module RuboCop
17
17
  module Cop
18
18
  module Chef
19
- # The node.set method has been removed in Chef-13 and must be replaced by node.normal.
20
- #
21
- # Note that node.normal keeps the semantics identical, but the use of node.normal is
22
- # also discouraged.
23
- #
24
- # @example
25
- #
26
- # # bad
27
- # node.set['foo'] = true
28
- #
29
- # # good
30
- # node.normal['foo'] = true
31
- #
32
- class NodeSet < Cop
33
- MSG = 'Do not use node.set. Replace with node.normal to keep identical behavior.'.freeze
19
+ module ChefDeprecations
20
+ # The node.set method has been removed in Chef-13 and must be replaced by node.normal.
21
+ #
22
+ # Note that node.normal keeps the semantics identical, but the use of node.normal is
23
+ # also discouraged.
24
+ #
25
+ # @example
26
+ #
27
+ # # bad
28
+ # node.set['foo'] = true
29
+ #
30
+ # # good
31
+ # node.normal['foo'] = true
32
+ #
33
+ class NodeSet < Cop
34
+ MSG = 'Do not use node.set. Replace with node.normal to keep identical behavior.'.freeze
34
35
 
35
- def_node_matcher :node_set?, <<-PATTERN
36
- (send (send _ :node) $:set)
37
- PATTERN
36
+ def_node_matcher :node_set?, <<-PATTERN
37
+ (send (send _ :node) $:set)
38
+ PATTERN
38
39
 
39
- def on_send(node)
40
- node_set?(node) do
41
- add_offense(node, location: :selector, message: MSG, severity: :refactor)
40
+ def on_send(node)
41
+ node_set?(node) do
42
+ add_offense(node, location: :selector, message: MSG, severity: :refactor)
43
+ end
42
44
  end
43
- end
44
45
 
45
- def autocorrect(node)
46
- lambda do |corrector|
47
- corrector.replace(node.loc.selector, 'normal')
46
+ def autocorrect(node)
47
+ lambda do |corrector|
48
+ corrector.replace(node.loc.selector, 'normal')
49
+ end
48
50
  end
49
51
  end
50
52
  end