cookstyle 5.4.13 → 5.5.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/cookstyle.yml +231 -129
- data/lib/cookstyle.rb +1 -0
- data/lib/cookstyle/version.rb +1 -1
- data/lib/rubocop/chef/cookbook_helpers.rb +67 -0
- data/lib/rubocop/cop/chef/correctness/block_guard_clause_string_only.rb +34 -31
- data/lib/rubocop/cop/chef/correctness/cb_depends_on_self.rb +16 -14
- data/lib/rubocop/cop/chef/correctness/default_maintainer_metadata.rb +22 -20
- data/lib/rubocop/cop/chef/correctness/insecure_cookbook_url.rb +32 -30
- data/lib/rubocop/cop/chef/correctness/invalid_license_string.rb +454 -453
- data/lib/rubocop/cop/chef/correctness/invalid_platform_metadata.rb +57 -57
- data/lib/rubocop/cop/chef/correctness/metadata_missing_name.rb +18 -16
- data/lib/rubocop/cop/chef/correctness/name_property_and_required.rb +61 -59
- data/lib/rubocop/cop/chef/correctness/node_normal.rb +29 -27
- data/lib/rubocop/cop/chef/correctness/node_normal_unless.rb +29 -27
- data/lib/rubocop/cop/chef/correctness/node_save.rb +46 -0
- data/lib/rubocop/cop/chef/correctness/ohai_default_recipe.rb +47 -0
- data/lib/rubocop/cop/chef/correctness/property_with_default_and_required.rb +35 -33
- data/lib/rubocop/cop/chef/correctness/property_with_name_attribute.rb +29 -27
- data/lib/rubocop/cop/chef/correctness/resource_sets_internal_properties.rb +52 -0
- data/lib/rubocop/cop/chef/correctness/resource_sets_name_property.rb +51 -0
- data/lib/rubocop/cop/chef/correctness/resource_with_none_action.rb +52 -0
- data/lib/rubocop/cop/chef/correctness/service_resource.rb +26 -24
- data/lib/rubocop/cop/chef/correctness/tmp_path.rb +30 -28
- data/lib/rubocop/cop/chef/deprecation/attribute_metadata.rb +22 -21
- data/lib/rubocop/cop/chef/deprecation/chef_rest.rb +56 -0
- data/lib/rubocop/cop/chef/deprecation/chocolatey_package_uninstall_action.rb +58 -0
- data/lib/rubocop/cop/chef/deprecation/conflicts_metadata.rb +18 -16
- data/lib/rubocop/cop/chef/deprecation/depends_compat_resource.rb +21 -19
- data/lib/rubocop/cop/chef/deprecation/depends_partial_search.rb +17 -15
- data/lib/rubocop/cop/chef/deprecation/depends_poise.rb +17 -15
- data/lib/rubocop/cop/chef/deprecation/deprecated_mixins.rb +39 -37
- data/lib/rubocop/cop/chef/deprecation/easy_install.rb +15 -13
- data/lib/rubocop/cop/chef/deprecation/epic_fail.rb +24 -22
- data/lib/rubocop/cop/chef/deprecation/erl_call.rb +15 -13
- data/lib/rubocop/cop/chef/deprecation/launchd_deprecated_hash_property.rb +55 -0
- data/lib/rubocop/cop/chef/deprecation/legacy_yum_cookbook_recipes.rb +24 -22
- data/lib/rubocop/cop/chef/deprecation/locale_lc_all_property.rb +45 -0
- data/lib/rubocop/cop/chef/deprecation/long_description_metadata.rb +21 -19
- data/lib/rubocop/cop/chef/deprecation/node_methods_not_attributes.rb +55 -53
- data/lib/rubocop/cop/chef/deprecation/node_set.rb +27 -25
- data/lib/rubocop/cop/chef/deprecation/node_set_unless.rb +27 -25
- data/lib/rubocop/cop/chef/deprecation/provides_metadata.rb +18 -16
- data/lib/rubocop/cop/chef/deprecation/replaces_metadata.rb +18 -16
- data/lib/rubocop/cop/chef/deprecation/require_recipe.rb +23 -21
- data/lib/rubocop/cop/chef/deprecation/suggests_metadata.rb +18 -16
- data/lib/rubocop/cop/chef/deprecation/use_inline_resources.rb +56 -0
- data/lib/rubocop/cop/chef/deprecation/user_supports_property.rb +53 -0
- data/lib/rubocop/cop/chef/deprecation/xml_ruby_recipe.rb +51 -0
- data/lib/rubocop/cop/chef/deprecation/yum_dnf_compat_recipe.rb +51 -0
- data/lib/rubocop/cop/chef/effortless/data_bags.rb +13 -11
- data/lib/rubocop/cop/chef/effortless/search_used.rb +13 -11
- data/lib/rubocop/cop/chef/modernize/apt_default_recipe.rb +22 -20
- data/lib/rubocop/cop/chef/modernize/berksfile_source.rb +31 -29
- data/lib/rubocop/cop/chef/modernize/build_essential.rb +25 -23
- data/lib/rubocop/cop/chef/modernize/chef_14_resources.rb +27 -25
- data/lib/rubocop/cop/chef/modernize/defines_chefspec_matchers.rb +25 -23
- data/lib/rubocop/cop/chef/modernize/execute_apt_update.rb +19 -17
- data/lib/rubocop/cop/chef/modernize/includes_mixin_shellout.rb +27 -25
- data/lib/rubocop/cop/chef/modernize/libarchive_file.rb +41 -0
- data/lib/rubocop/cop/chef/modernize/minitest_handler_usage.rb +21 -19
- data/lib/rubocop/cop/chef/modernize/powershell_expand_archive.rb +48 -0
- data/lib/rubocop/cop/chef/modernize/powershell_install_package.rb +51 -0
- data/lib/rubocop/cop/chef/modernize/powershell_install_windowsfeature.rb +54 -0
- data/lib/rubocop/cop/chef/modernize/resource_set_or_return.rb +25 -23
- data/lib/rubocop/cop/chef/modernize/resource_with_allowed_actions.rb +77 -0
- data/lib/rubocop/cop/chef/modernize/resource_with_attributes.rb +37 -35
- data/lib/rubocop/cop/chef/modernize/respond_to_metadata.rb +54 -0
- data/lib/rubocop/cop/chef/modernize/respond_to_provides.rb +25 -23
- data/lib/rubocop/cop/chef/modernize/respond_to_resource_name.rb +26 -24
- data/lib/rubocop/cop/chef/{effortless/node_save.rb → modernize/seven_zip_archive.rb} +16 -16
- data/lib/rubocop/cop/chef/modernize/shellouts_to_chocolatey.rb +59 -0
- data/lib/rubocop/cop/chef/modernize/whyrun_supported_true.rb +20 -18
- data/lib/rubocop/cop/chef/modernize/windows_default_recipe.rb +23 -21
- data/lib/rubocop/cop/chef/modernize/windows_version_helper.rb +20 -18
- data/lib/rubocop/cop/chef/modernize/windows_zipfile.rb +15 -13
- data/lib/rubocop/cop/chef/style/attribute_keys.rb +59 -57
- data/lib/rubocop/cop/chef/style/comment_sentence_spacing.rb +14 -12
- data/lib/rubocop/cop/chef/style/comments_copyright_format.rb +65 -63
- data/lib/rubocop/cop/chef/style/comments_format.rb +48 -45
- data/lib/rubocop/cop/chef/style/file_mode.rb +32 -30
- metadata +24 -9
- data/lib/rubocop/cop/chef/deprecation/respond_to_metadata.rb +0 -53
- data/lib/rubocop/cop/chef/modernize/ohai_default_recipe.rb +0 -45
- data/lib/rubocop/cop/chef/modernize/resource_with_allowed_action.rb +0 -75
- data/lib/rubocop/cop/chef/modernize/use_inline_resources.rb +0 -54
- data/lib/rubocop/cop/chef/modernize/xml_ruby_recipe.rb +0 -49
- data/lib/rubocop/cop/chef/modernize/yum_dnf_compat_recipe.rb +0 -49
@@ -0,0 +1,54 @@
|
|
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 ChefModernize
|
21
|
+
# It is not longer necessary respond_to?(:foo) in metadata. This was used to support new metadata
|
22
|
+
# methods in Chef 11 and early versions of Chef 12.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
#
|
26
|
+
# # bad
|
27
|
+
# chef_version '>= 13' if respond_to?(:chef_version)
|
28
|
+
#
|
29
|
+
# # good
|
30
|
+
# chef_version '>= 13'
|
31
|
+
#
|
32
|
+
class RespondToInMetadata < Cop
|
33
|
+
MSG = 'It is no longer necessary to use respond_to? in metadata.rb in Chef Infra Client 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
|
54
|
+
end
|
@@ -17,33 +17,35 @@
|
|
17
17
|
module RuboCop
|
18
18
|
module Cop
|
19
19
|
module Chef
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
20
|
+
module ChefModernize
|
21
|
+
# It is not longer necessary respond_to?(:foo) in metadata. This was used to support new metadata
|
22
|
+
# methods in Chef 11 and early versions of Chef 12.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
#
|
26
|
+
# # bad
|
27
|
+
# provides :foo if respond_to?(:provides)
|
28
|
+
#
|
29
|
+
# # good
|
30
|
+
# provides :foo
|
31
|
+
#
|
32
|
+
class RespondToProvides < Cop
|
33
|
+
MSG = 'respond_to?(:provides) in resources is no longer necessary in Chef Infra Client 12+'.freeze
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
35
|
+
def on_if(node)
|
36
|
+
if_respond_to_provides?(node) do
|
37
|
+
add_offense(node, location: :expression, message: MSG, severity: :refactor)
|
38
|
+
end
|
37
39
|
end
|
38
|
-
end
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
41
|
+
def_node_matcher :if_respond_to_provides?, <<~PATTERN
|
42
|
+
(if (send nil? :respond_to? ( :sym :provides ) ) ... )
|
43
|
+
PATTERN
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
45
|
+
def autocorrect(node)
|
46
|
+
lambda do |corrector|
|
47
|
+
corrector.replace(node.loc.expression, node.children[1].source)
|
48
|
+
end
|
47
49
|
end
|
48
50
|
end
|
49
51
|
end
|
@@ -17,34 +17,36 @@
|
|
17
17
|
module RuboCop
|
18
18
|
module Cop
|
19
19
|
module Chef
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
20
|
+
module ChefModernize
|
21
|
+
# Chef 12.5 introduced the resource_name method for resources. Many cookbooks used
|
22
|
+
# respond_to?(:resource_name) to provide backwards compatibility with older chef-client
|
23
|
+
# releases. This backwards compatibility is no longer necessary.
|
24
|
+
#
|
25
|
+
# @example
|
26
|
+
#
|
27
|
+
# # bad
|
28
|
+
# resource_name :foo if respond_to?(:resource_name)
|
29
|
+
#
|
30
|
+
# # good
|
31
|
+
# resource_name :foo
|
32
|
+
#
|
33
|
+
class RespondToResourceName < Cop
|
34
|
+
MSG = 'respond_to?(:resource_name) in resources is no longer necessary in Chef Infra Client 12.5+'.freeze
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
36
|
+
def on_if(node)
|
37
|
+
if_respond_to_resource_name?(node) do
|
38
|
+
add_offense(node, location: :expression, message: MSG, severity: :refactor)
|
39
|
+
end
|
38
40
|
end
|
39
|
-
end
|
40
41
|
|
41
|
-
|
42
|
-
|
43
|
-
|
42
|
+
def_node_matcher :if_respond_to_resource_name?, <<~PATTERN
|
43
|
+
(if (send nil? :respond_to? ( :sym :resource_name ) ) ... )
|
44
|
+
PATTERN
|
44
45
|
|
45
|
-
|
46
|
-
|
47
|
-
|
46
|
+
def autocorrect(node)
|
47
|
+
lambda do |corrector|
|
48
|
+
corrector.replace(node.loc.expression, node.children[1].source)
|
49
|
+
end
|
48
50
|
end
|
49
51
|
end
|
50
52
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright::
|
2
|
+
# Copyright:: 2019, Chef Software Inc.
|
3
3
|
# Author:: Tim Smith (<tsmith@chef.io>)
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -14,25 +14,25 @@
|
|
14
14
|
# See the License for the specific language governing permissions and
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
|
+
|
17
18
|
module RuboCop
|
18
19
|
module Cop
|
19
20
|
module Chef
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
21
|
+
module ChefModernize
|
22
|
+
# Use the archive_file resource built into Chef Infra Client 15+ instead of the seven_zip_archive
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
#
|
26
|
+
# # bad
|
27
|
+
# seven_zip_archive "C:\file.zip" do
|
28
|
+
# path 'C:\expand_here'
|
29
|
+
# end
|
30
|
+
#
|
31
|
+
class SevenZipArchiveResource < Cop
|
32
|
+
MSG = 'Use the archive_file resource built into Chef Infra Client 15+ instead of the seven_zip_archive'.freeze
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
add_offense(node, location: :expression, message: MSG, severity: :refactor)
|
34
|
+
def on_send(node)
|
35
|
+
add_offense(node, location: :expression, message: MSG, severity: :refactor) if node.method_name == :seven_zip_archive
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -0,0 +1,59 @@
|
|
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 ChefModernize
|
21
|
+
# Use the Chocolatey resources built into Chef Infra Client instead of shelling out to the choco command
|
22
|
+
#
|
23
|
+
# @example
|
24
|
+
#
|
25
|
+
# # bad
|
26
|
+
# execute 'install package foo' do
|
27
|
+
# command "choco install --source=artifactory \"foo\" -y --no-progress --ignore-package-exit-codes"
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
# powershell_script 'add artifactory choco source' do
|
31
|
+
# code "choco source add -n=artifactory -s='https://mycorp.jfrog.io/mycorp/api/nuget/chocolatey-remote' -u foo -p bar"x
|
32
|
+
# not_if 'choco source list | findstr artifactory'
|
33
|
+
# end
|
34
|
+
#
|
35
|
+
class ShellOutToChocolatey < Cop
|
36
|
+
include RuboCop::Chef::CookbookHelpers
|
37
|
+
|
38
|
+
MSG = 'Use the Chocolatey resources built into Chef Infra Client instead of shelling out to the choco command'.freeze
|
39
|
+
|
40
|
+
def on_block(node)
|
41
|
+
match_property_in_resource?(:powershell_script, 'code', node) do |code_property|
|
42
|
+
property_data = method_arg_ast_to_string(code_property)
|
43
|
+
if property_data && property_data.match?(/^choco /i)
|
44
|
+
add_offense(node, location: :expression, message: MSG, severity: :refactor)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
match_property_in_resource?(:execute, 'command', node) do |code_property|
|
49
|
+
property_data = method_arg_ast_to_string(code_property)
|
50
|
+
if property_data && property_data.match?(/^choco /i)
|
51
|
+
add_offense(node, location: :expression, message: MSG, severity: :refactor)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -17,27 +17,29 @@
|
|
17
17
|
module RuboCop
|
18
18
|
module Cop
|
19
19
|
module Chef
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
20
|
+
module ChefModernize
|
21
|
+
# whyrun_supported? no longer needs to be set to true as that is the default in Chef Infra Client 13+
|
22
|
+
#
|
23
|
+
# @example
|
24
|
+
#
|
25
|
+
# # bad
|
26
|
+
# def whyrun_supported?
|
27
|
+
# true
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
class WhyRunSupportedTrue < Cop
|
31
|
+
MSG = 'whyrun_supported? no longer needs to be set to true as it is the default in Chef Infra Client 13+'.freeze
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
33
|
+
def on_def(node)
|
34
|
+
if node.method_name == :whyrun_supported? && node.body == s(:true) # rubocop: disable Lint/BooleanSymbol
|
35
|
+
add_offense(node, location: :expression, message: MSG, severity: :refactor)
|
36
|
+
end
|
35
37
|
end
|
36
|
-
end
|
37
38
|
|
38
|
-
|
39
|
-
|
40
|
-
|
39
|
+
def autocorrect(node)
|
40
|
+
lambda do |corrector|
|
41
|
+
corrector.remove(node.loc.expression)
|
42
|
+
end
|
41
43
|
end
|
42
44
|
end
|
43
45
|
end
|
@@ -17,31 +17,33 @@
|
|
17
17
|
module RuboCop
|
18
18
|
module Cop
|
19
19
|
module Chef
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
20
|
+
module ChefModernize
|
21
|
+
# Don't include the windows default recipe that is either full of gem install that are part
|
22
|
+
# of the Chef Infra Client, or empty (depends on version).
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
#
|
26
|
+
# # bad
|
27
|
+
# include_recipe 'windows::default'
|
28
|
+
# include_recipe 'windows'
|
29
|
+
#
|
30
|
+
class IncludingWindowsDefaultRecipe < Cop
|
31
|
+
MSG = 'Do not include the Windows default recipe, which only installs win32 gems already included in Chef Infra Client'.freeze
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
33
|
+
def_node_matcher :windows_recipe_usage?, <<-PATTERN
|
34
|
+
(send nil? :include_recipe (str {"windows" "windows::default"}))
|
35
|
+
PATTERN
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
def on_send(node)
|
38
|
+
windows_recipe_usage?(node) do
|
39
|
+
add_offense(node, location: :expression, message: MSG, severity: :refactor)
|
40
|
+
end
|
39
41
|
end
|
40
|
-
end
|
41
42
|
|
42
|
-
|
43
|
-
|
44
|
-
|
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,26 +17,28 @@
|
|
17
17
|
module RuboCop
|
18
18
|
module Cop
|
19
19
|
module Chef
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
20
|
+
module ChefModernize
|
21
|
+
# Use node['platform_version] data instead of the Windows::VersionHelper helper from the Windows cookbook.
|
22
|
+
#
|
23
|
+
# @example
|
24
|
+
#
|
25
|
+
# # bad
|
26
|
+
# Windows::VersionHelper.nt_version
|
27
|
+
#
|
28
|
+
# # good
|
29
|
+
# node['platform_version].to_i
|
30
|
+
#
|
31
|
+
class WindowsVersionHelper < Cop
|
32
|
+
MSG = "Use node['platform_version'] data instead of the Windows::VersionHelper helper from the Windows cookbook.".freeze
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
34
|
+
def_node_matcher :windows_helper?, <<-PATTERN
|
35
|
+
(send ( const ( const {nil? cbase} :Windows ) :VersionHelper ) ... )
|
36
|
+
PATTERN
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
38
|
+
def on_send(node)
|
39
|
+
windows_helper?(node) do
|
40
|
+
add_offense(node, location: :expression, message: MSG, severity: :refactor)
|
41
|
+
end
|
40
42
|
end
|
41
43
|
end
|
42
44
|
end
|
@@ -17,20 +17,22 @@
|
|
17
17
|
module RuboCop
|
18
18
|
module Cop
|
19
19
|
module Chef
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
20
|
+
module ChefModernize
|
21
|
+
# Use the archive_file resource built into Chef Infra Client 15+ instead of the windows_zipfile from the Windows cookbook
|
22
|
+
#
|
23
|
+
# @example
|
24
|
+
#
|
25
|
+
# # bad
|
26
|
+
# windows_zipfile 'C:\\files\\' do
|
27
|
+
# source 'C:\\Temp\\file.zip'
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
class WindowsZipfileUsage < Cop
|
31
|
+
MSG = 'Use the archive_file resource built into Chef Infra Client 15+ instead of the windows_zipfile from the Windows cookbook'.freeze
|
31
32
|
|
32
|
-
|
33
|
-
|
33
|
+
def on_send(node)
|
34
|
+
add_offense(node, location: :expression, message: MSG, severity: :refactor) if node.method_name == :windows_zipfile
|
35
|
+
end
|
34
36
|
end
|
35
37
|
end
|
36
38
|
end
|