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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cookstyle
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.4.13
4
+ version: 5.5.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thom May
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-08-29 00:00:00.000000000 Z
12
+ date: 2019-09-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -73,6 +73,7 @@ files:
73
73
  - lib/cookstyle.rb
74
74
  - lib/cookstyle/version.rb
75
75
  - lib/rubocop/chef.rb
76
+ - lib/rubocop/chef/cookbook_helpers.rb
76
77
  - lib/rubocop/chef/cookbook_only.rb
77
78
  - lib/rubocop/cop/chef/correctness/block_guard_clause_string_only.rb
78
79
  - lib/rubocop/cop/chef/correctness/cb_depends_on_self.rb
@@ -84,11 +85,18 @@ files:
84
85
  - lib/rubocop/cop/chef/correctness/name_property_and_required.rb
85
86
  - lib/rubocop/cop/chef/correctness/node_normal.rb
86
87
  - lib/rubocop/cop/chef/correctness/node_normal_unless.rb
88
+ - lib/rubocop/cop/chef/correctness/node_save.rb
89
+ - lib/rubocop/cop/chef/correctness/ohai_default_recipe.rb
87
90
  - lib/rubocop/cop/chef/correctness/property_with_default_and_required.rb
88
91
  - lib/rubocop/cop/chef/correctness/property_with_name_attribute.rb
92
+ - lib/rubocop/cop/chef/correctness/resource_sets_internal_properties.rb
93
+ - lib/rubocop/cop/chef/correctness/resource_sets_name_property.rb
94
+ - lib/rubocop/cop/chef/correctness/resource_with_none_action.rb
89
95
  - lib/rubocop/cop/chef/correctness/service_resource.rb
90
96
  - lib/rubocop/cop/chef/correctness/tmp_path.rb
91
97
  - lib/rubocop/cop/chef/deprecation/attribute_metadata.rb
98
+ - lib/rubocop/cop/chef/deprecation/chef_rest.rb
99
+ - lib/rubocop/cop/chef/deprecation/chocolatey_package_uninstall_action.rb
92
100
  - lib/rubocop/cop/chef/deprecation/conflicts_metadata.rb
93
101
  - lib/rubocop/cop/chef/deprecation/depends_compat_resource.rb
94
102
  - lib/rubocop/cop/chef/deprecation/depends_partial_search.rb
@@ -97,7 +105,9 @@ files:
97
105
  - lib/rubocop/cop/chef/deprecation/easy_install.rb
98
106
  - lib/rubocop/cop/chef/deprecation/epic_fail.rb
99
107
  - lib/rubocop/cop/chef/deprecation/erl_call.rb
108
+ - lib/rubocop/cop/chef/deprecation/launchd_deprecated_hash_property.rb
100
109
  - lib/rubocop/cop/chef/deprecation/legacy_yum_cookbook_recipes.rb
110
+ - lib/rubocop/cop/chef/deprecation/locale_lc_all_property.rb
101
111
  - lib/rubocop/cop/chef/deprecation/long_description_metadata.rb
102
112
  - lib/rubocop/cop/chef/deprecation/node_methods_not_attributes.rb
103
113
  - lib/rubocop/cop/chef/deprecation/node_set.rb
@@ -105,10 +115,12 @@ files:
105
115
  - lib/rubocop/cop/chef/deprecation/provides_metadata.rb
106
116
  - lib/rubocop/cop/chef/deprecation/replaces_metadata.rb
107
117
  - lib/rubocop/cop/chef/deprecation/require_recipe.rb
108
- - lib/rubocop/cop/chef/deprecation/respond_to_metadata.rb
109
118
  - lib/rubocop/cop/chef/deprecation/suggests_metadata.rb
119
+ - lib/rubocop/cop/chef/deprecation/use_inline_resources.rb
120
+ - lib/rubocop/cop/chef/deprecation/user_supports_property.rb
121
+ - lib/rubocop/cop/chef/deprecation/xml_ruby_recipe.rb
122
+ - lib/rubocop/cop/chef/deprecation/yum_dnf_compat_recipe.rb
110
123
  - lib/rubocop/cop/chef/effortless/data_bags.rb
111
- - lib/rubocop/cop/chef/effortless/node_save.rb
112
124
  - lib/rubocop/cop/chef/effortless/search_used.rb
113
125
  - lib/rubocop/cop/chef/modernize/apt_default_recipe.rb
114
126
  - lib/rubocop/cop/chef/modernize/berksfile_source.rb
@@ -117,20 +129,23 @@ files:
117
129
  - lib/rubocop/cop/chef/modernize/defines_chefspec_matchers.rb
118
130
  - lib/rubocop/cop/chef/modernize/execute_apt_update.rb
119
131
  - lib/rubocop/cop/chef/modernize/includes_mixin_shellout.rb
132
+ - lib/rubocop/cop/chef/modernize/libarchive_file.rb
120
133
  - lib/rubocop/cop/chef/modernize/minitest_handler_usage.rb
121
- - lib/rubocop/cop/chef/modernize/ohai_default_recipe.rb
134
+ - lib/rubocop/cop/chef/modernize/powershell_expand_archive.rb
135
+ - lib/rubocop/cop/chef/modernize/powershell_install_package.rb
136
+ - lib/rubocop/cop/chef/modernize/powershell_install_windowsfeature.rb
122
137
  - lib/rubocop/cop/chef/modernize/resource_set_or_return.rb
123
- - lib/rubocop/cop/chef/modernize/resource_with_allowed_action.rb
138
+ - lib/rubocop/cop/chef/modernize/resource_with_allowed_actions.rb
124
139
  - lib/rubocop/cop/chef/modernize/resource_with_attributes.rb
140
+ - lib/rubocop/cop/chef/modernize/respond_to_metadata.rb
125
141
  - lib/rubocop/cop/chef/modernize/respond_to_provides.rb
126
142
  - lib/rubocop/cop/chef/modernize/respond_to_resource_name.rb
127
- - lib/rubocop/cop/chef/modernize/use_inline_resources.rb
143
+ - lib/rubocop/cop/chef/modernize/seven_zip_archive.rb
144
+ - lib/rubocop/cop/chef/modernize/shellouts_to_chocolatey.rb
128
145
  - lib/rubocop/cop/chef/modernize/whyrun_supported_true.rb
129
146
  - lib/rubocop/cop/chef/modernize/windows_default_recipe.rb
130
147
  - lib/rubocop/cop/chef/modernize/windows_version_helper.rb
131
148
  - lib/rubocop/cop/chef/modernize/windows_zipfile.rb
132
- - lib/rubocop/cop/chef/modernize/xml_ruby_recipe.rb
133
- - lib/rubocop/cop/chef/modernize/yum_dnf_compat_recipe.rb
134
149
  - lib/rubocop/cop/chef/style/attribute_keys.rb
135
150
  - lib/rubocop/cop/chef/style/comment_sentence_spacing.rb
136
151
  - lib/rubocop/cop/chef/style/comments_copyright_format.rb
@@ -1,53 +0,0 @@
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
- # It is not longer necessary respond_to?(:foo) in metadata. This was used to support new metadata
21
- # methods in Chef 11 and early versions of Chef 12.
22
- #
23
- # @example
24
- #
25
- # # bad
26
- # chef_version '>= 13' if respond_to?(:chef_version)
27
- #
28
- # # good
29
- # chef_version '>= 13'
30
- #
31
-
32
- class RespondToInMetadata < Cop
33
- MSG = 'It is no longer necessary to use respond_to? in metadata.rb in Chef 12.15 and later'.freeze
34
-
35
- def on_if(node)
36
- if_respond_to?(node) do
37
- add_offense(node, location: :expression, message: MSG, severity: :refactor)
38
- end
39
- end
40
-
41
- def_node_matcher :if_respond_to?, <<~PATTERN
42
- (if (send nil? :respond_to? _ ) ... )
43
- PATTERN
44
-
45
- def autocorrect(node)
46
- lambda do |corrector|
47
- corrector.replace(node.loc.expression, node.children[1].source)
48
- end
49
- end
50
- end
51
- end
52
- end
53
- end
@@ -1,45 +0,0 @@
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
- # 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 'ohai::default'
28
- # include_recipe 'ohai'
29
- #
30
- class IncludingOhaiDefaultRecipe < Cop
31
- MSG = "Use the ohai_plugin resource to ship custom Ohai plugins instead of using the ohai::default recipe. If you're not shipping custom Ohai plugins, then you can remove this recipe entirely".freeze
32
-
33
- def_node_matcher :ohai_recipe_usage?, <<-PATTERN
34
- (send nil? :include_recipe (str {"ohai" "ohai::default"}))
35
- PATTERN
36
-
37
- def on_send(node)
38
- ohai_recipe_usage?(node) do
39
- add_offense(node, location: :expression, message: MSG, severity: :refactor)
40
- end
41
- end
42
- end
43
- end
44
- end
45
- end
@@ -1,75 +0,0 @@
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
-
18
- module RuboCop
19
- module Cop
20
- module Chef
21
- # In HWRPs and LWRPs it was necessary to define the allowed actions within the resource.
22
- # In custom resources this is no longer necessary as Chef will determine it based on the
23
- # actions defined in the resource.
24
- #
25
- # @example
26
- #
27
- # # bad
28
- # property :something, String
29
- #
30
- # allowed_actions [:create, :remove]
31
- # action :create do
32
- # # some action code because we're in a custom resource
33
- # end
34
- #
35
- # # also bad
36
- # property :something, String
37
- #
38
- # actions [:create, :remove]
39
- # action :create do
40
- # # some action code because we're in a custom resource
41
- # end
42
- #
43
- # # good
44
- # property :something, String
45
- #
46
- # action :create do
47
- # # some action code because we're in a custom resource
48
- # end
49
- #
50
- class CustomResourceWithAllowedActions < Cop
51
- MSG = "Custom Resources don't need to define the allowed actions with allowed_actions or actions methods".freeze
52
-
53
- def_node_matcher :allowed_actions?, <<-PATTERN
54
- (send nil? {:allowed_actions :actions} ... )
55
- PATTERN
56
-
57
- def_node_search :resource_actions?, <<-PATTERN
58
- (block (send nil? :action ... ) ... )
59
- PATTERN
60
-
61
- def on_send(node)
62
- allowed_actions?(node) do
63
- add_offense(node, location: :expression, message: MSG, severity: :refactor) if resource_actions?(processed_source.ast)
64
- end
65
- end
66
-
67
- def autocorrect(node)
68
- lambda do |corrector|
69
- corrector.remove(node.loc.expression)
70
- end
71
- end
72
- end
73
- end
74
- end
75
- end
@@ -1,54 +0,0 @@
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
- # use_inline_resources became the default in Chef Infra Client 13+ and no longer needs
21
- # to be called in resources
22
- #
23
- # @example
24
- #
25
- # # bad
26
- # use_inline_resources
27
- # use_inline_resources if defined?(use_inline_resources)
28
- #
29
- class UseInlineResourcesDefined < Cop
30
- MSG = 'use_inline_resources is now the default for resources in Chef Infra Client 13+ and does not need to be specified.'.freeze
31
-
32
- def on_send(node)
33
- if node.method_name == :use_inline_resources
34
- # don't alert on the use_inline_resources within the defined? check
35
- # that would result in 2 alerts on the same line and wouldn't be useful
36
- return if node.parent && node.parent.defined_type?
37
-
38
- # catch the full offense if the method is gated like this: use_inline_resources if defined?(use_inline_resources)
39
- if node.parent && node.parent.if_type? && node.parent.children.first.method_name == :defined?
40
- node = node.parent
41
- end
42
- add_offense(node, location: :expression, message: MSG, severity: :refactor)
43
- end
44
- end
45
-
46
- def autocorrect(node)
47
- lambda do |corrector|
48
- corrector.remove(node.loc.expression)
49
- end
50
- end
51
- end
52
- end
53
- end
54
- end
@@ -1,49 +0,0 @@
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
- # The xml::ruby recipe was used to install nokogiri into the Chef installation. Nokogiri is included
21
- # in Chef Infra Client 12 and later so this recipe is no longer necessary.
22
- #
23
- # @example
24
- #
25
- # # bad
26
- # include_recipe 'xml::ruby'
27
- #
28
- class IncludingXMLRubyRecipe < Cop
29
- MSG = 'The xml::ruby recipe installs nokogiri which is included in Chef Infra Client 12 and later.'.freeze
30
-
31
- def_node_matcher :xml_ruby_recipe?, <<-PATTERN
32
- (send nil? :include_recipe (str "xml::ruby"))
33
- PATTERN
34
-
35
- def on_send(node)
36
- xml_ruby_recipe?(node) do
37
- add_offense(node, location: :expression, message: MSG, severity: :refactor)
38
- end
39
- end
40
-
41
- def autocorrect(node)
42
- lambda do |corrector|
43
- corrector.remove(node.loc.expression)
44
- end
45
- end
46
- end
47
- end
48
- end
49
- end
@@ -1,49 +0,0 @@
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
- # Don't include the yum DNF compatibility recipe, which is no longer necessary
21
- # as Chef Infra Client includes DNF package support
22
- #
23
- # @example
24
- #
25
- # # bad
26
- # include_recipe 'yum::dnf_yum_compat'
27
- #
28
- class IncludingYumDNFCompatRecipe < Cop
29
- MSG = 'Do not include the yum::dnf_yum_compat default recipe to install yum on dnf systems. Chef Infra Client now includes built in support for DNF packages.'.freeze
30
-
31
- def_node_matcher :yum_dnf_compat_recipe_usage?, <<-PATTERN
32
- (send nil? :include_recipe (str "yum::dnf_yum_compat"))
33
- PATTERN
34
-
35
- def on_send(node)
36
- yum_dnf_compat_recipe_usage?(node) do
37
- add_offense(node, location: :expression, message: MSG, severity: :refactor)
38
- end
39
- end
40
-
41
- def autocorrect(node)
42
- lambda do |corrector|
43
- corrector.remove(node.loc.expression)
44
- end
45
- end
46
- end
47
- end
48
- end
49
- end