cookstyle 5.15.7 → 5.16.10
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 +172 -4
- data/lib/cookstyle.rb +6 -0
- data/lib/cookstyle/version.rb +1 -1
- data/lib/rubocop/chef/cookbook_helpers.rb +12 -4
- data/lib/rubocop/cop/chef/correctness/dnf_package_allow_downgrades.rb +50 -0
- data/lib/rubocop/cop/chef/correctness/invalid_notification_timing.rb +53 -0
- data/lib/rubocop/cop/chef/correctness/malformed_value_for_platform.rb +67 -0
- data/lib/rubocop/cop/chef/correctness/notifies_action_not_symbol.rb +11 -3
- data/lib/rubocop/cop/chef/deprecation/chef_rewind.rb +6 -3
- data/lib/rubocop/cop/chef/deprecation/depends_compat_resource.rb +4 -0
- data/lib/rubocop/cop/chef/deprecation/deprecated_platform_methods.rb +56 -0
- data/lib/rubocop/cop/chef/deprecation/legacy_notify_syntax.rb +11 -3
- data/lib/rubocop/cop/chef/deprecation/name_property_and_default.rb +18 -22
- data/lib/rubocop/cop/chef/deprecation/ruby_block_create_action.rb +64 -0
- data/lib/rubocop/cop/chef/modernize/apt_default_recipe.rb +5 -2
- data/lib/rubocop/cop/chef/modernize/chef_14_resources.rb +4 -0
- data/lib/rubocop/cop/chef/modernize/cron_manage_resource.rb +4 -0
- data/lib/rubocop/cop/chef/modernize/depends_zypper_cookbook.rb +4 -0
- data/lib/rubocop/cop/chef/modernize/execute_sc_exe.rb +66 -0
- data/lib/rubocop/cop/chef/modernize/execute_sleep.rb +77 -0
- data/lib/rubocop/cop/chef/modernize/execute_tzutil.rb +3 -0
- data/lib/rubocop/cop/chef/modernize/foodcritic_comments.rb +51 -0
- data/lib/rubocop/cop/chef/modernize/libarchive_file.rb +4 -0
- data/lib/rubocop/cop/chef/modernize/macos_user_defaults.rb +4 -0
- data/lib/rubocop/cop/chef/modernize/openssl_rsa_key_resource.rb +4 -0
- data/lib/rubocop/cop/chef/modernize/openssl_x509_resource.rb +4 -0
- data/lib/rubocop/cop/chef/modernize/powershell_expand_archive.rb +3 -0
- data/lib/rubocop/cop/chef/modernize/powershell_guard_interpreter.rb +3 -0
- data/lib/rubocop/cop/chef/modernize/powershell_install_package.rb +3 -0
- data/lib/rubocop/cop/chef/modernize/powershell_install_windowsfeature.rb +3 -0
- data/lib/rubocop/cop/chef/modernize/property_with_name_attribute.rb +13 -15
- data/lib/rubocop/cop/chef/modernize/respond_to_metadata.rb +4 -0
- data/lib/rubocop/cop/chef/modernize/sc_windows_resource.rb +49 -0
- data/lib/rubocop/cop/chef/modernize/seven_zip_archive.rb +4 -0
- data/lib/rubocop/cop/chef/modernize/systctl_param_resource.rb +4 -2
- data/lib/rubocop/cop/chef/modernize/whyrun_supported_true.rb +4 -0
- data/lib/rubocop/cop/chef/modernize/windows_default_recipe.rb +1 -2
- data/lib/rubocop/cop/chef/modernize/windows_zipfile.rb +4 -0
- data/lib/rubocop/cop/chef/modernize/zipfile_resource.rb +3 -0
- data/lib/rubocop/cop/chef/modernize/zypper_repo.rb +4 -0
- data/lib/rubocop/cop/chef/redundant/custom_resource_with_allowed_actions.rb +1 -1
- data/lib/rubocop/cop/chef/redundant/long_description_metadata.rb +0 -1
- data/lib/rubocop/cop/chef/redundant/sensitive_property_in_resource.rb +48 -0
- data/lib/rubocop/cop/chef/redundant/unnecessary_desired_state.rb +57 -0
- data/lib/rubocop/cop/chef/redundant/unnecessary_name_property.rb +10 -7
- data/lib/rubocop/cop/chef/style/immediate_notification_timing.rb +59 -0
- data/lib/rubocop/cop/chef/style/true_false_resource_properties.rb +55 -0
- data/lib/rubocop/cop/chef/style/unnecessary_platform_case_statement.rb +90 -0
- data/lib/rubocop/cop/chef/style/use_platform_helpers.rb +21 -5
- data/lib/rubocop/cop/target_chef_version.rb +18 -0
- data/lib/rubocop/monkey_patches/commissioner.rb +26 -0
- data/lib/rubocop/monkey_patches/config.rb +15 -0
- data/lib/rubocop/monkey_patches/cop.rb +10 -0
- metadata +20 -2
@@ -27,33 +27,49 @@ module RuboCop
|
|
27
27
|
# node['platform_family'] == 'debian'
|
28
28
|
# node['platform'] != 'ubuntu'
|
29
29
|
# node['platform_family'] != 'debian'
|
30
|
+
# %w(rhel suse).include?(node['platform_family'])
|
30
31
|
#
|
31
32
|
# # good
|
32
33
|
# platform?('ubuntu')
|
33
34
|
# !platform?('ubuntu')
|
34
35
|
# platform_family?('debian')
|
35
36
|
# !platform_family?('debian')
|
37
|
+
# platform_family?('rhel', 'suse')
|
36
38
|
#
|
37
39
|
class UsePlatformHelpers < Cop
|
38
|
-
MSG = "Use platform? and platform_family? helpers
|
40
|
+
MSG = "Use platform? and platform_family? helpers to check a node's platform".freeze
|
39
41
|
|
40
|
-
def_node_matcher :
|
41
|
-
(
|
42
|
+
def_node_matcher :platform_equals?, <<-PATTERN
|
43
|
+
(send (send (send nil? :node) :[] $(str {"platform" "platform_family"}) ) ${:== :!=} $str )
|
44
|
+
PATTERN
|
45
|
+
|
46
|
+
def_node_matcher :platform_include?, <<-PATTERN
|
47
|
+
(send $(array ...) :include? (send (send nil? :node) :[] $(str {"platform" "platform_family"})))
|
42
48
|
PATTERN
|
43
49
|
|
44
50
|
def on_send(node)
|
45
|
-
|
51
|
+
platform_equals?(node) do
|
52
|
+
add_offense(node, location: :expression, message: MSG, severity: :refactor)
|
53
|
+
end
|
54
|
+
|
55
|
+
platform_include?(node) do
|
46
56
|
add_offense(node, location: :expression, message: MSG, severity: :refactor)
|
47
57
|
end
|
48
58
|
end
|
49
59
|
|
50
60
|
def autocorrect(node)
|
51
61
|
lambda do |corrector|
|
52
|
-
|
62
|
+
platform_equals?(node) do |type, operator, plat|
|
53
63
|
corrected_string = operator == :!= ? '!' : ''
|
54
64
|
corrected_string << "#{type.value}?('#{plat.value}')"
|
55
65
|
corrector.replace(node.loc.expression, corrected_string)
|
56
66
|
end
|
67
|
+
|
68
|
+
platform_include?(node) do |plats, type|
|
69
|
+
platforms = plats.values.map { |x| x.str_type? ? "'#{x.value}'" : x.source }
|
70
|
+
corrected_string = "#{type.value}?(#{platforms.join(', ')})"
|
71
|
+
corrector.replace(node.loc.expression, corrected_string)
|
72
|
+
end
|
57
73
|
end
|
58
74
|
end
|
59
75
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# shamelessly borrowed from rubocop-rails. Thanks!
|
4
|
+
|
5
|
+
module RuboCop
|
6
|
+
module Cop
|
7
|
+
# Common functionality for checking target chef version.
|
8
|
+
module TargetChefVersion
|
9
|
+
def minimum_target_chef_version(version)
|
10
|
+
@minimum_target_chef_version = version
|
11
|
+
end
|
12
|
+
|
13
|
+
def support_target_chef_version?(version)
|
14
|
+
Gem::Version.new(@minimum_target_chef_version) <= Gem::Version.new(version)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,26 @@
|
|
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
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
class Config
|
5
|
+
# This is a copy of the #target_rails_version method from Rubocop
|
6
|
+
def target_chef_version
|
7
|
+
@target_chef_version ||=
|
8
|
+
if for_all_cops['TargetChefVersion']
|
9
|
+
for_all_cops['TargetChefVersion'].to_f
|
10
|
+
else
|
11
|
+
99 # just set a high number so we don't need to update this later
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
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: 5.
|
4
|
+
version: 5.16.10
|
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-12-
|
12
|
+
date: 2019-12-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rubocop
|
@@ -50,13 +50,16 @@ files:
|
|
50
50
|
- lib/rubocop/chef/platform_helpers.rb
|
51
51
|
- lib/rubocop/cop/chef/correctness/block_guard_clause_string_only.rb
|
52
52
|
- lib/rubocop/cop/chef/correctness/cb_depends_on_self.rb
|
53
|
+
- lib/rubocop/cop/chef/correctness/dnf_package_allow_downgrades.rb
|
53
54
|
- lib/rubocop/cop/chef/correctness/incorrect_library_injection.rb
|
55
|
+
- lib/rubocop/cop/chef/correctness/invalid_notification_timing.rb
|
54
56
|
- lib/rubocop/cop/chef/correctness/invalid_platform_family_helper.rb
|
55
57
|
- lib/rubocop/cop/chef/correctness/invalid_platform_helper.rb
|
56
58
|
- lib/rubocop/cop/chef/correctness/invalid_platform_metadata.rb
|
57
59
|
- lib/rubocop/cop/chef/correctness/invalid_value_for_platform_family_helper.rb
|
58
60
|
- lib/rubocop/cop/chef/correctness/invalid_value_for_platform_helper.rb
|
59
61
|
- lib/rubocop/cop/chef/correctness/invalid_version_metadata.rb
|
62
|
+
- lib/rubocop/cop/chef/correctness/malformed_value_for_platform.rb
|
60
63
|
- lib/rubocop/cop/chef/correctness/metadata_missing_name.rb
|
61
64
|
- lib/rubocop/cop/chef/correctness/node_normal.rb
|
62
65
|
- lib/rubocop/cop/chef/correctness/node_normal_unless.rb
|
@@ -79,6 +82,7 @@ files:
|
|
79
82
|
- lib/rubocop/cop/chef/deprecation/depends_partial_search.rb
|
80
83
|
- lib/rubocop/cop/chef/deprecation/depends_poise.rb
|
81
84
|
- lib/rubocop/cop/chef/deprecation/deprecated_mixins.rb
|
85
|
+
- lib/rubocop/cop/chef/deprecation/deprecated_platform_methods.rb
|
82
86
|
- lib/rubocop/cop/chef/deprecation/deprecated_yum_repository_properties.rb
|
83
87
|
- lib/rubocop/cop/chef/deprecation/easy_install.rb
|
84
88
|
- lib/rubocop/cop/chef/deprecation/eol_audit_mode.rb
|
@@ -103,6 +107,7 @@ files:
|
|
103
107
|
- lib/rubocop/cop/chef/deprecation/resource_uses_dsl_name_method.rb
|
104
108
|
- lib/rubocop/cop/chef/deprecation/resource_uses_provider_base_method.rb
|
105
109
|
- lib/rubocop/cop/chef/deprecation/resource_uses_updated_method.rb
|
110
|
+
- lib/rubocop/cop/chef/deprecation/ruby_block_create_action.rb
|
106
111
|
- lib/rubocop/cop/chef/deprecation/run_command_helper.rb
|
107
112
|
- lib/rubocop/cop/chef/deprecation/search_uses_positional_parameters.rb
|
108
113
|
- lib/rubocop/cop/chef/deprecation/use_inline_resources.rb
|
@@ -131,7 +136,10 @@ files:
|
|
131
136
|
- lib/rubocop/cop/chef/modernize/depends_zypper_cookbook.rb
|
132
137
|
- lib/rubocop/cop/chef/modernize/empty_resource_initialize.rb
|
133
138
|
- lib/rubocop/cop/chef/modernize/execute_apt_update.rb
|
139
|
+
- lib/rubocop/cop/chef/modernize/execute_sc_exe.rb
|
140
|
+
- lib/rubocop/cop/chef/modernize/execute_sleep.rb
|
134
141
|
- lib/rubocop/cop/chef/modernize/execute_tzutil.rb
|
142
|
+
- lib/rubocop/cop/chef/modernize/foodcritic_comments.rb
|
135
143
|
- lib/rubocop/cop/chef/modernize/if_provides_default_action.rb
|
136
144
|
- lib/rubocop/cop/chef/modernize/includes_mixin_shellout.rb
|
137
145
|
- lib/rubocop/cop/chef/modernize/libarchive_file.rb
|
@@ -152,6 +160,7 @@ files:
|
|
152
160
|
- lib/rubocop/cop/chef/modernize/respond_to_metadata.rb
|
153
161
|
- lib/rubocop/cop/chef/modernize/respond_to_provides.rb
|
154
162
|
- lib/rubocop/cop/chef/modernize/respond_to_resource_name.rb
|
163
|
+
- lib/rubocop/cop/chef/modernize/sc_windows_resource.rb
|
155
164
|
- lib/rubocop/cop/chef/modernize/seven_zip_archive.rb
|
156
165
|
- lib/rubocop/cop/chef/modernize/shellouts_to_chocolatey.rb
|
157
166
|
- lib/rubocop/cop/chef/modernize/systctl_param_resource.rb
|
@@ -172,7 +181,9 @@ files:
|
|
172
181
|
- lib/rubocop/cop/chef/redundant/recipe_metadata.rb
|
173
182
|
- lib/rubocop/cop/chef/redundant/replaces_metadata.rb
|
174
183
|
- lib/rubocop/cop/chef/redundant/resource_with_nothing_action.rb
|
184
|
+
- lib/rubocop/cop/chef/redundant/sensitive_property_in_resource.rb
|
175
185
|
- lib/rubocop/cop/chef/redundant/suggests_metadata.rb
|
186
|
+
- lib/rubocop/cop/chef/redundant/unnecessary_desired_state.rb
|
176
187
|
- lib/rubocop/cop/chef/redundant/unnecessary_name_property.rb
|
177
188
|
- lib/rubocop/cop/chef/sharing/default_maintainer_metadata.rb
|
178
189
|
- lib/rubocop/cop/chef/sharing/empty_metadata_field.rb
|
@@ -184,9 +195,16 @@ files:
|
|
184
195
|
- lib/rubocop/cop/chef/style/comments_default_copyright.rb
|
185
196
|
- lib/rubocop/cop/chef/style/comments_format.rb
|
186
197
|
- lib/rubocop/cop/chef/style/file_mode.rb
|
198
|
+
- lib/rubocop/cop/chef/style/immediate_notification_timing.rb
|
187
199
|
- lib/rubocop/cop/chef/style/simplify_platform_major_version_check.rb
|
200
|
+
- lib/rubocop/cop/chef/style/true_false_resource_properties.rb
|
201
|
+
- lib/rubocop/cop/chef/style/unnecessary_platform_case_statement.rb
|
188
202
|
- lib/rubocop/cop/chef/style/use_platform_helpers.rb
|
203
|
+
- lib/rubocop/cop/target_chef_version.rb
|
189
204
|
- lib/rubocop/monkey_patches/comment_config.rb
|
205
|
+
- lib/rubocop/monkey_patches/commissioner.rb
|
206
|
+
- lib/rubocop/monkey_patches/config.rb
|
207
|
+
- lib/rubocop/monkey_patches/cop.rb
|
190
208
|
- lib/rubocop/monkey_patches/json_formatter.rb
|
191
209
|
homepage:
|
192
210
|
licenses:
|