cookstyle 7.19.0 → 7.23.0
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 +80 -4
- data/config/disable_all.yml +2 -0
- data/config/upstream.yml +24 -2
- data/cookstyle.gemspec +1 -1
- data/lib/cookstyle/version.rb +2 -2
- data/lib/rubocop/cop/chef/correctness/metadata_malformed_version.rb +1 -1
- data/lib/rubocop/cop/chef/correctness/powershell_file_exists.rb +2 -2
- data/lib/rubocop/cop/chef/deprecation/chef_sugar_helpers.rb +2 -2
- data/lib/rubocop/cop/chef/deprecation/depends_chef_nginx_cookbook.rb +54 -0
- data/lib/rubocop/cop/chef/deprecation/depends_chef_reporting_cookbook.rb +51 -0
- data/lib/rubocop/cop/chef/deprecation/depends_omnibus_updater_cookbook.rb +54 -0
- data/lib/rubocop/cop/chef/deprecation/deprecated_chefspec_platform.rb +2 -2
- data/lib/rubocop/cop/chef/deprecation/hwrp_without_unified_mode_true.rb +1 -1
- data/lib/rubocop/cop/chef/deprecation/resource_without_unified_mode_true.rb +1 -1
- data/lib/rubocop/cop/chef/modernize/class_eval_action_class.rb +64 -0
- data/lib/rubocop/cop/chef/modernize/depends_chef_vault_cookbook.rb +54 -0
- data/lib/rubocop/cop/chef/modernize/depends_chocolatey_cookbooks.rb +55 -0
- data/lib/rubocop/cop/chef/modernize/depends_openssl_cookbook.rb +54 -0
- data/lib/rubocop/cop/chef/modernize/use_chef_language_cloud_helpers.rb +90 -0
- data/lib/rubocop/cop/chef/modernize/use_chef_language_env_helpers.rb +66 -0
- data/lib/rubocop/cop/chef/style/immediate_notification_timing.rb +3 -3
- metadata +14 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9be1741ac594805428a4c1269af0b63e1176abf6e14aa6e04c47639c1153f083
|
4
|
+
data.tar.gz: b7d95d2ba12571d8a09d1a6eabaacce48e2ee0956ac91c595d7c5be5e010978b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4409915af7d5e193e9fcbc49c333370aa318e50c4a798ccee1a6b619912b4ff3bd6f8016b67f96da4f3ba10bda212e453d45fbfe5ec3a611d6eb64a78911820f
|
7
|
+
data.tar.gz: cb2d001bd4d5fb913dbb6a14972bb341e43fa982a926ae30a37d3adcce6e5fc599a8e535ff53dd82cac3dddf8de8fde0ce49c1e1db9192e83ad51a99c609a0f2
|
data/Gemfile
CHANGED
data/config/cookstyle.yml
CHANGED
@@ -482,7 +482,7 @@ Chef/Correctness/OctalModeAsString:
|
|
482
482
|
- '**/Berksfile'
|
483
483
|
|
484
484
|
Chef/Correctness/MetadataMalformedDepends:
|
485
|
-
Description:
|
485
|
+
Description: metadata.rb cookbook dependencies and version constraints should be comma separated.
|
486
486
|
StyleGuide: 'chef_correctness_metadatamalformeddepends'
|
487
487
|
Enabled: true
|
488
488
|
VersionAdded: '7.16'
|
@@ -490,7 +490,7 @@ Chef/Correctness/MetadataMalformedDepends:
|
|
490
490
|
- '**/metadata.rb'
|
491
491
|
|
492
492
|
Chef/Correctness/PowershellFileExists:
|
493
|
-
Description: Use Ruby's built-in `File.exist?('C:\somefile') instead of executing PowerShell's `Test-Path` cmdlet, which takes longer to load.
|
493
|
+
Description: Use Ruby's built-in `File.exist?('C:\somefile')` method instead of executing PowerShell's `Test-Path` cmdlet, which takes longer to load.
|
494
494
|
StyleGuide: 'chef_correctness_powershellfileexists'
|
495
495
|
Enabled: true
|
496
496
|
VersionAdded: '7.19'
|
@@ -979,7 +979,7 @@ Chef/Deprecations/DeprecatedPlatformMethods:
|
|
979
979
|
- '**/providers/*.rb'
|
980
980
|
|
981
981
|
Chef/Deprecations/DeprecatedChefSpecPlatform:
|
982
|
-
Description: Use currently supported platforms in ChefSpec listed at https://github.com/chefspec/fauxhai/blob/
|
982
|
+
Description: Use currently supported platforms in ChefSpec listed at https://github.com/chefspec/fauxhai/blob/main/PLATFORMS.md. Fauxhai / ChefSpec will perform fuzzy matching on platform version so it's always best to be less specific ie. 10 instead of 10.3
|
983
983
|
StyleGuide: 'chef_deprecations_deprecatedchefspecplatform'
|
984
984
|
Enabled: true
|
985
985
|
VersionAdded: '5.20.0'
|
@@ -1198,7 +1198,7 @@ Chef/Deprecations/DeprecatedYumRepositoryActions:
|
|
1198
1198
|
- '**/Rakefile'
|
1199
1199
|
|
1200
1200
|
Chef/Deprecations/ChefSugarHelpers:
|
1201
|
-
Description: Do not use legacy chef-sugar helper methods, which will not be moved into Chef Infra Client itself. For a complete set of chef-sugar helpers now shipping in Chef Infra Client itself see https://github.com/chef/chef/tree/
|
1201
|
+
Description: Do not use legacy chef-sugar helper methods, which will not be moved into Chef Infra Client itself. For a complete set of chef-sugar helpers now shipping in Chef Infra Client itself see https://github.com/chef/chef/tree/main/chef-utils#getting-started
|
1202
1202
|
StyleGuide: 'chef_deprecations_chefsugarhelpers'
|
1203
1203
|
Enabled: true
|
1204
1204
|
VersionAdded: '7.3.0'
|
@@ -1246,6 +1246,30 @@ Chef/Deprecations/DeprecatedSudoActions:
|
|
1246
1246
|
- '**/Berksfile'
|
1247
1247
|
- '**/Rakefile'
|
1248
1248
|
|
1249
|
+
Chef/Deprecations/DependsOnChefNginxCookbook:
|
1250
|
+
Description: Don't depend on the deprecated `chef_nginx` cookbook that was replaced by the `nginx` cookbook. The legacy chef_nginx cookbook may not be compatible with newer Chef Infra Client releases.
|
1251
|
+
StyleGuide: 'chef_deprecations_dependsonchefnginxcookbook'
|
1252
|
+
Enabled: true
|
1253
|
+
VersionAdded: '7.20.0'
|
1254
|
+
Include:
|
1255
|
+
- '**/metadata.rb'
|
1256
|
+
|
1257
|
+
Chef/Deprecations/DependsOnChefReportingCookbook:
|
1258
|
+
Description: Don't depend on the chef-reporting cookbook made obsolete by Chef Infra Client 11.6. This cookbook installs a gem that is not compatible with newer Chef Infra Client releases.
|
1259
|
+
StyleGuide: 'chef_deprecations_dependsonchefreportingcookbook'
|
1260
|
+
Enabled: true
|
1261
|
+
VersionAdded: '7.20.0'
|
1262
|
+
Include:
|
1263
|
+
- '**/metadata.rb'
|
1264
|
+
|
1265
|
+
Chef/Deprecations/DependsOnOmnibusUpdaterCookbook:
|
1266
|
+
Description: Don't depend on the EOL `omnibus_updater` cookbook. This cookbook no longer works with newer Chef Infra Client releases and has been replaced with the more reliable `chef_client_updater` cookbook.
|
1267
|
+
StyleGuide: 'chef_deprecations_dependsonomnibusupdatercookbook'
|
1268
|
+
Enabled: true
|
1269
|
+
VersionAdded: '7.20.0'
|
1270
|
+
Include:
|
1271
|
+
- '**/metadata.rb'
|
1272
|
+
|
1249
1273
|
###############################
|
1250
1274
|
# Chef/Modernize: Cleaning up legacy code and using new built-in resources
|
1251
1275
|
###############################
|
@@ -1848,6 +1872,58 @@ Chef/Modernize/DependsOnKernelModuleCookbook:
|
|
1848
1872
|
Include:
|
1849
1873
|
- '**/metadata.rb'
|
1850
1874
|
|
1875
|
+
Chef/Modernize/DependsOnChefVaultCookbook:
|
1876
|
+
Description: Don't depend on the chef-vault cookbook made obsolete by Chef Infra Client 16.0. The chef-vault gem and helpers are now included in Chef Infra Client itself.
|
1877
|
+
StyleGuide: 'chef_modernize_dependsonchefvaultcookbook'
|
1878
|
+
Enabled: true
|
1879
|
+
VersionAdded: '7.20.0'
|
1880
|
+
Include:
|
1881
|
+
- '**/metadata.rb'
|
1882
|
+
|
1883
|
+
Chef/Modernize/DependsOnChocolateyCookbooks:
|
1884
|
+
Description: Don't depend on the chocolatey_source or chocolatey_config cookbooks made obsolete by Chef Infra Client 14.3. The chocolatey_source and chocolatey_config resources are now included in Chef Infra Client itself.
|
1885
|
+
StyleGuide: 'chef_modernize_dependsonchocolateycookbooks'
|
1886
|
+
Enabled: true
|
1887
|
+
VersionAdded: '7.20.0'
|
1888
|
+
Include:
|
1889
|
+
- '**/metadata.rb'
|
1890
|
+
|
1891
|
+
Chef/Modernize/DependsOnOpensslCookbook:
|
1892
|
+
Description: Don't depend on the `openssl` cookbook which was made obsolete by Chef Infra Client 14.4. All `openssl_*` resources are now included directly in Chef Infra Client.
|
1893
|
+
StyleGuide: 'chef_modernize_dependsonopensslcookbook'
|
1894
|
+
Enabled: true
|
1895
|
+
VersionAdded: '7.20.0'
|
1896
|
+
Include:
|
1897
|
+
- '**/metadata.rb'
|
1898
|
+
|
1899
|
+
Chef/Modernize/UseChefLanguageEnvHelpers:
|
1900
|
+
Description: Chef Infra Client 15.5 and later include a large number of new helpers in the Chef Infra Language to simplify checking the system configuration in recipes and resources. These should be used when possible over more complex attributes or ENV var comparisons.
|
1901
|
+
StyleGuide: 'chef_modernize_usecheflanguageenvhelpers'
|
1902
|
+
Enabled: true
|
1903
|
+
VersionAdded: '7.21.0'
|
1904
|
+
Include:
|
1905
|
+
- '**/resources/*.rb'
|
1906
|
+
- '**/providers/*.rb'
|
1907
|
+
- '**/recipes/*.rb'
|
1908
|
+
|
1909
|
+
Chef/Modernize/UseChefLanguageCloudHelpers:
|
1910
|
+
Description: Chef Infra Client 15.5 and later include cloud helpers to make detecting instances that run on public and private clouds easier.
|
1911
|
+
StyleGuide: 'chef_modernize_usecheflanguagecloudhelpers'
|
1912
|
+
Enabled: true
|
1913
|
+
VersionAdded: '7.22.0'
|
1914
|
+
Include:
|
1915
|
+
- '**/resources/*.rb'
|
1916
|
+
- '**/providers/*.rb'
|
1917
|
+
- '**/recipes/*.rb'
|
1918
|
+
|
1919
|
+
Chef/Modernize/ClassEvalActionClass:
|
1920
|
+
Description: In Chef Infra Client 12.9 and later it is no longer necessary to call the class_eval method on the action class block.
|
1921
|
+
StyleGuide: 'chef_modernize_classevalactionclass'
|
1922
|
+
Enabled: true
|
1923
|
+
VersionAdded: '7.23.0'
|
1924
|
+
Include:
|
1925
|
+
- '**/resources/*.rb'
|
1926
|
+
|
1851
1927
|
###############################
|
1852
1928
|
# Chef/RedundantCode: Cleanup unnecessary code in your cookbooks regardless of Chef Infra Client release
|
1853
1929
|
###############################
|
data/config/disable_all.yml
CHANGED
data/config/upstream.yml
CHANGED
@@ -174,6 +174,20 @@ Bundler/GemComment:
|
|
174
174
|
IgnoredGems: []
|
175
175
|
OnlyFor: []
|
176
176
|
|
177
|
+
Bundler/GemFilename:
|
178
|
+
Description: 'Enforces the filename for managing gems.'
|
179
|
+
Enabled: true
|
180
|
+
VersionAdded: '1.20'
|
181
|
+
EnforcedStyle: 'Gemfile'
|
182
|
+
SupportedStyles:
|
183
|
+
- 'Gemfile'
|
184
|
+
- 'gems.rb'
|
185
|
+
Include:
|
186
|
+
- '**/Gemfile'
|
187
|
+
- '**/gems.rb'
|
188
|
+
- '**/Gemfile.lock'
|
189
|
+
- '**/gems.locked'
|
190
|
+
|
177
191
|
Bundler/GemVersion:
|
178
192
|
Description: 'Requires or forbids specifying gem versions.'
|
179
193
|
Enabled: false
|
@@ -1519,6 +1533,11 @@ Lint/Debugger:
|
|
1519
1533
|
Capybara:
|
1520
1534
|
- save_and_open_page
|
1521
1535
|
- save_and_open_screenshot
|
1536
|
+
debug.rb:
|
1537
|
+
- binding.b
|
1538
|
+
- binding.break
|
1539
|
+
- Kernel.binding.b
|
1540
|
+
- Kernel.binding.break
|
1522
1541
|
Pry:
|
1523
1542
|
- binding.pry
|
1524
1543
|
- binding.remote_pry
|
@@ -1527,6 +1546,8 @@ Lint/Debugger:
|
|
1527
1546
|
Rails:
|
1528
1547
|
- debugger
|
1529
1548
|
- Kernel.debugger
|
1549
|
+
RubyJard:
|
1550
|
+
- jard
|
1530
1551
|
WebConsole:
|
1531
1552
|
- binding.console
|
1532
1553
|
|
@@ -3149,7 +3170,7 @@ Style/CommentAnnotation:
|
|
3149
3170
|
StyleGuide: '#annotate-keywords'
|
3150
3171
|
Enabled: true
|
3151
3172
|
VersionAdded: '0.10'
|
3152
|
-
VersionChanged: '1.
|
3173
|
+
VersionChanged: '1.20'
|
3153
3174
|
Keywords:
|
3154
3175
|
- TODO
|
3155
3176
|
- FIXME
|
@@ -4692,8 +4713,9 @@ Style/StructInheritance:
|
|
4692
4713
|
Description: 'Checks for inheritance from Struct.new.'
|
4693
4714
|
StyleGuide: '#no-extend-struct-new'
|
4694
4715
|
Enabled: true
|
4716
|
+
SafeAutoCorrect: false
|
4695
4717
|
VersionAdded: '0.29'
|
4696
|
-
VersionChanged: '
|
4718
|
+
VersionChanged: '1.20'
|
4697
4719
|
|
4698
4720
|
Style/SwapValues:
|
4699
4721
|
Description: 'This cop enforces the use of shorthand-style swapping of 2 variables.'
|
data/cookstyle.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
|
23
23
|
spec.metadata = {
|
24
24
|
'homepage_uri' => 'https://github.com/chef/cookstyle',
|
25
|
-
'changelog_uri' => 'https://github.com/chef/cookstyle/blob/
|
25
|
+
'changelog_uri' => 'https://github.com/chef/cookstyle/blob/main/CHANGELOG.md',
|
26
26
|
'source_code_uri' => 'https://github.com/chef/cookstyle',
|
27
27
|
'documentation_uri' => 'https://docs.chef.io/workstation/cookstyle/',
|
28
28
|
'bug_tracker_uri' => 'https://github.com/chef/cookstyle/issues',
|
data/lib/cookstyle/version.rb
CHANGED
@@ -19,7 +19,7 @@ module RuboCop
|
|
19
19
|
module Cop
|
20
20
|
module Chef
|
21
21
|
module Correctness
|
22
|
-
# metadata.rb cookbook dependencies and version constraints should be comma separated
|
22
|
+
# metadata.rb cookbook dependencies and version constraints should be comma separated.
|
23
23
|
#
|
24
24
|
# @example
|
25
25
|
#
|
@@ -19,7 +19,7 @@ module RuboCop
|
|
19
19
|
module Cop
|
20
20
|
module Chef
|
21
21
|
module Correctness
|
22
|
-
# Use Ruby's built-in `File.exist?('C:\somefile') instead of executing PowerShell's `Test-Path` cmdlet, which takes longer to load.
|
22
|
+
# Use Ruby's built-in `File.exist?('C:\somefile')` method instead of executing PowerShell's `Test-Path` cmdlet, which takes longer to load.
|
23
23
|
#
|
24
24
|
# @example
|
25
25
|
#
|
@@ -31,7 +31,7 @@ module RuboCop
|
|
31
31
|
#
|
32
32
|
class PowershellFileExists < Base
|
33
33
|
RESTRICT_ON_SEND = [:powershell_out, :powershell_out!].freeze
|
34
|
-
MSG = "Use Ruby's built-in `File.exist?('C
|
34
|
+
MSG = "Use Ruby's built-in `File.exist?('C:\\somefile')` method instead of executing PowerShell's `Test-Path` cmdlet, which takes longer to load."
|
35
35
|
|
36
36
|
def_node_matcher :powershell_out_exists?, <<-PATTERN
|
37
37
|
(send nil? {:powershell_out :powershell_out!} (str $_))
|
@@ -19,7 +19,7 @@ module RuboCop
|
|
19
19
|
module Cop
|
20
20
|
module Chef
|
21
21
|
module Deprecations
|
22
|
-
# Do not use legacy chef-sugar helper methods, which will not be moved into Chef Infra Client itself. For a complete set of chef-sugar helpers now shipping in Chef Infra Client itself see https://github.com/chef/chef/tree/
|
22
|
+
# Do not use legacy chef-sugar helper methods, which will not be moved into Chef Infra Client itself. For a complete set of chef-sugar helpers now shipping in Chef Infra Client itself see https://github.com/chef/chef/tree/main/chef-utils#getting-started
|
23
23
|
#
|
24
24
|
# @example
|
25
25
|
#
|
@@ -42,7 +42,7 @@ module RuboCop
|
|
42
42
|
# opensolaris?
|
43
43
|
#
|
44
44
|
class ChefSugarHelpers < Base
|
45
|
-
MSG = 'Do not use legacy chef-sugar helper methods, which will not be moved into Chef Infra Client itself. For a complete set of chef-sugar helpers now shipping in Chef Infra Client itself see https://github.com/chef/chef/tree/
|
45
|
+
MSG = 'Do not use legacy chef-sugar helper methods, which will not be moved into Chef Infra Client itself. For a complete set of chef-sugar helpers now shipping in Chef Infra Client itself see https://github.com/chef/chef/tree/main/chef-utils#getting-started'
|
46
46
|
RESTRICT_ON_SEND = [:vagrant_key?, :vagrant_domain?, :vagrant_user?, :require_chef_gem, :best_ip_for, :nexus?, :ios_xr?, :ruby_20?, :ruby_19?, :includes_recipe?, :wrlinux?, :dev_null, :nexentacore_platform?, :opensolaris_platform?, :nexentacore?, :opensolaris?].freeze
|
47
47
|
|
48
48
|
def on_send(node)
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Copyright:: 2021, 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
|
+
# Don't depend on the deprecated `chef_nginx` cookbook that was replaced by the `nginx` cookbook. The legacy chef_nginx cookbook may not be compatible with newer Chef Infra Client releases.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
#
|
26
|
+
# #### incorrect
|
27
|
+
# depends 'chef_nginx'
|
28
|
+
#
|
29
|
+
# #### correct
|
30
|
+
# depends 'nginx'
|
31
|
+
#
|
32
|
+
class DependsOnChefNginxCookbook < Base
|
33
|
+
include RangeHelp
|
34
|
+
extend AutoCorrector
|
35
|
+
|
36
|
+
MSG = "Don't depend on the deprecated `chef_nginx` cookbook that was replaced by the `nginx` cookbook."
|
37
|
+
RESTRICT_ON_SEND = [:depends].freeze
|
38
|
+
|
39
|
+
def_node_matcher :depends_compat_resource?, <<-PATTERN
|
40
|
+
(send nil? :depends (str {"chef_nginx"}))
|
41
|
+
PATTERN
|
42
|
+
|
43
|
+
def on_send(node)
|
44
|
+
depends_compat_resource?(node) do
|
45
|
+
add_offense(node, message: MSG, severity: :warning) do |corrector|
|
46
|
+
corrector.remove(range_with_surrounding_space(range: node.loc.expression, side: :left))
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Copyright:: 2021, 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
|
+
# Don't depend on the chef-reporting cookbook made obsolete by Chef Infra Client 11.6. This cookbook installs a gem that is not compatible with newer Chef Infra Client releases.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
#
|
26
|
+
# #### incorrect
|
27
|
+
# depends 'chef-reporting'
|
28
|
+
#
|
29
|
+
class DependsOnChefReportingCookbook < Base
|
30
|
+
extend AutoCorrector
|
31
|
+
include RangeHelp
|
32
|
+
|
33
|
+
MSG = "Don't depend on the chef-reporting cookbook made obsolete by Chef Infra Client 11.6. This cookbook installs a gem that is not compatible with newer Chef Infra Client releases."
|
34
|
+
RESTRICT_ON_SEND = [:depends].freeze
|
35
|
+
|
36
|
+
def_node_matcher :legacy_depends?, <<-PATTERN
|
37
|
+
(send nil? :depends (str "chef-reporting") ... )
|
38
|
+
PATTERN
|
39
|
+
|
40
|
+
def on_send(node)
|
41
|
+
legacy_depends?(node) do
|
42
|
+
add_offense(node, message: MSG, severity: :warning) do |corrector|
|
43
|
+
corrector.remove(range_with_surrounding_space(range: node.loc.expression, side: :left))
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Copyright:: 2021, 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
|
+
# Don't depend on the EOL `omnibus_updater` cookbook. This cookbook no longer works with newer Chef Infra Client releases and has been replaced with the more reliable `chef_client_updater` cookbook.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
#
|
26
|
+
# #### incorrect
|
27
|
+
# depends 'omnibus_updater'
|
28
|
+
#
|
29
|
+
# #### correct
|
30
|
+
# depends 'chef_client_updater'
|
31
|
+
#
|
32
|
+
class DependsOnOmnibusUpdaterCookbook < Base
|
33
|
+
extend AutoCorrector
|
34
|
+
include RangeHelp
|
35
|
+
|
36
|
+
MSG = "Don't depend on the EOL `omnibus_updater` cookbook. This cookbook no longer works with newer Chef Infra Client releases and has been replaced with the more reliable `chef_client_updater` cookbook."
|
37
|
+
RESTRICT_ON_SEND = [:depends].freeze
|
38
|
+
|
39
|
+
def_node_matcher :legacy_depends?, <<-PATTERN
|
40
|
+
(send nil? :depends (str "omnibus_updater") ... )
|
41
|
+
PATTERN
|
42
|
+
|
43
|
+
def on_send(node)
|
44
|
+
legacy_depends?(node) do
|
45
|
+
add_offense(node, message: MSG, severity: :warning) do |corrector|
|
46
|
+
corrector.remove(range_with_surrounding_space(range: node.loc.expression, side: :left))
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -19,7 +19,7 @@ module RuboCop
|
|
19
19
|
module Cop
|
20
20
|
module Chef
|
21
21
|
module Deprecations
|
22
|
-
# Use currently supported platforms in ChefSpec listed at https://github.com/chefspec/fauxhai/blob/
|
22
|
+
# Use currently supported platforms in ChefSpec listed at https://github.com/chefspec/fauxhai/blob/main/PLATFORMS.md. Fauxhai / ChefSpec will perform fuzzy matching on platform version values so it's always best to be less specific ie. 10 instead of 10.3
|
23
23
|
#
|
24
24
|
# @example
|
25
25
|
#
|
@@ -29,7 +29,7 @@ module RuboCop
|
|
29
29
|
include RuboCop::Chef::CookbookHelpers
|
30
30
|
extend AutoCorrector
|
31
31
|
|
32
|
-
MSG = "Use currently supported platforms in ChefSpec listed at https://github.com/chefspec/fauxhai/blob/
|
32
|
+
MSG = "Use currently supported platforms in ChefSpec listed at https://github.com/chefspec/fauxhai/blob/main/PLATFORMS.md. Fauxhai / ChefSpec will perform fuzzy matching on platform version so it's always best to be less specific ie. 10 instead of 10.3"
|
33
33
|
|
34
34
|
DEPRECATED_MAPPING = {
|
35
35
|
'amazon' => {
|
@@ -19,7 +19,7 @@ module RuboCop
|
|
19
19
|
module Cop
|
20
20
|
module Chef
|
21
21
|
module Deprecations
|
22
|
-
# Chef Infra Client 15.3 and later include a new Unified Mode that
|
22
|
+
# Chef Infra Client 15.3 and later include a new Unified Mode that simplifies the execution of resources by replace the traditional compile and converge phases with a single phase. Unified mode simplifies writing advanced resources and avoids confusing errors that often occur when mixing ruby and Chef Infra resources. Chef Infra Client 17.0 and later will begin warning that `unified_mode true` should be set in all resources to validate that they will continue to function in Chef Infra Client 18.0 (April 2022) when Unified Mode becomes the default.
|
23
23
|
#
|
24
24
|
# @example
|
25
25
|
#
|
@@ -19,7 +19,7 @@ module RuboCop
|
|
19
19
|
module Cop
|
20
20
|
module Chef
|
21
21
|
module Deprecations
|
22
|
-
# Chef Infra Client 15.3 and later include a new Unified Mode that
|
22
|
+
# Chef Infra Client 15.3 and later include a new Unified Mode that simplifies the execution of resources by replace the traditional compile and converge phases with a single phase. Unified mode simplifies writing advanced resources and avoids confusing errors that often occur when mixing ruby and Chef Infra resources. Chef Infra Client 17.0 and later will begin warning that `unified_mode true` should be set in all resources to validate that they will continue to function in Chef Infra Client 18.0 (April 2022) when Unified Mode becomes the default.
|
23
23
|
#
|
24
24
|
# @example
|
25
25
|
#
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Copyright:: 2021, 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 Modernize
|
22
|
+
# In Chef Infra Client 12.9 and later it is no longer necessary to call the class_eval method on the action class block.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
#
|
26
|
+
# #### incorrect
|
27
|
+
# action_class.class_eval do
|
28
|
+
# foo
|
29
|
+
# end
|
30
|
+
#
|
31
|
+
# #### correct
|
32
|
+
# action_class do
|
33
|
+
# foo
|
34
|
+
# end
|
35
|
+
#
|
36
|
+
class ClassEvalActionClass < Base
|
37
|
+
extend TargetChefVersion
|
38
|
+
extend AutoCorrector
|
39
|
+
|
40
|
+
minimum_target_chef_version '12.9'
|
41
|
+
|
42
|
+
MSG = 'In Chef Infra Client 12.9 and later it is no longer necessary to call the class_eval method on the action class block.'
|
43
|
+
RESTRICT_ON_SEND = [:include_recipe].freeze
|
44
|
+
|
45
|
+
def_node_matcher :class_eval_action_class?, <<-PATTERN
|
46
|
+
(block
|
47
|
+
(send
|
48
|
+
(send nil? :action_class) :class_eval)
|
49
|
+
(args)
|
50
|
+
... )
|
51
|
+
PATTERN
|
52
|
+
|
53
|
+
def on_block(node)
|
54
|
+
class_eval_action_class?(node) do
|
55
|
+
add_offense(node, message: MSG, severity: :refactor) do |corrector|
|
56
|
+
corrector.replace(node, node.source.gsub('.class_eval', ''))
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Copyright:: 2021, 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 Modernize
|
22
|
+
# Don't depend on the chef-vault cookbook made obsolete by Chef Infra Client 16.0. The chef-vault gem and helpers are now included in Chef Infra Client itself.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
#
|
26
|
+
# #### incorrect
|
27
|
+
# depends 'chef-vault'
|
28
|
+
#
|
29
|
+
class DependsOnChefVaultCookbook < Base
|
30
|
+
extend AutoCorrector
|
31
|
+
extend TargetChefVersion
|
32
|
+
include RangeHelp
|
33
|
+
|
34
|
+
minimum_target_chef_version '16.0'
|
35
|
+
|
36
|
+
MSG = "Don't depend on the chef-vault cookbook made obsolete by Chef Infra Client 16.0. The chef-vault gem and helpers are now included in Chef Infra Client itself."
|
37
|
+
RESTRICT_ON_SEND = [:depends].freeze
|
38
|
+
|
39
|
+
def_node_matcher :legacy_depends?, <<-PATTERN
|
40
|
+
(send nil? :depends (str "chef-vault") ... )
|
41
|
+
PATTERN
|
42
|
+
|
43
|
+
def on_send(node)
|
44
|
+
legacy_depends?(node) do
|
45
|
+
add_offense(node, message: MSG, severity: :refactor) do |corrector|
|
46
|
+
corrector.remove(range_with_surrounding_space(range: node.loc.expression, side: :left))
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Copyright:: 2021, 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 Modernize
|
22
|
+
# Don't depend on the chocolatey_source or chocolatey_config cookbooks made obsolete by Chef Infra Client 14.3. The chocolatey_source and chocolatey_config resources are now included in Chef Infra Client itself.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
#
|
26
|
+
# #### incorrect
|
27
|
+
# depends 'chocolatey_source'
|
28
|
+
# depends 'chocolatey_config'
|
29
|
+
#
|
30
|
+
class DependsOnChocolateyCookbooks < Base
|
31
|
+
extend AutoCorrector
|
32
|
+
extend TargetChefVersion
|
33
|
+
include RangeHelp
|
34
|
+
|
35
|
+
minimum_target_chef_version '14.3'
|
36
|
+
|
37
|
+
MSG = "Don't depend on the chocolatey_source or chocolatey_config cookbooks made obsolete by Chef Infra Client 14.3. The chocolatey_source and chocolatey_config resources are now included in Chef Infra Client itself."
|
38
|
+
RESTRICT_ON_SEND = [:depends].freeze
|
39
|
+
|
40
|
+
def_node_matcher :legacy_depends?, <<-PATTERN
|
41
|
+
(send nil? :depends (str {"chocolatey_source" "chocolatey_config"}) ... )
|
42
|
+
PATTERN
|
43
|
+
|
44
|
+
def on_send(node)
|
45
|
+
legacy_depends?(node) do
|
46
|
+
add_offense(node, message: MSG, severity: :refactor) do |corrector|
|
47
|
+
corrector.remove(range_with_surrounding_space(range: node.loc.expression, side: :left))
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Copyright:: 2021, 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 Modernize
|
22
|
+
# Don't depend on the `openssl` cookbook which was made obsolete by Chef Infra Client 14.4. All `openssl_*` resources are now included directly in Chef Infra Client.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
#
|
26
|
+
# #### incorrect
|
27
|
+
# depends 'openssl'
|
28
|
+
#
|
29
|
+
class DependsOnOpensslCookbook < Base
|
30
|
+
extend AutoCorrector
|
31
|
+
extend TargetChefVersion
|
32
|
+
include RangeHelp
|
33
|
+
|
34
|
+
minimum_target_chef_version '14.4'
|
35
|
+
|
36
|
+
MSG = "Don't depend on the `openssl` cookbook which was made obsolete by Chef Infra Client 14.4. All `openssl_*` resources are now included directly in Chef Infra Client."
|
37
|
+
RESTRICT_ON_SEND = [:depends].freeze
|
38
|
+
|
39
|
+
def_node_matcher :legacy_depends?, <<-PATTERN
|
40
|
+
(send nil? :depends (str "openssl") ... )
|
41
|
+
PATTERN
|
42
|
+
|
43
|
+
def on_send(node)
|
44
|
+
legacy_depends?(node) do
|
45
|
+
add_offense(node, message: MSG, severity: :refactor) do |corrector|
|
46
|
+
corrector.remove(range_with_surrounding_space(range: node.loc.expression, side: :left))
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Copyright:: 2021, 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 Modernize
|
22
|
+
# Chef Infra Client 15.5 and later include cloud helpers to make detecting instances that run on public and private clouds easier.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
#
|
26
|
+
# #### incorrect
|
27
|
+
# node['cloud']['provider'] == 'alibaba'
|
28
|
+
# node['cloud']['provider'] == 'ec2'
|
29
|
+
# node['cloud']['provider'] == 'gce'
|
30
|
+
# node['cloud']['provider'] == 'rackspace'
|
31
|
+
# node['cloud']['provider'] == 'eucalyptus'
|
32
|
+
# node['cloud']['provider'] == 'linode'
|
33
|
+
# node['cloud']['provider'] == 'openstack'
|
34
|
+
# node['cloud']['provider'] == 'azure'
|
35
|
+
# node['cloud']['provider'] == 'digital_ocean'
|
36
|
+
# node['cloud']['provider'] == 'softlayer'
|
37
|
+
#
|
38
|
+
# #### correct
|
39
|
+
# alibaba?
|
40
|
+
# ec2?
|
41
|
+
# gce?
|
42
|
+
# rackspace?
|
43
|
+
# eucalyptus?
|
44
|
+
# linode?
|
45
|
+
# openstack?
|
46
|
+
# azure?
|
47
|
+
# digital_ocean?
|
48
|
+
# softlayer?
|
49
|
+
#
|
50
|
+
class UseChefLanguageCloudHelpers < Base
|
51
|
+
extend AutoCorrector
|
52
|
+
|
53
|
+
MSG = 'Chef Infra Client 15.5 and later include cloud helpers to make detecting instances that run on public and private clouds easier.'
|
54
|
+
RESTRICT_ON_SEND = [:==, :[]].freeze
|
55
|
+
VALID_CLOUDS = %w(alibaba ec2 gce rackspace eucalyptus linode openstack azure digital_ocean softlayer).freeze
|
56
|
+
|
57
|
+
def_node_matcher :provider_comparison?, <<-PATTERN
|
58
|
+
(send
|
59
|
+
(send
|
60
|
+
(send
|
61
|
+
(send nil? :node) :[]
|
62
|
+
(str "cloud")) :[]
|
63
|
+
(str "provider")) :==
|
64
|
+
(str $_))
|
65
|
+
PATTERN
|
66
|
+
|
67
|
+
def_node_matcher :node_cloud?, <<-PATTERN
|
68
|
+
(send
|
69
|
+
(send nil? :node) :[]
|
70
|
+
(str "cloud"))
|
71
|
+
PATTERN
|
72
|
+
|
73
|
+
def on_send(node)
|
74
|
+
provider_comparison?(node) do |cloud_name|
|
75
|
+
# skip it if someone was checking for a bogus cloud provider
|
76
|
+
next unless VALID_CLOUDS.include?(cloud_name)
|
77
|
+
|
78
|
+
# if they were checking for node['cloud'] and the provider replace it all
|
79
|
+
node = node.parent if node.parent.and_type? && node_cloud?(node.left_sibling)
|
80
|
+
|
81
|
+
add_offense(node, message: MSG, severity: :refactor) do |corrector|
|
82
|
+
corrector.replace(node, "#{cloud_name}?")
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Copyright:: 2021, 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 Modernize
|
22
|
+
# Chef Infra Client 15.5 and later include a large number of new helpers in the Chef Infra Language to simplify checking the system configuration in recipes and resources. These should be used when possible over more complex attributes or ENV var comparisons.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
#
|
26
|
+
# #### incorrect
|
27
|
+
# ENV['CI']
|
28
|
+
# ENV['TEST_KITCHEN']
|
29
|
+
#
|
30
|
+
# #### correct
|
31
|
+
# ci?
|
32
|
+
# kitchen?
|
33
|
+
#
|
34
|
+
class UseChefLanguageEnvHelpers < Base
|
35
|
+
extend AutoCorrector
|
36
|
+
|
37
|
+
RESTRICT_ON_SEND = [:[]].freeze
|
38
|
+
|
39
|
+
def_node_matcher :env?, <<-PATTERN
|
40
|
+
(send
|
41
|
+
(const nil? :ENV) :[]
|
42
|
+
(str ${"TEST_KITCHEN" "CI"}))
|
43
|
+
PATTERN
|
44
|
+
|
45
|
+
def on_send(node)
|
46
|
+
env?(node) do |env_value|
|
47
|
+
# we don't handle .nil? checks yet so just skip them
|
48
|
+
next if node.parent.send_type? && node.parent.method_name == :nil?
|
49
|
+
|
50
|
+
case env_value
|
51
|
+
when 'CI'
|
52
|
+
add_offense(node, message: 'Chef Infra Client 15.5 and later include a helper `ci?` that should be used to see if the `CI` env var is set.', severity: :refactor) do |corrector|
|
53
|
+
corrector.replace(node, 'ci?')
|
54
|
+
end
|
55
|
+
when 'TEST_KITCHEN'
|
56
|
+
add_offense(node, message: 'Chef Infra Client 15.5 and later include a helper `kitchen?` that should be used to see if the `TEST_KITCHEN` env var is set.', severity: :refactor) do |corrector|
|
57
|
+
corrector.replace(node, 'kitchen?')
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -19,7 +19,7 @@ module RuboCop
|
|
19
19
|
module Cop
|
20
20
|
module Chef
|
21
21
|
module Style
|
22
|
-
# Use :immediately instead of :immediate for resource notification timing
|
22
|
+
# Use :immediately instead of :immediate for resource notification timing.
|
23
23
|
#
|
24
24
|
# @example
|
25
25
|
#
|
@@ -39,10 +39,10 @@ module RuboCop
|
|
39
39
|
extend AutoCorrector
|
40
40
|
|
41
41
|
MSG = 'Use :immediately instead of :immediate for resource notification timing'
|
42
|
-
RESTRICT_ON_SEND = [:notifies].freeze
|
42
|
+
RESTRICT_ON_SEND = [:notifies, :subscribes].freeze
|
43
43
|
|
44
44
|
def_node_matcher :immediate_notify?, <<-PATTERN
|
45
|
-
(send nil? :notifies (sym _) (...) $(sym :immediate))
|
45
|
+
(send nil? {:notifies :subscribes} (sym _) (...) $(sym :immediate))
|
46
46
|
PATTERN
|
47
47
|
|
48
48
|
def on_send(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: 7.
|
4
|
+
version: 7.23.0
|
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: 2021-
|
12
|
+
date: 2021-09-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: 1.
|
20
|
+
version: 1.20.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.20.0
|
28
28
|
description:
|
29
29
|
email:
|
30
30
|
- thom@chef.io
|
@@ -100,7 +100,10 @@ files:
|
|
100
100
|
- lib/rubocop/cop/chef/deprecation/chefspec_coverage_report.rb
|
101
101
|
- lib/rubocop/cop/chef/deprecation/chefspec_legacy_runner.rb
|
102
102
|
- lib/rubocop/cop/chef/deprecation/chocolatey_package_uninstall_action.rb
|
103
|
+
- lib/rubocop/cop/chef/deprecation/depends_chef_nginx_cookbook.rb
|
104
|
+
- lib/rubocop/cop/chef/deprecation/depends_chef_reporting_cookbook.rb
|
103
105
|
- lib/rubocop/cop/chef/deprecation/depends_compat_resource.rb
|
106
|
+
- lib/rubocop/cop/chef/deprecation/depends_omnibus_updater_cookbook.rb
|
104
107
|
- lib/rubocop/cop/chef/deprecation/depends_partial_search.rb
|
105
108
|
- lib/rubocop/cop/chef/deprecation/depends_poise.rb
|
106
109
|
- lib/rubocop/cop/chef/deprecation/deprecated_chefspec_platform.rb
|
@@ -178,6 +181,7 @@ files:
|
|
178
181
|
- lib/rubocop/cop/chef/modernize/chef_14_resources.rb
|
179
182
|
- lib/rubocop/cop/chef/modernize/chef_15_resources.rb
|
180
183
|
- lib/rubocop/cop/chef/modernize/chef_gem_nokogiri.rb
|
184
|
+
- lib/rubocop/cop/chef/modernize/class_eval_action_class.rb
|
181
185
|
- lib/rubocop/cop/chef/modernize/compile_time_resources.rb
|
182
186
|
- lib/rubocop/cop/chef/modernize/conditional_using_test.rb
|
183
187
|
- lib/rubocop/cop/chef/modernize/cron_d_file_or_template.rb
|
@@ -186,8 +190,11 @@ files:
|
|
186
190
|
- lib/rubocop/cop/chef/modernize/default_action_initializer.rb
|
187
191
|
- lib/rubocop/cop/chef/modernize/defines_chefspec_matchers.rb
|
188
192
|
- lib/rubocop/cop/chef/modernize/definitions.rb
|
193
|
+
- lib/rubocop/cop/chef/modernize/depends_chef_vault_cookbook.rb
|
194
|
+
- lib/rubocop/cop/chef/modernize/depends_chocolatey_cookbooks.rb
|
189
195
|
- lib/rubocop/cop/chef/modernize/depends_kernel_module_cookbook.rb
|
190
196
|
- lib/rubocop/cop/chef/modernize/depends_locale_cookbook.rb
|
197
|
+
- lib/rubocop/cop/chef/modernize/depends_openssl_cookbook.rb
|
191
198
|
- lib/rubocop/cop/chef/modernize/depends_timezone_lwrp_cookbook.rb
|
192
199
|
- lib/rubocop/cop/chef/modernize/depends_windows_firewall_cookbook.rb
|
193
200
|
- lib/rubocop/cop/chef/modernize/depends_zypper_cookbook.rb
|
@@ -230,6 +237,8 @@ files:
|
|
230
237
|
- lib/rubocop/cop/chef/modernize/simplify_apt_ppa_setup.rb
|
231
238
|
- lib/rubocop/cop/chef/modernize/sysctl_param_resource.rb
|
232
239
|
- lib/rubocop/cop/chef/modernize/unnecessary_mixlib_shellout_require.rb
|
240
|
+
- lib/rubocop/cop/chef/modernize/use_chef_language_cloud_helpers.rb
|
241
|
+
- lib/rubocop/cop/chef/modernize/use_chef_language_env_helpers.rb
|
233
242
|
- lib/rubocop/cop/chef/modernize/use_multipackage_installs.rb
|
234
243
|
- lib/rubocop/cop/chef/modernize/use_require_relative.rb
|
235
244
|
- lib/rubocop/cop/chef/modernize/whyrun_supported_true.rb
|
@@ -297,7 +306,7 @@ licenses:
|
|
297
306
|
- Apache-2.0
|
298
307
|
metadata:
|
299
308
|
homepage_uri: https://github.com/chef/cookstyle
|
300
|
-
changelog_uri: https://github.com/chef/cookstyle/blob/
|
309
|
+
changelog_uri: https://github.com/chef/cookstyle/blob/main/CHANGELOG.md
|
301
310
|
source_code_uri: https://github.com/chef/cookstyle
|
302
311
|
documentation_uri: https://docs.chef.io/workstation/cookstyle/
|
303
312
|
bug_tracker_uri: https://github.com/chef/cookstyle/issues
|