cookstyle 7.18.0 → 7.22.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/cookstyle.yml +122 -5
- 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 +50 -0
- 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/chef_14_resources.rb +2 -2
- data/lib/rubocop/cop/chef/modernize/chef_15_resources.rb +57 -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_kernel_module_cookbook.rb +54 -0
- data/lib/rubocop/cop/chef/modernize/depends_locale_cookbook.rb +54 -0
- data/lib/rubocop/cop/chef/modernize/depends_openssl_cookbook.rb +54 -0
- data/lib/rubocop/cop/chef/modernize/depends_timezone_lwrp_cookbook.rb +54 -0
- data/lib/rubocop/cop/chef/modernize/depends_windows_firewall_cookbook.rb +54 -0
- data/lib/rubocop/cop/chef/modernize/libarchive_file.rb +4 -2
- 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 +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f991818edd484753a75e2c0ae4e0d363f48b9213189cd4240bda17b08e260d4
|
4
|
+
data.tar.gz: fa69ed0eb47f5276d723b7f75acd6c08f21e8c57391f6c1b8c71f2e74c023880
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f5a09a0805b0b184e1fe10e90bbdd0270a537b4c823560f74f1b4cfd6e6ea332fc62fc6695595b92cf35733db3871d94a037b4747681572bd0925525c7a3da9
|
7
|
+
data.tar.gz: 5118bf5677557d03e0e730de31670c7defcd943d5d356147f40eed1c86118f463f29083f081d4af0e622c7375db9415c5b9e57da933291c441c500ee658d6265
|
data/config/cookstyle.yml
CHANGED
@@ -482,13 +482,22 @@ 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'
|
489
489
|
Include:
|
490
490
|
- '**/metadata.rb'
|
491
491
|
|
492
|
+
Chef/Correctness/PowershellFileExists:
|
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
|
+
StyleGuide: 'chef_correctness_powershellfileexists'
|
495
|
+
Enabled: true
|
496
|
+
VersionAdded: '7.19'
|
497
|
+
Exclude:
|
498
|
+
- '**/metadata.rb'
|
499
|
+
- '**/Berksfile'
|
500
|
+
|
492
501
|
###############################
|
493
502
|
# Chef/Sharing: Issues that prevent sharing code with other teams or with the Chef community in general
|
494
503
|
###############################
|
@@ -970,7 +979,7 @@ Chef/Deprecations/DeprecatedPlatformMethods:
|
|
970
979
|
- '**/providers/*.rb'
|
971
980
|
|
972
981
|
Chef/Deprecations/DeprecatedChefSpecPlatform:
|
973
|
-
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
|
974
983
|
StyleGuide: 'chef_deprecations_deprecatedchefspecplatform'
|
975
984
|
Enabled: true
|
976
985
|
VersionAdded: '5.20.0'
|
@@ -1189,7 +1198,7 @@ Chef/Deprecations/DeprecatedYumRepositoryActions:
|
|
1189
1198
|
- '**/Rakefile'
|
1190
1199
|
|
1191
1200
|
Chef/Deprecations/ChefSugarHelpers:
|
1192
|
-
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
|
1193
1202
|
StyleGuide: 'chef_deprecations_chefsugarhelpers'
|
1194
1203
|
Enabled: true
|
1195
1204
|
VersionAdded: '7.3.0'
|
@@ -1237,6 +1246,30 @@ Chef/Deprecations/DeprecatedSudoActions:
|
|
1237
1246
|
- '**/Berksfile'
|
1238
1247
|
- '**/Rakefile'
|
1239
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
|
+
|
1240
1273
|
###############################
|
1241
1274
|
# Chef/Modernize: Cleaning up legacy code and using new built-in resources
|
1242
1275
|
###############################
|
@@ -1263,7 +1296,7 @@ Chef/Modernize/WhyRunSupportedTrue:
|
|
1263
1296
|
- '**/libraries/*.rb'
|
1264
1297
|
|
1265
1298
|
Chef/Modernize/UnnecessaryDependsChef14:
|
1266
|
-
Description: Don't depend on cookbooks made obsolete by Chef Infra Client 14+. These community cookbooks contain resources that are now included in Chef Infra Client itself.
|
1299
|
+
Description: Don't depend on cookbooks made obsolete by Chef Infra Client 14.0+. These community cookbooks contain resources that are now included in Chef Infra Client itself.
|
1267
1300
|
StyleGuide: 'chef_modernize_unnecessarydependschef14'
|
1268
1301
|
Enabled: true
|
1269
1302
|
VersionAdded: '5.1.0'
|
@@ -1389,7 +1422,7 @@ Chef/Modernize/SevenZipArchiveResource:
|
|
1389
1422
|
- '**/metadata.rb'
|
1390
1423
|
|
1391
1424
|
Chef/Modernize/LibarchiveFileResource:
|
1392
|
-
Description: Use the archive_file resource built into Chef Infra Client 15+ instead of the libarchive file resource
|
1425
|
+
Description: Use the archive_file resource built into Chef Infra Client 15+ instead of the libarchive file resource from the libarchive cookbook
|
1393
1426
|
StyleGuide: 'chef_modernize_libarchivefileresource'
|
1394
1427
|
Enabled: true
|
1395
1428
|
VersionAdded: '5.5.0'
|
@@ -1799,6 +1832,90 @@ Chef/Modernize/ActionMethodInResource:
|
|
1799
1832
|
- '**/resources/*.rb'
|
1800
1833
|
- '**/providers/*.rb'
|
1801
1834
|
|
1835
|
+
Chef/Modernize/UnnecessaryDependsChef15:
|
1836
|
+
Description: Don't depend on cookbooks made obsolete by Chef Infra Client 15.0+. These community cookbooks contain resources that are now included in Chef Infra Client itself.
|
1837
|
+
StyleGuide: 'chef_modernize_unnecessarydependschef15'
|
1838
|
+
Enabled: true
|
1839
|
+
VersionAdded: '7.19.0'
|
1840
|
+
Include:
|
1841
|
+
- '**/metadata.rb'
|
1842
|
+
|
1843
|
+
Chef/Modernize/DependsOnLocaleCookbook:
|
1844
|
+
Description: Don't depend on the locale cookbook made obsolete by Chef Infra Client 14.5. The locale resource is now included in Chef Infra Client itself.
|
1845
|
+
StyleGuide: 'chef_modernize_dependsonlocalecookbook'
|
1846
|
+
Enabled: true
|
1847
|
+
VersionAdded: '7.19.0'
|
1848
|
+
Include:
|
1849
|
+
- '**/metadata.rb'
|
1850
|
+
|
1851
|
+
Chef/Modernize/DependsOnTimezoneLwrpCookbook:
|
1852
|
+
Description: Don't depend on the timezone_lwrp cookbook made obsolete by Chef Infra Client 14.6. The timezone resource is now included in Chef Infra Client itself.
|
1853
|
+
StyleGuide: 'chef_modernize_dependsontimezonelwrpcookbook'
|
1854
|
+
Enabled: true
|
1855
|
+
VersionAdded: '7.19.0'
|
1856
|
+
Include:
|
1857
|
+
- '**/metadata.rb'
|
1858
|
+
|
1859
|
+
Chef/Modernize/DependsOnWindowsFirewallCookbook:
|
1860
|
+
Description: Don't depend on the windows_firewall cookbook made obsolete by Chef Infra Client 14.7. The windows_firewall resource is now included in Chef Infra Client itself.
|
1861
|
+
StyleGuide: 'chef_modernize_dependsonwindowsfirewallcookbook'
|
1862
|
+
Enabled: true
|
1863
|
+
VersionAdded: '7.19.0'
|
1864
|
+
Include:
|
1865
|
+
- '**/metadata.rb'
|
1866
|
+
|
1867
|
+
Chef/Modernize/DependsOnKernelModuleCookbook:
|
1868
|
+
Description: Don't depend on the kernel_module cookbook made obsolete by Chef Infra Client 14.3. The kernel_module resource is now included in Chef Infra Client itself.
|
1869
|
+
StyleGuide: 'chef_modernize_dependsonkernelmodulecookbook'
|
1870
|
+
Enabled: true
|
1871
|
+
VersionAdded: '7.19.0'
|
1872
|
+
Include:
|
1873
|
+
- '**/metadata.rb'
|
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 attribute 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: hef Infra Client 15.5 and later include cloud helpers to make detecting instance 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
|
+
|
1802
1919
|
###############################
|
1803
1920
|
# Chef/RedundantCode: Cleanup unnecessary code in your cookbooks regardless of Chef Infra Client release
|
1804
1921
|
###############################
|
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
|
#
|
@@ -0,0 +1,50 @@
|
|
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 Correctness
|
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
|
+
#
|
24
|
+
# @example
|
25
|
+
#
|
26
|
+
# #### incorrect
|
27
|
+
# powershell_out('Test-Path "C:\\Program Files\\LAPS\\CSE\\AdmPwd.dll"').stdout.strip == 'True'
|
28
|
+
#
|
29
|
+
# #### correct
|
30
|
+
# ::File.exist?('C:\Program Files\LAPS\CSE\AdmPwd.dll')
|
31
|
+
#
|
32
|
+
class PowershellFileExists < Base
|
33
|
+
RESTRICT_ON_SEND = [:powershell_out, :powershell_out!].freeze
|
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
|
+
|
36
|
+
def_node_matcher :powershell_out_exists?, <<-PATTERN
|
37
|
+
(send nil? {:powershell_out :powershell_out!} (str $_))
|
38
|
+
PATTERN
|
39
|
+
|
40
|
+
def on_send(node)
|
41
|
+
powershell_out_exists?(node) do |exists_string|
|
42
|
+
return unless exists_string.match?(/^Test-Path/)
|
43
|
+
add_offense(node, message: MSG, severity: :refactor)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -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
|