cookstyle 7.0.0 → 7.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/config/cookstyle.yml +21 -0
- data/config/disable_all.yml +6 -0
- data/config/upstream.yml +31 -5
- data/lib/cookstyle/version.rb +2 -2
- data/lib/rubocop/cop/chef/deprecation/foodcritic_testing.rb +43 -0
- data/lib/rubocop/cop/chef/deprecation/librarian_chefspec.rb +42 -0
- data/lib/rubocop/cop/chef/modernize/use_multipackage_installs.rb +16 -12
- metadata +6 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 662226d3c6dc1e7ba00c89296274f8a46f04c7012abc658b0dd85b65e4d47126
|
|
4
|
+
data.tar.gz: a814e8b4190084045c668e3c82b8616640e593121046f4da0095373c614bf77c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3e56b4d1cd6fe22d917798beb027bdfd22a8b61d1e1ff55f6183707af0cabc80ba04fba87ae4e26bc5baae8d5c9603dcd39ddb48c8bfda1bbfb0419ca78fb3a6
|
|
7
|
+
data.tar.gz: a2c799f5706fc3ba55acbc2733392a4a162eec03199fab91c26ce8609cee96bcdd8d865ddd5f3361e1aed07e0ebeba82b5b42113d30a678c2dd073c6cccbf7df
|
data/config/cookstyle.yml
CHANGED
|
@@ -1137,6 +1137,23 @@ Chef/Deprecations/UseYamlDump:
|
|
|
1137
1137
|
Enabled: true
|
|
1138
1138
|
VersionAdded: '6.21.0'
|
|
1139
1139
|
|
|
1140
|
+
Chef/Deprecations/LibrarianChefSpec:
|
|
1141
|
+
Description: The Librarian-Chef depsolving project is no longer maintained and ChefSpec should not use Librarian-Chef for cookbook depsolving. Consider using Policyfiles instead.
|
|
1142
|
+
StyleGuide: '#chefdeprecationslibrarianchefspec'
|
|
1143
|
+
Enabled: true
|
|
1144
|
+
VersionAdded: '7.1.0'
|
|
1145
|
+
Include:
|
|
1146
|
+
- '**/specs/*.rb'
|
|
1147
|
+
|
|
1148
|
+
Chef/Deprecations/FoodcriticTesting:
|
|
1149
|
+
Description: The Foodcritic cookbook linter has been deprecated and should no longer be used for validating cookbooks
|
|
1150
|
+
StyleGuide: '#chefdeprecationsfoodcritictesting'
|
|
1151
|
+
Enabled: true
|
|
1152
|
+
VersionAdded: '7.1.0'
|
|
1153
|
+
Include:
|
|
1154
|
+
- '**/Rakefile'
|
|
1155
|
+
- '**/Gemfile'
|
|
1156
|
+
|
|
1140
1157
|
###############################
|
|
1141
1158
|
# Chef/Modernize: Cleaning up legacy code and using new built-in resources
|
|
1142
1159
|
###############################
|
|
@@ -2746,4 +2763,8 @@ Style/ExpandPathArguments:
|
|
|
2746
2763
|
|
|
2747
2764
|
# Avoid a safe navigation operator if we don't need it
|
|
2748
2765
|
Lint/RedundantSafeNavigation:
|
|
2766
|
+
Enabled: true
|
|
2767
|
+
|
|
2768
|
+
# Avoid using blocks to remove nils from a Hash/Array
|
|
2769
|
+
Style/CollectionCompact:
|
|
2749
2770
|
Enabled: true
|
data/config/disable_all.yml
CHANGED
|
@@ -307,6 +307,8 @@ Lint/NestedPercentLiteral:
|
|
|
307
307
|
Enabled: false
|
|
308
308
|
Lint/NextWithoutAccumulator:
|
|
309
309
|
Enabled: false
|
|
310
|
+
Lint/NoReturnInBeginEndBlocks:
|
|
311
|
+
Enabled: false
|
|
310
312
|
Lint/NonDeterministicRequireOrder:
|
|
311
313
|
Enabled: false
|
|
312
314
|
Lint/NonLocalExitFromIterator:
|
|
@@ -515,6 +517,8 @@ Style/ClassMethodsDefinitions:
|
|
|
515
517
|
Enabled: false
|
|
516
518
|
Style/ClassVars:
|
|
517
519
|
Enabled: false
|
|
520
|
+
Style/CollectionCompact:
|
|
521
|
+
Enabled: false
|
|
518
522
|
Style/CollectionMethods:
|
|
519
523
|
Enabled: false
|
|
520
524
|
Style/ColonMethodCall:
|
|
@@ -689,6 +693,8 @@ Style/MutableConstant:
|
|
|
689
693
|
Enabled: false
|
|
690
694
|
Style/NegatedIf:
|
|
691
695
|
Enabled: false
|
|
696
|
+
Style/NegatedIfElseCondition:
|
|
697
|
+
Enabled: false
|
|
692
698
|
Style/NegatedUnless:
|
|
693
699
|
Enabled: false
|
|
694
700
|
Style/NegatedWhile:
|
data/config/upstream.yml
CHANGED
|
@@ -1478,6 +1478,7 @@ Lint/ElseLayout:
|
|
|
1478
1478
|
Description: 'Check for odd code arrangement in an else block.'
|
|
1479
1479
|
Enabled: true
|
|
1480
1480
|
VersionAdded: '0.17'
|
|
1481
|
+
VersionChanged: '1.2'
|
|
1481
1482
|
|
|
1482
1483
|
Lint/EmptyBlock:
|
|
1483
1484
|
Description: 'This cop checks for blocks without a body.'
|
|
@@ -1679,6 +1680,11 @@ Lint/NextWithoutAccumulator:
|
|
|
1679
1680
|
Enabled: true
|
|
1680
1681
|
VersionAdded: '0.36'
|
|
1681
1682
|
|
|
1683
|
+
Lint/NoReturnInBeginEndBlocks:
|
|
1684
|
+
Description: 'Do not `return` inside `begin..end` blocks in assignment contexts.'
|
|
1685
|
+
Enabled: pending
|
|
1686
|
+
VersionAdded: '1.2'
|
|
1687
|
+
|
|
1682
1688
|
Lint/NonDeterministicRequireOrder:
|
|
1683
1689
|
Description: 'Always sort arrays returned by Dir.glob when requiring files.'
|
|
1684
1690
|
Enabled: true
|
|
@@ -2036,8 +2042,9 @@ Lint/UselessMethodDefinition:
|
|
|
2036
2042
|
Lint/UselessSetterCall:
|
|
2037
2043
|
Description: 'Checks for useless setter call to a local variable.'
|
|
2038
2044
|
Enabled: true
|
|
2045
|
+
SafeAutoCorrect: false
|
|
2039
2046
|
VersionAdded: '0.13'
|
|
2040
|
-
VersionChanged: '
|
|
2047
|
+
VersionChanged: '1.2'
|
|
2041
2048
|
Safe: false
|
|
2042
2049
|
|
|
2043
2050
|
Lint/UselessTimes:
|
|
@@ -2181,6 +2188,7 @@ Naming/BinaryOperatorParameterName:
|
|
|
2181
2188
|
StyleGuide: '#other-arg'
|
|
2182
2189
|
Enabled: true
|
|
2183
2190
|
VersionAdded: '0.50'
|
|
2191
|
+
VersionChanged: '1.2'
|
|
2184
2192
|
|
|
2185
2193
|
Naming/BlockParameterName:
|
|
2186
2194
|
Description: >-
|
|
@@ -2287,6 +2295,7 @@ Naming/HeredocDelimiterCase:
|
|
|
2287
2295
|
StyleGuide: '#heredoc-delimiters'
|
|
2288
2296
|
Enabled: true
|
|
2289
2297
|
VersionAdded: '0.50'
|
|
2298
|
+
VersionChanged: '1.2'
|
|
2290
2299
|
EnforcedStyle: uppercase
|
|
2291
2300
|
SupportedStyles:
|
|
2292
2301
|
- lowercase
|
|
@@ -2305,7 +2314,7 @@ Naming/MemoizedInstanceVariableName:
|
|
|
2305
2314
|
Memoized method name should match memo instance variable name.
|
|
2306
2315
|
Enabled: true
|
|
2307
2316
|
VersionAdded: '0.53'
|
|
2308
|
-
VersionChanged: '
|
|
2317
|
+
VersionChanged: '1.2'
|
|
2309
2318
|
EnforcedStyleForLeadingUnderscores: disallowed
|
|
2310
2319
|
SupportedStylesForLeadingUnderscores:
|
|
2311
2320
|
- disallowed
|
|
@@ -2403,14 +2412,18 @@ Naming/VariableName:
|
|
|
2403
2412
|
- camelCase
|
|
2404
2413
|
|
|
2405
2414
|
Naming/VariableNumber:
|
|
2406
|
-
Description: 'Use the configured style when numbering variables.'
|
|
2415
|
+
Description: 'Use the configured style when numbering symbols, methods and variables.'
|
|
2416
|
+
StyleGuide: '#snake-case-symbols-methods-vars-with-numbers'
|
|
2407
2417
|
Enabled: true
|
|
2408
2418
|
VersionAdded: '0.50'
|
|
2419
|
+
VersionChanged: '1.2'
|
|
2409
2420
|
EnforcedStyle: normalcase
|
|
2410
2421
|
SupportedStyles:
|
|
2411
2422
|
- snake_case
|
|
2412
2423
|
- normalcase
|
|
2413
2424
|
- non_integer
|
|
2425
|
+
CheckMethodNames: true
|
|
2426
|
+
CheckSymbols: true
|
|
2414
2427
|
|
|
2415
2428
|
#################### Security ##############################
|
|
2416
2429
|
|
|
@@ -2789,6 +2802,11 @@ Style/ClassVars:
|
|
|
2789
2802
|
Enabled: true
|
|
2790
2803
|
VersionAdded: '0.13'
|
|
2791
2804
|
|
|
2805
|
+
Style/CollectionCompact:
|
|
2806
|
+
Description: 'Use `{Array,Hash}#{compact,compact!}` instead of custom logic to reject nils.'
|
|
2807
|
+
Enabled: pending
|
|
2808
|
+
VersionAdded: '1.2'
|
|
2809
|
+
|
|
2792
2810
|
# Align with the style guide.
|
|
2793
2811
|
Style/CollectionMethods:
|
|
2794
2812
|
Description: 'Preferred collection methods.'
|
|
@@ -2986,7 +3004,7 @@ Style/DoubleNegation:
|
|
|
2986
3004
|
StyleGuide: '#no-bang-bang'
|
|
2987
3005
|
Enabled: true
|
|
2988
3006
|
VersionAdded: '0.19'
|
|
2989
|
-
VersionChanged: '
|
|
3007
|
+
VersionChanged: '1.2'
|
|
2990
3008
|
EnforcedStyle: allowed_in_returns
|
|
2991
3009
|
SafeAutoCorrect: false
|
|
2992
3010
|
SupportedStyles:
|
|
@@ -3611,6 +3629,13 @@ Style/NegatedIf:
|
|
|
3611
3629
|
- prefix
|
|
3612
3630
|
- postfix
|
|
3613
3631
|
|
|
3632
|
+
Style/NegatedIfElseCondition:
|
|
3633
|
+
Description: >-
|
|
3634
|
+
This cop checks for uses of `if-else` and ternary operators with a negated condition
|
|
3635
|
+
which can be simplified by inverting condition and swapping branches.
|
|
3636
|
+
Enabled: pending
|
|
3637
|
+
VersionAdded: '1.2'
|
|
3638
|
+
|
|
3614
3639
|
Style/NegatedUnless:
|
|
3615
3640
|
Description: 'Favor if over unless for negative conditions.'
|
|
3616
3641
|
StyleGuide: '#if-for-negatives'
|
|
@@ -3888,11 +3913,12 @@ Style/RaiseArgs:
|
|
|
3888
3913
|
StyleGuide: '#exception-class-messages'
|
|
3889
3914
|
Enabled: true
|
|
3890
3915
|
VersionAdded: '0.14'
|
|
3891
|
-
VersionChanged: '
|
|
3916
|
+
VersionChanged: '1.2'
|
|
3892
3917
|
EnforcedStyle: exploded
|
|
3893
3918
|
SupportedStyles:
|
|
3894
3919
|
- compact # raise Exception.new(msg)
|
|
3895
3920
|
- exploded # raise Exception, msg
|
|
3921
|
+
AllowedCompactTypes: []
|
|
3896
3922
|
|
|
3897
3923
|
Style/RandomWithOffset:
|
|
3898
3924
|
Description: >-
|
data/lib/cookstyle/version.rb
CHANGED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
#
|
|
3
|
+
# Copyright:: 2020, Chef Software, Inc.
|
|
4
|
+
# Author:: Tim Smith (<tsmith@chef.io>)
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
#
|
|
18
|
+
module RuboCop
|
|
19
|
+
module Cop
|
|
20
|
+
module Chef
|
|
21
|
+
module Deprecations
|
|
22
|
+
# The Foodcritic cookbook linter has been deprecated and should no longer be used for validating cookbooks.
|
|
23
|
+
#
|
|
24
|
+
# @example
|
|
25
|
+
#
|
|
26
|
+
# # bad
|
|
27
|
+
# gem 'foodcritic'
|
|
28
|
+
# require 'foodcritic'
|
|
29
|
+
#
|
|
30
|
+
class FoodcriticTesting < Base
|
|
31
|
+
MSG = 'The Foodcritic cookbook linter has been deprecated and should no longer be used for validating cookbooks.'
|
|
32
|
+
RESTRICT_ON_SEND = [:require, :gem].freeze
|
|
33
|
+
|
|
34
|
+
def on_send(node)
|
|
35
|
+
return unless node.arguments.first == s(:str, 'foodcritic')
|
|
36
|
+
|
|
37
|
+
add_offense(node, message: MSG, severity: :warning)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
#
|
|
3
|
+
# Copyright:: 2020, Chef Software, Inc.
|
|
4
|
+
# Author:: Tim Smith (<tsmith@chef.io>)
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
#
|
|
18
|
+
module RuboCop
|
|
19
|
+
module Cop
|
|
20
|
+
module Chef
|
|
21
|
+
module Deprecations
|
|
22
|
+
# The Librarian-Chef depsolving project is no longer maintained and a Cheffile should not be used for cookbook depsolving. Consider using Policyfiles instead.
|
|
23
|
+
#
|
|
24
|
+
# @example
|
|
25
|
+
#
|
|
26
|
+
# # bad
|
|
27
|
+
# require 'chefspec/librarian'
|
|
28
|
+
#
|
|
29
|
+
class LibrarianChefSpec < Base
|
|
30
|
+
MSG = 'The Librarian-Chef depsolving project is no longer maintained and ChefSpec should not use Librarian-Chef for cookbook depsolving. Consider using Policyfiles instead.'
|
|
31
|
+
RESTRICT_ON_SEND = [:require].freeze
|
|
32
|
+
|
|
33
|
+
def on_send(node)
|
|
34
|
+
return unless node.arguments.first == s(:str, 'chefspec/librarian')
|
|
35
|
+
|
|
36
|
+
add_offense(node, message: MSG, severity: :warning)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -60,8 +60,8 @@ module RuboCop
|
|
|
60
60
|
(lvar _))}) nil?)
|
|
61
61
|
PATTERN
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
(block
|
|
63
|
+
def_node_search :package_array_install, <<-PATTERN
|
|
64
|
+
$(block
|
|
65
65
|
(send
|
|
66
66
|
$(array ... ) :each)
|
|
67
67
|
(args ... )
|
|
@@ -78,27 +78,31 @@ module RuboCop
|
|
|
78
78
|
# see if all platforms in the when condition are multi-package compliant
|
|
79
79
|
def multipackage_platforms?(condition_obj)
|
|
80
80
|
condition_obj.all? do |p|
|
|
81
|
-
|
|
81
|
+
# make sure it's a string (not a regex) and it's in the array
|
|
82
|
+
p.str_type? && MULTIPACKAGE_PLATS.include?(p.value)
|
|
82
83
|
end
|
|
83
84
|
end
|
|
84
85
|
|
|
85
86
|
def on_when(node)
|
|
86
87
|
return unless platform_or_platform_family?(node.parent.condition) &&
|
|
87
|
-
package_array_install?(node.body) &&
|
|
88
88
|
multipackage_platforms?(node.conditions)
|
|
89
|
-
|
|
89
|
+
return if node.body.nil? # don't blow up on empty whens
|
|
90
|
+
|
|
91
|
+
package_array_install(node.body) do |install_block, pkgs|
|
|
92
|
+
add_offense(install_block, message: MSG, severity: :refactor) do |corrector|
|
|
93
|
+
corrector.replace(install_block, "package #{pkgs.source}")
|
|
94
|
+
end
|
|
95
|
+
end
|
|
90
96
|
end
|
|
91
97
|
|
|
92
98
|
def on_if(node)
|
|
93
99
|
platform_helper?(node) do |plats, blk, _pkgs|
|
|
94
|
-
|
|
95
|
-
end
|
|
96
|
-
end
|
|
100
|
+
return unless multipackage_platforms?(plats)
|
|
97
101
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
+
add_offense(blk, message: MSG, severity: :refactor) do |corrector|
|
|
103
|
+
package_array_install(blk) do |install_block, pkgs|
|
|
104
|
+
corrector.replace(install_block, "package #{pkgs.source}")
|
|
105
|
+
end
|
|
102
106
|
end
|
|
103
107
|
end
|
|
104
108
|
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: 7.
|
|
4
|
+
version: 7.1.2
|
|
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-11-05 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: 1.
|
|
20
|
+
version: 1.2.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: 1.
|
|
27
|
+
version: 1.2.0
|
|
28
28
|
description:
|
|
29
29
|
email:
|
|
30
30
|
- thom@chef.io
|
|
@@ -113,11 +113,13 @@ files:
|
|
|
113
113
|
- lib/rubocop/cop/chef/deprecation/erl_call.rb
|
|
114
114
|
- lib/rubocop/cop/chef/deprecation/execute_path_property.rb
|
|
115
115
|
- lib/rubocop/cop/chef/deprecation/execute_relative_creates_without_cwd.rb
|
|
116
|
+
- lib/rubocop/cop/chef/deprecation/foodcritic_testing.rb
|
|
116
117
|
- lib/rubocop/cop/chef/deprecation/hwrp_without_provides.rb
|
|
117
118
|
- lib/rubocop/cop/chef/deprecation/inherits_compat_resource.rb
|
|
118
119
|
- lib/rubocop/cop/chef/deprecation/launchd_deprecated_hash_property.rb
|
|
119
120
|
- lib/rubocop/cop/chef/deprecation/legacy_notify_syntax.rb
|
|
120
121
|
- lib/rubocop/cop/chef/deprecation/legacy_yum_cookbook_recipes.rb
|
|
122
|
+
- lib/rubocop/cop/chef/deprecation/librarian_chefspec.rb
|
|
121
123
|
- lib/rubocop/cop/chef/deprecation/locale_lc_all_property.rb
|
|
122
124
|
- lib/rubocop/cop/chef/deprecation/log_resource_notifications.rb
|
|
123
125
|
- lib/rubocop/cop/chef/deprecation/macos_userdefaults_global_property.rb
|