cookstyle 6.2.9 → 6.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/config/cookstyle.yml +306 -15
- data/config/disable_all.yml +21 -3
- data/config/upstream.yml +141 -35
- data/lib/cookstyle.rb +1 -1
- data/lib/cookstyle/version.rb +2 -2
- data/lib/rubocop/chef/platform_helpers.rb +2 -1
- data/lib/rubocop/cop/chef/correctness/invalid_platform_family_values_in_case.rb +77 -0
- data/lib/rubocop/cop/chef/correctness/invalid_platform_values_in_case.rb +77 -0
- data/lib/rubocop/cop/chef/correctness/lazy_eval_node_attribute_defaults.rb +56 -0
- data/lib/rubocop/cop/chef/correctness/node_normal.rb +1 -1
- data/lib/rubocop/cop/chef/correctness/node_normal_unless.rb +1 -1
- data/lib/rubocop/cop/chef/correctness/openssl_password_helpers.rb +45 -0
- data/lib/rubocop/cop/chef/deprecation/depends_compat_resource.rb +1 -1
- data/lib/rubocop/cop/chef/deprecation/depends_partial_search.rb +1 -1
- data/lib/rubocop/cop/chef/deprecation/deprecated_chefspec_platform.rb +10 -4
- data/lib/rubocop/cop/chef/deprecation/deprecated_shellout_methods.rb +65 -0
- data/lib/rubocop/cop/chef/deprecation/easy_install.rb +2 -2
- data/lib/rubocop/cop/chef/deprecation/erl_call.rb +1 -1
- data/lib/rubocop/cop/chef/deprecation/locale_lc_all_property.rb +2 -2
- data/lib/rubocop/cop/chef/deprecation/node_methods_not_attributes.rb +1 -1
- data/lib/rubocop/cop/chef/deprecation/node_set.rb +2 -3
- data/lib/rubocop/cop/chef/deprecation/node_set_unless.rb +2 -3
- data/lib/rubocop/cop/chef/deprecation/powershell_cookbook_helpers.rb +3 -3
- data/lib/rubocop/cop/chef/deprecation/resource_uses_only_resource_name.rb +77 -0
- data/lib/rubocop/cop/chef/deprecation/ruby_27_keyword_argument_warnings.rb +59 -0
- data/lib/rubocop/cop/chef/deprecation/user_supports_property.rb +6 -1
- data/lib/rubocop/cop/chef/deprecation/xml_ruby_recipe.rb +3 -3
- data/lib/rubocop/cop/chef/modernize/includes_mixin_shellout.rb +24 -3
- data/lib/rubocop/cop/chef/modernize/respond_to_compile_time.rb +93 -0
- data/lib/rubocop/cop/chef/modernize/respond_to_provides.rb +15 -5
- data/lib/rubocop/cop/chef/modernize/shell_out_helper.rb +64 -0
- data/lib/rubocop/cop/chef/modernize/use_multipackage_installs.rb +8 -4
- data/lib/rubocop/cop/chef/style/overly_complex_supports_depends_metadata.rb +1 -1
- data/lib/rubocop/cop/target_chef_version.rb +4 -0
- data/lib/rubocop/monkey_patches/team.rb +24 -0
- metadata +14 -5
- data/lib/rubocop/monkey_patches/commissioner.rb +0 -26
@@ -0,0 +1,64 @@
|
|
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
|
+
module ChefModernize
|
22
|
+
# Use the built-in `shell_out` helper available in Chef Infra Client 12.11+ instead of calling `Mixlib::ShellOut.new('foo').run_command`.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
#
|
26
|
+
# # bad
|
27
|
+
# Mixlib::ShellOut.new('foo').run_command
|
28
|
+
#
|
29
|
+
# # good
|
30
|
+
# shell_out('foo')
|
31
|
+
#
|
32
|
+
class ShellOutHelper < Cop
|
33
|
+
extend TargetChefVersion
|
34
|
+
|
35
|
+
minimum_target_chef_version '12.11'
|
36
|
+
|
37
|
+
MSG = "Use the built-in `shell_out` helper available in Chef Infra Client 12.11+ instead of calling `Mixlib::ShellOut.new('foo').run_command`.".freeze
|
38
|
+
|
39
|
+
def_node_matcher :mixlib_shellout_run_cmd?, <<-PATTERN
|
40
|
+
(send
|
41
|
+
(send
|
42
|
+
(const
|
43
|
+
(const nil? :Mixlib) :ShellOut) :new
|
44
|
+
$(...)) :run_command)
|
45
|
+
PATTERN
|
46
|
+
|
47
|
+
def on_send(node)
|
48
|
+
mixlib_shellout_run_cmd?(node) do
|
49
|
+
add_offense(node, location: :expression, message: MSG, severity: :refactor)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def autocorrect(node)
|
54
|
+
mixlib_shellout_run_cmd?(node) do |cmd|
|
55
|
+
lambda do |corrector|
|
56
|
+
corrector.replace(node.loc.expression, "shell_out(#{cmd.loc.expression.source})")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -47,12 +47,14 @@ module RuboCop
|
|
47
47
|
(send
|
48
48
|
$(array ... ) :each)
|
49
49
|
(args ... )
|
50
|
-
(block
|
50
|
+
{(block
|
51
51
|
(send nil? :package
|
52
52
|
(lvar ... ))
|
53
53
|
(args)
|
54
54
|
(send nil? :action
|
55
|
-
(sym :install)))
|
55
|
+
(sym :install)))
|
56
|
+
(send nil? :package
|
57
|
+
(lvar _))}) nil?)
|
56
58
|
PATTERN
|
57
59
|
|
58
60
|
def_node_matcher :package_array_install?, <<-PATTERN
|
@@ -60,12 +62,14 @@ module RuboCop
|
|
60
62
|
(send
|
61
63
|
$(array ... ) :each)
|
62
64
|
(args ... )
|
63
|
-
(block
|
65
|
+
{(block
|
64
66
|
(send nil? :package
|
65
67
|
(lvar ... ))
|
66
68
|
(args)
|
67
69
|
(send nil? :action
|
68
|
-
(sym :install)))
|
70
|
+
(sym :install)))
|
71
|
+
(send nil? :package
|
72
|
+
(lvar _))})
|
69
73
|
PATTERN
|
70
74
|
|
71
75
|
# see if all platforms in the when condition are multipackage compliant
|
@@ -18,7 +18,7 @@ module RuboCop
|
|
18
18
|
module Cop
|
19
19
|
module Chef
|
20
20
|
module ChefStyle
|
21
|
-
# Don't loop over an array to set cookbook dependencies or supported platforms if you have fewer than three values to set.
|
21
|
+
# Don't loop over an array to set cookbook dependencies or supported platforms if you have fewer than three values to set. Setting multiple `supports` or `depends` values is simpler and easier to understand for new users.
|
22
22
|
#
|
23
23
|
# @example
|
24
24
|
#
|
@@ -6,6 +6,10 @@ module RuboCop
|
|
6
6
|
module Cop
|
7
7
|
# Common functionality for checking target chef version.
|
8
8
|
module TargetChefVersion
|
9
|
+
def required_minimum_chef_version
|
10
|
+
@minimum_target_chef_version
|
11
|
+
end
|
12
|
+
|
9
13
|
def minimum_target_chef_version(version)
|
10
14
|
@minimum_target_chef_version = version
|
11
15
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
class Team
|
6
|
+
def support_target_chef_version?(cop)
|
7
|
+
return true unless cop.class.respond_to?(:support_target_chef_version?)
|
8
|
+
|
9
|
+
cop.class.support_target_chef_version?(cop.target_chef_version)
|
10
|
+
end
|
11
|
+
|
12
|
+
### START COOKSTYLE MODIFICATION
|
13
|
+
def roundup_relevant_cops(filename)
|
14
|
+
cops.reject do |cop|
|
15
|
+
cop.excluded_file?(filename) ||
|
16
|
+
!support_target_ruby_version?(cop) ||
|
17
|
+
!support_target_chef_version?(cop) ||
|
18
|
+
!support_target_rails_version?(cop)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
### END COOKSTYLE MODIFICATION
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
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: 6.
|
4
|
+
version: 6.7.3
|
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: 2020-
|
12
|
+
date: 2020-06-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rubocop
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - '='
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 0.
|
20
|
+
version: 0.85.0
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - '='
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 0.
|
27
|
+
version: 0.85.0
|
28
28
|
description:
|
29
29
|
email:
|
30
30
|
- thom@chef.io
|
@@ -57,17 +57,21 @@ files:
|
|
57
57
|
- lib/rubocop/cop/chef/correctness/incorrect_library_injection.rb
|
58
58
|
- lib/rubocop/cop/chef/correctness/invalid_notification_timing.rb
|
59
59
|
- lib/rubocop/cop/chef/correctness/invalid_platform_family_helper.rb
|
60
|
+
- lib/rubocop/cop/chef/correctness/invalid_platform_family_values_in_case.rb
|
60
61
|
- lib/rubocop/cop/chef/correctness/invalid_platform_helper.rb
|
61
62
|
- lib/rubocop/cop/chef/correctness/invalid_platform_metadata.rb
|
63
|
+
- lib/rubocop/cop/chef/correctness/invalid_platform_values_in_case.rb
|
62
64
|
- lib/rubocop/cop/chef/correctness/invalid_value_for_platform_family_helper.rb
|
63
65
|
- lib/rubocop/cop/chef/correctness/invalid_value_for_platform_helper.rb
|
64
66
|
- lib/rubocop/cop/chef/correctness/invalid_version_metadata.rb
|
67
|
+
- lib/rubocop/cop/chef/correctness/lazy_eval_node_attribute_defaults.rb
|
65
68
|
- lib/rubocop/cop/chef/correctness/malformed_value_for_platform.rb
|
66
69
|
- lib/rubocop/cop/chef/correctness/metadata_missing_name.rb
|
67
70
|
- lib/rubocop/cop/chef/correctness/node_normal.rb
|
68
71
|
- lib/rubocop/cop/chef/correctness/node_normal_unless.rb
|
69
72
|
- lib/rubocop/cop/chef/correctness/node_save.rb
|
70
73
|
- lib/rubocop/cop/chef/correctness/notifies_action_not_symbol.rb
|
74
|
+
- lib/rubocop/cop/chef/correctness/openssl_password_helpers.rb
|
71
75
|
- lib/rubocop/cop/chef/correctness/powershell_delete_file.rb
|
72
76
|
- lib/rubocop/cop/chef/correctness/resource_sets_internal_properties.rb
|
73
77
|
- lib/rubocop/cop/chef/correctness/resource_sets_name_property.rb
|
@@ -89,6 +93,7 @@ files:
|
|
89
93
|
- lib/rubocop/cop/chef/deprecation/deprecated_chefspec_platform.rb
|
90
94
|
- lib/rubocop/cop/chef/deprecation/deprecated_mixins.rb
|
91
95
|
- lib/rubocop/cop/chef/deprecation/deprecated_platform_methods.rb
|
96
|
+
- lib/rubocop/cop/chef/deprecation/deprecated_shellout_methods.rb
|
92
97
|
- lib/rubocop/cop/chef/deprecation/deprecated_windows_version_check.rb
|
93
98
|
- lib/rubocop/cop/chef/deprecation/deprecated_yum_repository_properties.rb
|
94
99
|
- lib/rubocop/cop/chef/deprecation/easy_install.rb
|
@@ -114,9 +119,11 @@ files:
|
|
114
119
|
- lib/rubocop/cop/chef/deprecation/require_recipe.rb
|
115
120
|
- lib/rubocop/cop/chef/deprecation/resource_overrides_provides_method.rb
|
116
121
|
- lib/rubocop/cop/chef/deprecation/resource_uses_dsl_name_method.rb
|
122
|
+
- lib/rubocop/cop/chef/deprecation/resource_uses_only_resource_name.rb
|
117
123
|
- lib/rubocop/cop/chef/deprecation/resource_uses_provider_base_method.rb
|
118
124
|
- lib/rubocop/cop/chef/deprecation/resource_uses_updated_method.rb
|
119
125
|
- lib/rubocop/cop/chef/deprecation/resource_without_name_or_provides.rb
|
126
|
+
- lib/rubocop/cop/chef/deprecation/ruby_27_keyword_argument_warnings.rb
|
120
127
|
- lib/rubocop/cop/chef/deprecation/ruby_block_create_action.rb
|
121
128
|
- lib/rubocop/cop/chef/deprecation/run_command_helper.rb
|
122
129
|
- lib/rubocop/cop/chef/deprecation/search_uses_positional_parameters.rb
|
@@ -176,11 +183,13 @@ files:
|
|
176
183
|
- lib/rubocop/cop/chef/modernize/resource_name_initializer.rb
|
177
184
|
- lib/rubocop/cop/chef/modernize/resource_set_or_return.rb
|
178
185
|
- lib/rubocop/cop/chef/modernize/resource_with_attributes.rb
|
186
|
+
- lib/rubocop/cop/chef/modernize/respond_to_compile_time.rb
|
179
187
|
- lib/rubocop/cop/chef/modernize/respond_to_metadata.rb
|
180
188
|
- lib/rubocop/cop/chef/modernize/respond_to_provides.rb
|
181
189
|
- lib/rubocop/cop/chef/modernize/respond_to_resource_name.rb
|
182
190
|
- lib/rubocop/cop/chef/modernize/sc_windows_resource.rb
|
183
191
|
- lib/rubocop/cop/chef/modernize/seven_zip_archive.rb
|
192
|
+
- lib/rubocop/cop/chef/modernize/shell_out_helper.rb
|
184
193
|
- lib/rubocop/cop/chef/modernize/shellouts_to_chocolatey.rb
|
185
194
|
- lib/rubocop/cop/chef/modernize/simplify_apt_ppa_setup.rb
|
186
195
|
- lib/rubocop/cop/chef/modernize/systctl_param_resource.rb
|
@@ -236,9 +245,9 @@ files:
|
|
236
245
|
- lib/rubocop/cop/chef/style/use_platform_helpers.rb
|
237
246
|
- lib/rubocop/cop/target_chef_version.rb
|
238
247
|
- lib/rubocop/monkey_patches/comment_config.rb
|
239
|
-
- lib/rubocop/monkey_patches/commissioner.rb
|
240
248
|
- lib/rubocop/monkey_patches/config.rb
|
241
249
|
- lib/rubocop/monkey_patches/cop.rb
|
250
|
+
- lib/rubocop/monkey_patches/team.rb
|
242
251
|
homepage:
|
243
252
|
licenses:
|
244
253
|
- Apache-2.0
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module Cop
|
5
|
-
class Commissioner
|
6
|
-
def remove_irrelevant_cops(filename)
|
7
|
-
@cops.reject! { |cop| cop.excluded_file?(filename) }
|
8
|
-
@cops.reject! do |cop|
|
9
|
-
cop.class.respond_to?(:support_target_ruby_version?) &&
|
10
|
-
!cop.class.support_target_ruby_version?(cop.target_ruby_version)
|
11
|
-
end
|
12
|
-
@cops.reject! do |cop|
|
13
|
-
cop.class.respond_to?(:support_target_rails_version?) &&
|
14
|
-
!cop.class.support_target_rails_version?(cop.target_rails_version)
|
15
|
-
end
|
16
|
-
|
17
|
-
### START COOKSTYLE MODIFICATION
|
18
|
-
@cops.reject! do |cop|
|
19
|
-
cop.class.respond_to?(:support_target_chef_version?) &&
|
20
|
-
!cop.class.support_target_chef_version?(cop.target_chef_version)
|
21
|
-
end
|
22
|
-
### END COOKSTYLE MODIFICATION
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|