cookstyle 6.2.9 → 6.3.4
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 +19 -2
- data/config/disable_all.yml +8 -2
- data/config/upstream.yml +59 -13
- data/lib/cookstyle/version.rb +2 -2
- data/lib/rubocop/cop/chef/deprecation/deprecated_shellout_methods.rb +65 -0
- 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
- 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: 7a9b1ee43fdd2c9baa768f2cdbd18592bea73293b26ce1ef76ddc4e3cb1827a3
|
|
4
|
+
data.tar.gz: 87d8aff860e98ef48aa935345091bd66586b712e52e3b2ed767ba5aededffe6b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d31f92b56384f5fe012ea3fb39a154b30cc2d02dda3226d4fd2f856de4511efba3e52736886345dfacace945c4c02f74e3f8468537b00d233f7f5180c1553bd0
|
|
7
|
+
data.tar.gz: 70c9b88f541824fcd23aafb7bfd4ea9a8ad2d4500d201b65910e0055f538f7a9cdca2c7d8998b06e4cb6a06f865d2d19b93d8edf4c659527335d06b26a84430b
|
data/config/cookstyle.yml
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
AllCops:
|
|
2
|
-
TargetRubyVersion: 2.
|
|
2
|
+
TargetRubyVersion: 2.4
|
|
3
3
|
TargetChefVersion: ~
|
|
4
4
|
Exclude:
|
|
5
5
|
- '**/files/**/*'
|
|
@@ -825,6 +825,15 @@ ChefDeprecations/PowershellCookbookHelpers:
|
|
|
825
825
|
- '**/metadata.rb'
|
|
826
826
|
- '**/Berksfile'
|
|
827
827
|
|
|
828
|
+
ChefDeprecations/DeprecatedShelloutMethods:
|
|
829
|
+
Description: Many legacy specialized shell_out methods were replaced in Chef Infra Client 14.3 and removed in Chef Infra Client 15. Use shell_out and any additional options if necessary.
|
|
830
|
+
Enabled: true
|
|
831
|
+
VersionAdded: '6.3.0'
|
|
832
|
+
Exclude:
|
|
833
|
+
- '**/metadata.rb'
|
|
834
|
+
- '**/attributes/*.rb'
|
|
835
|
+
- '**/Berksfile'
|
|
836
|
+
|
|
828
837
|
###############################
|
|
829
838
|
# ChefModernize: Cleaning up legacy code and using new built-in resources
|
|
830
839
|
###############################
|
|
@@ -1276,6 +1285,14 @@ ChefModernize/NodeRolesInclude:
|
|
|
1276
1285
|
- '**/metadata.rb'
|
|
1277
1286
|
- '**/Berksfile'
|
|
1278
1287
|
|
|
1288
|
+
ChefModernize/RespondToCompileTime:
|
|
1289
|
+
Description: There is no need to check if the chef_gem resource supports compile_time as Chef Infra Client 12.1 and later support the compile_time property.
|
|
1290
|
+
Enabled: true
|
|
1291
|
+
VersionAdded: '6.3.0'
|
|
1292
|
+
Exclude:
|
|
1293
|
+
- '**/metadata.rb'
|
|
1294
|
+
- '**/Berksfile'
|
|
1295
|
+
|
|
1279
1296
|
###############################
|
|
1280
1297
|
# ChefRedundantCode: Cleanup unnecessary code in your cookbooks regardless of Chef Infra Client release
|
|
1281
1298
|
###############################
|
|
@@ -1768,7 +1785,7 @@ Style/StructInheritance:
|
|
|
1768
1785
|
Enabled: true
|
|
1769
1786
|
Style/SymbolLiteral:
|
|
1770
1787
|
Enabled: true
|
|
1771
|
-
Layout/
|
|
1788
|
+
Layout/IndentationStyle:
|
|
1772
1789
|
Enabled: true
|
|
1773
1790
|
Layout/TrailingBlankLines:
|
|
1774
1791
|
Enabled: true
|
data/config/disable_all.yml
CHANGED
|
@@ -103,6 +103,8 @@ Layout/HeredocIndentation:
|
|
|
103
103
|
Enabled: false
|
|
104
104
|
Layout/IndentationConsistency:
|
|
105
105
|
Enabled: false
|
|
106
|
+
Layout/IndentationStyle:
|
|
107
|
+
Enabled: false
|
|
106
108
|
Layout/IndentationWidth:
|
|
107
109
|
Enabled: false
|
|
108
110
|
Layout/InitialIndentation:
|
|
@@ -155,6 +157,8 @@ Layout/SpaceAroundEqualsInParameterDefault:
|
|
|
155
157
|
Enabled: false
|
|
156
158
|
Layout/SpaceAroundKeyword:
|
|
157
159
|
Enabled: false
|
|
160
|
+
Layout/SpaceAroundMethodCallOperator:
|
|
161
|
+
Enabled: false
|
|
158
162
|
Layout/SpaceAroundOperators:
|
|
159
163
|
Enabled: false
|
|
160
164
|
Layout/SpaceBeforeBlockBraces:
|
|
@@ -187,8 +191,6 @@ Layout/SpaceInsideReferenceBrackets:
|
|
|
187
191
|
Enabled: false
|
|
188
192
|
Layout/SpaceInsideStringInterpolation:
|
|
189
193
|
Enabled: false
|
|
190
|
-
Layout/Tab:
|
|
191
|
-
Enabled: false
|
|
192
194
|
Layout/TrailingEmptyLines:
|
|
193
195
|
Enabled: false
|
|
194
196
|
Layout/TrailingWhitespace:
|
|
@@ -467,6 +469,8 @@ Style/DefWithParentheses:
|
|
|
467
469
|
Enabled: false
|
|
468
470
|
Style/Dir:
|
|
469
471
|
Enabled: false
|
|
472
|
+
Style/DisableCopsWithinSourceCodeDirective:
|
|
473
|
+
Enabled: false
|
|
470
474
|
Style/DocumentationMethod:
|
|
471
475
|
Enabled: false
|
|
472
476
|
Style/Documentation:
|
|
@@ -501,6 +505,8 @@ Style/EvenOdd:
|
|
|
501
505
|
Enabled: false
|
|
502
506
|
Style/ExpandPathArguments:
|
|
503
507
|
Enabled: false
|
|
508
|
+
Style/ExponentialNotation:
|
|
509
|
+
Enabled: false
|
|
504
510
|
Style/FloatDivision:
|
|
505
511
|
Enabled: false
|
|
506
512
|
Style/For:
|
data/config/upstream.yml
CHANGED
|
@@ -97,6 +97,14 @@ AllCops:
|
|
|
97
97
|
# to true in the same configuration.
|
|
98
98
|
EnabledByDefault: false
|
|
99
99
|
DisabledByDefault: false
|
|
100
|
+
# New cops introduced between major versions are set to a special pending status
|
|
101
|
+
# and are not enabled by default with warning message.
|
|
102
|
+
# Change this behavior by overriding either `NewCops: enable` or `NewCops: disable`.
|
|
103
|
+
# When `NewCops` is `enable`, pending cops are enabled in bulk. Can be overridden by
|
|
104
|
+
# the `--enable-pending-cops` command-line option.
|
|
105
|
+
# When `NewCops` is `disable`, pending cops are disabled in bulk. Can be overridden by
|
|
106
|
+
# the `--disable-pending-cops` command-line option.
|
|
107
|
+
NewCops: pending
|
|
100
108
|
# Enables the result cache if `true`. Can be overridden by the `--cache` command
|
|
101
109
|
# line option.
|
|
102
110
|
UseCache: true
|
|
@@ -125,7 +133,7 @@ AllCops:
|
|
|
125
133
|
# followed by the Gemfile.lock or gems.locked file. (Although the Ruby version
|
|
126
134
|
# is specified in the Gemfile or gems.rb file, RuboCop reads the final value
|
|
127
135
|
# from the lock file.) If the Ruby version is still unresolved, RuboCop will
|
|
128
|
-
# use the oldest officially supported Ruby version (currently Ruby 2.
|
|
136
|
+
# use the oldest officially supported Ruby version (currently Ruby 2.4).
|
|
129
137
|
TargetRubyVersion: ~
|
|
130
138
|
|
|
131
139
|
#################### Bundler ###############################
|
|
@@ -793,6 +801,22 @@ Layout/IndentationConsistency:
|
|
|
793
801
|
# A reference to `EnforcedStyle: indented_internal_methods`.
|
|
794
802
|
- https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions
|
|
795
803
|
|
|
804
|
+
Layout/IndentationStyle:
|
|
805
|
+
Description: 'Consistent indentation either with tabs only or spaces only.'
|
|
806
|
+
StyleGuide: '#spaces-indentation'
|
|
807
|
+
Enabled: true
|
|
808
|
+
VersionAdded: '0.49'
|
|
809
|
+
VersionChanged: '0.82'
|
|
810
|
+
# By default, the indentation width from Layout/IndentationWidth is used
|
|
811
|
+
# But it can be overridden by setting this parameter
|
|
812
|
+
# It is used during auto-correction to determine how many spaces should
|
|
813
|
+
# replace each tab.
|
|
814
|
+
IndentationWidth: ~
|
|
815
|
+
EnforcedStyle: spaces
|
|
816
|
+
SupportedStyles:
|
|
817
|
+
- spaces
|
|
818
|
+
- tabs
|
|
819
|
+
|
|
796
820
|
Layout/IndentationWidth:
|
|
797
821
|
Description: 'Use 2 spaces for indentation.'
|
|
798
822
|
StyleGuide: '#spaces-indentation'
|
|
@@ -1080,6 +1104,11 @@ Layout/SpaceAroundKeyword:
|
|
|
1080
1104
|
Enabled: true
|
|
1081
1105
|
VersionAdded: '0.49'
|
|
1082
1106
|
|
|
1107
|
+
Layout/SpaceAroundMethodCallOperator:
|
|
1108
|
+
Description: 'Checks method call operators to not have spaces around them.'
|
|
1109
|
+
Enabled: pending
|
|
1110
|
+
VersionAdded: '0.82'
|
|
1111
|
+
|
|
1083
1112
|
Layout/SpaceAroundOperators:
|
|
1084
1113
|
Description: 'Use a single space around operators.'
|
|
1085
1114
|
StyleGuide: '#spaces-operators'
|
|
@@ -1250,18 +1279,6 @@ Layout/SpaceInsideStringInterpolation:
|
|
|
1250
1279
|
- space
|
|
1251
1280
|
- no_space
|
|
1252
1281
|
|
|
1253
|
-
Layout/Tab:
|
|
1254
|
-
Description: 'No hard tabs.'
|
|
1255
|
-
StyleGuide: '#spaces-indentation'
|
|
1256
|
-
Enabled: true
|
|
1257
|
-
VersionAdded: '0.49'
|
|
1258
|
-
VersionChanged: '0.51'
|
|
1259
|
-
# By default, the indentation width from Layout/IndentationWidth is used
|
|
1260
|
-
# But it can be overridden by setting this parameter
|
|
1261
|
-
# It is used during auto-correction to determine how many spaces should
|
|
1262
|
-
# replace each tab.
|
|
1263
|
-
IndentationWidth: ~
|
|
1264
|
-
|
|
1265
1282
|
Layout/TrailingEmptyLines:
|
|
1266
1283
|
Description: 'Checks trailing blank lines and final newline.'
|
|
1267
1284
|
StyleGuide: '#newline-eof'
|
|
@@ -1567,6 +1584,8 @@ Lint/RaiseException:
|
|
|
1567
1584
|
StyleGuide: '#raise-exception'
|
|
1568
1585
|
Enabled: pending
|
|
1569
1586
|
VersionAdded: '0.81'
|
|
1587
|
+
AllowedImplicitNamespaces:
|
|
1588
|
+
- 'Gem'
|
|
1570
1589
|
|
|
1571
1590
|
Lint/RandOne:
|
|
1572
1591
|
Description: >-
|
|
@@ -2409,6 +2428,15 @@ Style/CaseEquality:
|
|
|
2409
2428
|
StyleGuide: '#no-case-equality'
|
|
2410
2429
|
Enabled: true
|
|
2411
2430
|
VersionAdded: '0.9'
|
|
2431
|
+
# If AllowOnConstant is enabled, the cop will ignore violations when the receiver of
|
|
2432
|
+
# the case equality operator is a constant.
|
|
2433
|
+
#
|
|
2434
|
+
# # bad
|
|
2435
|
+
# /string/ === "string"
|
|
2436
|
+
#
|
|
2437
|
+
# # good
|
|
2438
|
+
# String === "string"
|
|
2439
|
+
AllowOnConstant: false
|
|
2412
2440
|
|
|
2413
2441
|
Style/CharacterLiteral:
|
|
2414
2442
|
Description: 'Checks for uses of character literals.'
|
|
@@ -2449,6 +2477,7 @@ Style/ClassAndModuleChildren:
|
|
|
2449
2477
|
|
|
2450
2478
|
Style/ClassCheck:
|
|
2451
2479
|
Description: 'Enforces consistent use of `Object#is_a?` or `Object#kind_of?`.'
|
|
2480
|
+
StyleGuide: '#is-a-vs-kind-of'
|
|
2452
2481
|
Enabled: true
|
|
2453
2482
|
VersionAdded: '0.24'
|
|
2454
2483
|
EnforcedStyle: is_a?
|
|
@@ -2616,6 +2645,12 @@ Style/Dir:
|
|
|
2616
2645
|
Enabled: true
|
|
2617
2646
|
VersionAdded: '0.50'
|
|
2618
2647
|
|
|
2648
|
+
Style/DisableCopsWithinSourceCodeDirective:
|
|
2649
|
+
Description: >-
|
|
2650
|
+
Forbids disabling/enabling cops within source code.
|
|
2651
|
+
Enabled: false
|
|
2652
|
+
VersionAdded: '0.82'
|
|
2653
|
+
|
|
2619
2654
|
Style/Documentation:
|
|
2620
2655
|
Description: 'Document classes and non-namespace modules.'
|
|
2621
2656
|
Enabled: true
|
|
@@ -2734,6 +2769,17 @@ Style/ExpandPathArguments:
|
|
|
2734
2769
|
Enabled: true
|
|
2735
2770
|
VersionAdded: '0.53'
|
|
2736
2771
|
|
|
2772
|
+
Style/ExponentialNotation:
|
|
2773
|
+
Description: 'When using exponential notation, favor a mantissa between 1 (inclusive) and 10 (exclusive).'
|
|
2774
|
+
StyleGuide: '#exponential-notation'
|
|
2775
|
+
Enabled: pending
|
|
2776
|
+
VersionAdded: '0.82'
|
|
2777
|
+
EnforcedStyle: scientific
|
|
2778
|
+
SupportedStyles:
|
|
2779
|
+
- scientific
|
|
2780
|
+
- engineering
|
|
2781
|
+
- integral
|
|
2782
|
+
|
|
2737
2783
|
Style/FloatDivision:
|
|
2738
2784
|
Description: 'For performing float division, coerce one side only.'
|
|
2739
2785
|
StyleGuide: '#float-division'
|
data/lib/cookstyle/version.rb
CHANGED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright:: 2020, 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 ChefDeprecations
|
|
22
|
+
# The large number of shell_out helper methods in Chef Infra Client has been reduced to just shell_out and shell_out! methods. The legacy methods were removed in Chef Infra Client and cookbooks using these legacy helpers will need to be updated.
|
|
23
|
+
#
|
|
24
|
+
# @example
|
|
25
|
+
#
|
|
26
|
+
# # bad
|
|
27
|
+
# shell_out_compact('foo')
|
|
28
|
+
# shell_out_compact!('foo')
|
|
29
|
+
# shell_out_with_timeout('foo')
|
|
30
|
+
# shell_out_with_timeout!('foo')
|
|
31
|
+
# shell_out_with_systems_locale('foo')
|
|
32
|
+
# shell_out_with_systems_locale!('foo')
|
|
33
|
+
# shell_out_compact_timeout('foo')
|
|
34
|
+
# shell_out_compact_timeout!('foo')
|
|
35
|
+
#
|
|
36
|
+
# # good
|
|
37
|
+
# shell_out('foo')
|
|
38
|
+
# shell_out!('foo')
|
|
39
|
+
# shell_out!('foo', default_env: false) # replaces shell_out_with_systems_locale
|
|
40
|
+
#
|
|
41
|
+
class DeprecatedShelloutMethods < Cop
|
|
42
|
+
extend TargetChefVersion
|
|
43
|
+
|
|
44
|
+
minimum_target_chef_version '14.3'
|
|
45
|
+
|
|
46
|
+
DEPRECATED_SHELLOUT_METHODS = %i( shell_out_compact
|
|
47
|
+
shell_out_compact!
|
|
48
|
+
shell_out_compact_timeout
|
|
49
|
+
shell_out_compact_timeout!
|
|
50
|
+
shell_out_with_timeout
|
|
51
|
+
shell_out_with_timeout!
|
|
52
|
+
shell_out_with_systems_locale
|
|
53
|
+
shell_out_with_systems_locale!
|
|
54
|
+
).freeze
|
|
55
|
+
|
|
56
|
+
MSG = 'Many legacy specialized shell_out methods were replaced in Chef Infra Client 14.3 and removed in Chef Infra Client 15. Use shell_out and any additional options if necessary.'.freeze
|
|
57
|
+
|
|
58
|
+
def on_send(node)
|
|
59
|
+
add_offense(node, location: :expression, message: MSG, severity: :warning) if DEPRECATED_SHELLOUT_METHODS.include?(node.method_name)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright:: 2020, 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
|
+
# There is no need to check if the chef_gem resource supports compile_time as Chef Infra Client 12.1 and later support the compile_time property.
|
|
22
|
+
#
|
|
23
|
+
# # bad
|
|
24
|
+
# chef_gem 'ultradns-sdk' do
|
|
25
|
+
# compile_time true if Chef::Resource::ChefGem.method_defined?(:compile_time)
|
|
26
|
+
# action :nothing
|
|
27
|
+
# end
|
|
28
|
+
#
|
|
29
|
+
# chef_gem 'ultradns-sdk' do
|
|
30
|
+
# compile_time true if Chef::Resource::ChefGem.instance_methods(false).include?(:compile_time)
|
|
31
|
+
# action :nothing
|
|
32
|
+
# end
|
|
33
|
+
#
|
|
34
|
+
# chef_gem 'ultradns-sdk' do
|
|
35
|
+
# compile_time true if respond_to?(:compile_time)
|
|
36
|
+
# action :nothing
|
|
37
|
+
# end
|
|
38
|
+
#
|
|
39
|
+
# # good
|
|
40
|
+
# chef_gem 'ultradns-sdk' do
|
|
41
|
+
# compile_time true
|
|
42
|
+
# action :nothing
|
|
43
|
+
# end
|
|
44
|
+
#
|
|
45
|
+
class RespondToCompileTime < Cop
|
|
46
|
+
extend TargetChefVersion
|
|
47
|
+
|
|
48
|
+
minimum_target_chef_version '12.1'
|
|
49
|
+
|
|
50
|
+
MSG = 'There is no need to check if the chef_gem resource supports compile_time as Chef Infra Client 12.1 and later support the compile_time property.'.freeze
|
|
51
|
+
|
|
52
|
+
def_node_matcher :compile_time_method_defined?, <<-PATTERN
|
|
53
|
+
(if
|
|
54
|
+
{
|
|
55
|
+
(send
|
|
56
|
+
(const
|
|
57
|
+
(const
|
|
58
|
+
(const nil? :Chef) :Resource) :ChefGem) :method_defined?
|
|
59
|
+
(sym :compile_time))
|
|
60
|
+
|
|
61
|
+
(send
|
|
62
|
+
(send
|
|
63
|
+
(const
|
|
64
|
+
(const
|
|
65
|
+
(const nil? :Chef) :Resource) :ChefGem) :instance_methods
|
|
66
|
+
(false)) :include?
|
|
67
|
+
(sym :compile_time))
|
|
68
|
+
|
|
69
|
+
(send nil? :respond_to?
|
|
70
|
+
(sym :compile_time))
|
|
71
|
+
}
|
|
72
|
+
(send nil? :compile_time
|
|
73
|
+
$(_)) nil?)
|
|
74
|
+
PATTERN
|
|
75
|
+
|
|
76
|
+
def on_if(node)
|
|
77
|
+
compile_time_method_defined?(node) do
|
|
78
|
+
add_offense(node, location: :expression, message: MSG, severity: :refactor)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def autocorrect(node)
|
|
83
|
+
lambda do |corrector|
|
|
84
|
+
compile_time_method_defined?(node) do |val|
|
|
85
|
+
corrector.replace(node.loc.expression, "compile_time #{val.source}")
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#
|
|
2
|
-
# Copyright:: 2019, Chef Software, Inc.
|
|
2
|
+
# Copyright:: 2019-2020, 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");
|
|
@@ -18,19 +18,20 @@ module RuboCop
|
|
|
18
18
|
module Cop
|
|
19
19
|
module Chef
|
|
20
20
|
module ChefModernize
|
|
21
|
-
#
|
|
22
|
-
# methods in Chef 11 and early versions of Chef 12.
|
|
21
|
+
# In Chef Infra Client 12+ is is no longer necessary to gate the use of the provides methods in resources with `if respond_to?(:provides)` or `if defined? provides`.
|
|
23
22
|
#
|
|
24
23
|
# @example
|
|
25
24
|
#
|
|
26
25
|
# # bad
|
|
27
26
|
# provides :foo if respond_to?(:provides)
|
|
28
27
|
#
|
|
28
|
+
# provides :foo if defined? provides
|
|
29
|
+
#
|
|
29
30
|
# # good
|
|
30
31
|
# provides :foo
|
|
31
32
|
#
|
|
32
33
|
class RespondToProvides < Cop
|
|
33
|
-
MSG = 'respond_to?(:provides) in resources is no longer necessary in Chef Infra Client 12
|
|
34
|
+
MSG = 'Using `respond_to?(:provides)` or `if defined? provides` in resources is no longer necessary in Chef Infra Client 12+.'.freeze
|
|
34
35
|
|
|
35
36
|
def on_if(node)
|
|
36
37
|
if_respond_to_provides?(node) do
|
|
@@ -39,7 +40,16 @@ module RuboCop
|
|
|
39
40
|
end
|
|
40
41
|
|
|
41
42
|
def_node_matcher :if_respond_to_provides?, <<~PATTERN
|
|
42
|
-
(if
|
|
43
|
+
(if
|
|
44
|
+
{
|
|
45
|
+
(send nil? :respond_to?
|
|
46
|
+
(sym :provides))
|
|
47
|
+
|
|
48
|
+
(:defined?
|
|
49
|
+
(send nil? :provides))
|
|
50
|
+
}
|
|
51
|
+
(send nil? :provides
|
|
52
|
+
(sym _)) ... )
|
|
43
53
|
PATTERN
|
|
44
54
|
|
|
45
55
|
def autocorrect(node)
|
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.3.4
|
|
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-04-
|
|
12
|
+
date: 2020-04-16 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.82.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.82.0
|
|
28
28
|
description:
|
|
29
29
|
email:
|
|
30
30
|
- thom@chef.io
|
|
@@ -89,6 +89,7 @@ files:
|
|
|
89
89
|
- lib/rubocop/cop/chef/deprecation/deprecated_chefspec_platform.rb
|
|
90
90
|
- lib/rubocop/cop/chef/deprecation/deprecated_mixins.rb
|
|
91
91
|
- lib/rubocop/cop/chef/deprecation/deprecated_platform_methods.rb
|
|
92
|
+
- lib/rubocop/cop/chef/deprecation/deprecated_shellout_methods.rb
|
|
92
93
|
- lib/rubocop/cop/chef/deprecation/deprecated_windows_version_check.rb
|
|
93
94
|
- lib/rubocop/cop/chef/deprecation/deprecated_yum_repository_properties.rb
|
|
94
95
|
- lib/rubocop/cop/chef/deprecation/easy_install.rb
|
|
@@ -176,6 +177,7 @@ files:
|
|
|
176
177
|
- lib/rubocop/cop/chef/modernize/resource_name_initializer.rb
|
|
177
178
|
- lib/rubocop/cop/chef/modernize/resource_set_or_return.rb
|
|
178
179
|
- lib/rubocop/cop/chef/modernize/resource_with_attributes.rb
|
|
180
|
+
- lib/rubocop/cop/chef/modernize/respond_to_compile_time.rb
|
|
179
181
|
- lib/rubocop/cop/chef/modernize/respond_to_metadata.rb
|
|
180
182
|
- lib/rubocop/cop/chef/modernize/respond_to_provides.rb
|
|
181
183
|
- lib/rubocop/cop/chef/modernize/respond_to_resource_name.rb
|