cookstyle 6.12.6 → 6.15.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/config/cookstyle.yml +122 -41
- data/config/disable_all.yml +28 -4
- data/config/upstream.yml +96 -16
- data/cookstyle.gemspec +1 -0
- data/lib/cookstyle.rb +7 -7
- data/lib/cookstyle/version.rb +2 -2
- data/lib/rubocop/cop/chef/correctness/invalid_default_action.rb +48 -0
- data/lib/rubocop/cop/chef/correctness/invalid_platform_family_helper.rb +26 -3
- data/lib/rubocop/cop/chef/correctness/macos_userdefaults_invalid_type.rb +68 -0
- data/lib/rubocop/cop/chef/correctness/notifies_action_not_symbol.rb +4 -4
- data/lib/rubocop/cop/chef/correctness/supports_must_be_float.rb +52 -0
- data/lib/rubocop/cop/chef/deprecation/cheffile.rb +2 -2
- data/lib/rubocop/cop/chef/deprecation/deprecated_chefspec_platform.rb +6 -5
- data/lib/rubocop/cop/chef/deprecation/eol_audit_mode.rb +2 -2
- data/lib/rubocop/cop/chef/deprecation/macos_userdefaults_global_property.rb +61 -0
- data/lib/rubocop/cop/chef/deprecation/poise_archive.rb +4 -2
- data/lib/rubocop/cop/chef/deprecation/resource_uses_only_resource_name.rb +3 -3
- data/lib/rubocop/cop/chef/deprecation/ruby_27_keyword_argument_warnings.rb +6 -10
- data/lib/rubocop/cop/chef/effortless/node_environment.rb +1 -1
- data/lib/rubocop/cop/chef/effortless/node_roles.rb +3 -3
- data/lib/rubocop/cop/chef/modernize/action_method_in_resource.rb +57 -0
- data/lib/rubocop/cop/chef/modernize/allowed_actions_initializer.rb +2 -2
- data/lib/rubocop/cop/chef/modernize/cron_d_file_or_template.rb +88 -0
- data/lib/rubocop/cop/chef/modernize/default_action_initializer.rb +3 -3
- data/lib/rubocop/cop/chef/modernize/definitions.rb +1 -1
- data/lib/rubocop/cop/chef/modernize/provides_initializer.rb +3 -3
- data/lib/rubocop/cop/chef/modernize/resource_name_initializer.rb +2 -2
- data/lib/rubocop/cop/chef/modernize/use_multipackage_installs.rb +3 -3
- data/lib/rubocop/cop/chef/redundant/double_compile_time.rb +65 -0
- data/lib/rubocop/cop/chef/redundant/ohai_attribute_to_string.rb +3 -3
- data/lib/rubocop/cop/chef/sharing/empty_metadata_field.rb +1 -1
- data/lib/rubocop/cop/chef/sharing/include_property_descriptions.rb +5 -5
- data/lib/rubocop/cop/chef/sharing/include_resource_descriptions.rb +3 -3
- data/lib/rubocop/cop/chef/sharing/include_resource_examples.rb +2 -2
- data/lib/rubocop/cop/chef/style/file_mode.rb +38 -19
- data/lib/rubocop/cop/chef/style/unnecessary_platform_case_statement.rb +1 -1
- data/lib/rubocop/monkey_patches/{cop.rb → base.rb} +1 -1
- metadata +13 -6
@@ -19,7 +19,7 @@ module RuboCop
|
|
19
19
|
module Cop
|
20
20
|
module Chef
|
21
21
|
module ChefSharing
|
22
|
-
# Resources should include description fields to allow automated
|
22
|
+
# Resources should include description fields to allow automated documentation. Requires Chef Infra Client 13.9 or later.
|
23
23
|
#
|
24
24
|
# @example
|
25
25
|
#
|
@@ -33,7 +33,7 @@ module RuboCop
|
|
33
33
|
|
34
34
|
minimum_target_chef_version '13.9'
|
35
35
|
|
36
|
-
MSG = 'Resources should include description fields to allow automated
|
36
|
+
MSG = 'Resources should include description fields to allow automated documentation. Requires Chef Infra Client 13.9 or later.'
|
37
37
|
|
38
38
|
def investigate(processed_source)
|
39
39
|
return if processed_source.blank?
|
@@ -44,7 +44,7 @@ module RuboCop
|
|
44
44
|
add_offense(nil, location: range, message: MSG, severity: :refactor) unless resource_description(processed_source.ast).any?
|
45
45
|
end
|
46
46
|
|
47
|
-
def_node_search :resource_description, '(send nil? :description
|
47
|
+
def_node_search :resource_description, '(send nil? :description ...)'
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
@@ -19,7 +19,7 @@ module RuboCop
|
|
19
19
|
module Cop
|
20
20
|
module Chef
|
21
21
|
module ChefSharing
|
22
|
-
# Resources should include examples field to allow automated
|
22
|
+
# Resources should include examples field to allow automated documentation. Requires Chef Infra Client 13.9 or later.
|
23
23
|
#
|
24
24
|
# @example
|
25
25
|
#
|
@@ -41,7 +41,7 @@ module RuboCop
|
|
41
41
|
|
42
42
|
minimum_target_chef_version '13.9'
|
43
43
|
|
44
|
-
MSG = 'Resources should include examples field to allow automated
|
44
|
+
MSG = 'Resources should include examples field to allow automated documentation. Requires Chef Infra Client 13.9 or later.'
|
45
45
|
|
46
46
|
def investigate(processed_source)
|
47
47
|
return if processed_source.blank?
|
@@ -19,39 +19,58 @@ module RuboCop
|
|
19
19
|
module Cop
|
20
20
|
module Chef
|
21
21
|
module ChefStyle
|
22
|
-
#
|
22
|
+
# Use strings to represent file modes to avoid confusion between octal and base 10 integer formats.
|
23
23
|
#
|
24
24
|
# @example
|
25
25
|
#
|
26
26
|
# # bad
|
27
|
-
#
|
28
|
-
#
|
27
|
+
# remote_directory '/etc/my.conf' do
|
28
|
+
# content 'some content'
|
29
|
+
# mode 0600
|
30
|
+
# action :create
|
31
|
+
# end
|
32
|
+
#
|
33
|
+
# remote_directory 'handler' do
|
34
|
+
# source 'handlers'
|
35
|
+
# recursive true
|
36
|
+
# files_mode 644
|
37
|
+
# action :create
|
38
|
+
# end
|
29
39
|
#
|
30
40
|
# # good
|
31
|
-
#
|
41
|
+
# remote_directory '/etc/my.conf' do
|
42
|
+
# content 'some content'
|
43
|
+
# mode '600'
|
44
|
+
# action :create
|
45
|
+
# end
|
46
|
+
#
|
47
|
+
# remote_directory 'handler' do
|
48
|
+
# source 'handlers'
|
49
|
+
# recursive true
|
50
|
+
# files_mode '644'
|
51
|
+
# action :create
|
52
|
+
# end
|
32
53
|
#
|
33
|
-
class FileMode <
|
34
|
-
|
54
|
+
class FileMode < Base
|
55
|
+
extend RuboCop::Cop::AutoCorrector
|
56
|
+
|
57
|
+
MSG = 'Use strings to represent file modes to avoid confusion between octal and base 10 integer formats'
|
35
58
|
|
36
59
|
def_node_matcher :resource_mode?, <<-PATTERN
|
37
|
-
(send nil? :mode $int)
|
60
|
+
(send nil? {:mode :files_mode} $int)
|
38
61
|
PATTERN
|
39
62
|
|
40
63
|
def on_send(node)
|
41
64
|
resource_mode?(node) do |mode_int|
|
42
|
-
add_offense(mode_int
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
def autocorrect(node)
|
47
|
-
lambda do |corrector|
|
48
|
-
# If it was an octal literal, make sure we write out the right number.
|
49
|
-
replacement_base = octal?(node) ? 8 : 10
|
50
|
-
replacement_mode = node.children.first.to_s(replacement_base)
|
65
|
+
add_offense(mode_int.loc.expression, message: MSG, severity: :refactor) do |corrector|
|
66
|
+
# If it was an octal literal, make sure we write out the right number.
|
67
|
+
replacement_base = octal?(mode_int) ? 8 : 10
|
68
|
+
replacement_mode = mode_int.children.first.to_s(replacement_base)
|
51
69
|
|
52
|
-
|
53
|
-
|
54
|
-
|
70
|
+
# we build our own escaped string instead of using .inspect because that way
|
71
|
+
# we can use single quotes instead of the double quotes that .inspect adds
|
72
|
+
corrector.replace(mode_int.loc.expression, "\'#{replacement_mode}\'")
|
73
|
+
end
|
55
74
|
end
|
56
75
|
end
|
57
76
|
|
@@ -67,7 +67,7 @@ module RuboCop
|
|
67
67
|
condition_string = node.when_branches.first.conditions.map(&:source).join(', ')
|
68
68
|
|
69
69
|
# single line bodies without an else statement should be transformed into `X if platform?('ubuntu')` style statements
|
70
|
-
# while
|
70
|
+
# while multi-line statements should just have the case and when bits replace with `if platform?('ubuntu')`
|
71
71
|
if !node.else? && !node.when_branches.first.body.multiline?
|
72
72
|
new_source = "#{node.when_branches.first.body.source} if #{type.value}?(#{condition_string})"
|
73
73
|
corrector.replace(node.loc.expression, new_source)
|
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.15.9
|
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-08-24 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.89.1
|
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.89.1
|
28
28
|
description:
|
29
29
|
email:
|
30
30
|
- thom@chef.io
|
@@ -56,6 +56,7 @@ files:
|
|
56
56
|
- lib/rubocop/cop/chef/correctness/conditional_ruby_shellout.rb
|
57
57
|
- lib/rubocop/cop/chef/correctness/dnf_package_allow_downgrades.rb
|
58
58
|
- lib/rubocop/cop/chef/correctness/incorrect_library_injection.rb
|
59
|
+
- lib/rubocop/cop/chef/correctness/invalid_default_action.rb
|
59
60
|
- lib/rubocop/cop/chef/correctness/invalid_notification_timing.rb
|
60
61
|
- lib/rubocop/cop/chef/correctness/invalid_platform_family_helper.rb
|
61
62
|
- lib/rubocop/cop/chef/correctness/invalid_platform_family_values_in_case.rb
|
@@ -66,6 +67,7 @@ files:
|
|
66
67
|
- lib/rubocop/cop/chef/correctness/invalid_value_for_platform_helper.rb
|
67
68
|
- lib/rubocop/cop/chef/correctness/invalid_version_metadata.rb
|
68
69
|
- lib/rubocop/cop/chef/correctness/lazy_eval_node_attribute_defaults.rb
|
70
|
+
- lib/rubocop/cop/chef/correctness/macos_userdefaults_invalid_type.rb
|
69
71
|
- lib/rubocop/cop/chef/correctness/malformed_value_for_platform.rb
|
70
72
|
- lib/rubocop/cop/chef/correctness/metadata_missing_name.rb
|
71
73
|
- lib/rubocop/cop/chef/correctness/node_normal.rb
|
@@ -79,6 +81,7 @@ files:
|
|
79
81
|
- lib/rubocop/cop/chef/correctness/resource_with_none_action.rb
|
80
82
|
- lib/rubocop/cop/chef/correctness/scoped_file_exist.rb
|
81
83
|
- lib/rubocop/cop/chef/correctness/service_resource.rb
|
84
|
+
- lib/rubocop/cop/chef/correctness/supports_must_be_float.rb
|
82
85
|
- lib/rubocop/cop/chef/correctness/tmp_path.rb
|
83
86
|
- lib/rubocop/cop/chef/deprecation/ use_automatic_resource_name.rb
|
84
87
|
- lib/rubocop/cop/chef/deprecation/chef_handler_recipe.rb
|
@@ -111,6 +114,7 @@ files:
|
|
111
114
|
- lib/rubocop/cop/chef/deprecation/legacy_yum_cookbook_recipes.rb
|
112
115
|
- lib/rubocop/cop/chef/deprecation/locale_lc_all_property.rb
|
113
116
|
- lib/rubocop/cop/chef/deprecation/log_resource_notifications.rb
|
117
|
+
- lib/rubocop/cop/chef/deprecation/macos_userdefaults_global_property.rb
|
114
118
|
- lib/rubocop/cop/chef/deprecation/name_property_and_default.rb
|
115
119
|
- lib/rubocop/cop/chef/deprecation/node_deep_fetch.rb
|
116
120
|
- lib/rubocop/cop/chef/deprecation/node_methods_not_attributes.rb
|
@@ -146,6 +150,7 @@ files:
|
|
146
150
|
- lib/rubocop/cop/chef/effortless/node_roles.rb
|
147
151
|
- lib/rubocop/cop/chef/effortless/search_for_environments_or_roles.rb
|
148
152
|
- lib/rubocop/cop/chef/effortless/search_used.rb
|
153
|
+
- lib/rubocop/cop/chef/modernize/action_method_in_resource.rb
|
149
154
|
- lib/rubocop/cop/chef/modernize/allowed_actions_initializer.rb
|
150
155
|
- lib/rubocop/cop/chef/modernize/apt_default_recipe.rb
|
151
156
|
- lib/rubocop/cop/chef/modernize/berksfile_source.rb
|
@@ -154,6 +159,7 @@ files:
|
|
154
159
|
- lib/rubocop/cop/chef/modernize/chef_gem_nokogiri.rb
|
155
160
|
- lib/rubocop/cop/chef/modernize/compile_time_resources.rb
|
156
161
|
- lib/rubocop/cop/chef/modernize/conditional_using_test.rb
|
162
|
+
- lib/rubocop/cop/chef/modernize/cron_d_file_or_template.rb
|
157
163
|
- lib/rubocop/cop/chef/modernize/cron_manage_resource.rb
|
158
164
|
- lib/rubocop/cop/chef/modernize/databag_helpers.rb
|
159
165
|
- lib/rubocop/cop/chef/modernize/default_action_initializer.rb
|
@@ -212,6 +218,7 @@ files:
|
|
212
218
|
- lib/rubocop/cop/chef/redundant/attribute_metadata.rb
|
213
219
|
- lib/rubocop/cop/chef/redundant/conflicts_metadata.rb
|
214
220
|
- lib/rubocop/cop/chef/redundant/custom_resource_with_allowed_actions.rb
|
221
|
+
- lib/rubocop/cop/chef/redundant/double_compile_time.rb
|
215
222
|
- lib/rubocop/cop/chef/redundant/grouping_metadata.rb
|
216
223
|
- lib/rubocop/cop/chef/redundant/long_description_metadata.rb
|
217
224
|
- lib/rubocop/cop/chef/redundant/multiple_platform_checks.rb
|
@@ -253,12 +260,12 @@ files:
|
|
253
260
|
- lib/rubocop/cop/chef/style/unnecessary_platform_case_statement.rb
|
254
261
|
- lib/rubocop/cop/chef/style/use_platform_helpers.rb
|
255
262
|
- lib/rubocop/cop/target_chef_version.rb
|
263
|
+
- lib/rubocop/monkey_patches/base.rb
|
256
264
|
- lib/rubocop/monkey_patches/comment_config.rb
|
257
265
|
- lib/rubocop/monkey_patches/config.rb
|
258
|
-
- lib/rubocop/monkey_patches/cop.rb
|
259
266
|
- lib/rubocop/monkey_patches/registry_cop.rb
|
260
267
|
- lib/rubocop/monkey_patches/team.rb
|
261
|
-
homepage:
|
268
|
+
homepage: https://docs.chef.io/workstation/cookstyle/
|
262
269
|
licenses:
|
263
270
|
- Apache-2.0
|
264
271
|
metadata:
|