cookstyle 7.16.1 → 7.20.0
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 +111 -2
- data/config/disable_all.yml +4 -0
- data/config/upstream.yml +22 -5
- data/lib/cookstyle/version.rb +2 -2
- data/lib/rubocop/cop/chef/correctness/powershell_file_exists.rb +50 -0
- 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_sudo_actions.rb +65 -0
- 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
- metadata +17 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1beeee72a35f1c32830c7c968ba50d7a277bed019de89697fb54e232d53cfa3d
|
4
|
+
data.tar.gz: 98a912f077a8d14033a03ace34622f1b651dec2b1aea69e3c7c8121f9c487423
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7a79148cf57524f1df2f880fcaea77f82cff8d87f1b2e347c1f0ed39a6629bfd91436caa4c7a6b55d99da6d2429e8bea99d9feeb78bc29585458bddf739f4a1
|
7
|
+
data.tar.gz: 6793431fc22cb1de03923569fcf0d2fb57fe3e0b646df99579752fa999d1898956b799dd2734b1e0459bc156fb48081ba685ad0fbedd45204b3b45a9438a5101
|
data/config/cookstyle.yml
CHANGED
@@ -489,6 +489,15 @@ Chef/Correctness/MetadataMalformedDepends:
|
|
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
|
###############################
|
@@ -1225,6 +1234,42 @@ Chef/Deprecations/PolicyfileCommunitySource:
|
|
1225
1234
|
Include:
|
1226
1235
|
- '**/Policyfile.rb'
|
1227
1236
|
|
1237
|
+
Chef/Deprecations/DeprecatedSudoActions:
|
1238
|
+
Description: The `sudo` resource in the sudo cookbook 5.0 (2018) or Chef Infra Client 14 and later have replaced the existing `:install` and `:remove` actions with `:create` and `:delete` actions to better match other resources in Chef Infra.
|
1239
|
+
StyleGuide: 'chef_deprecations_deprecatedsudoactions'
|
1240
|
+
Enabled: true
|
1241
|
+
VersionAdded: '7.18.0'
|
1242
|
+
Exclude:
|
1243
|
+
- '**/spec/**/*.rb'
|
1244
|
+
- '**/metadata.rb'
|
1245
|
+
- '**/attributes/*.rb'
|
1246
|
+
- '**/Berksfile'
|
1247
|
+
- '**/Rakefile'
|
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 by 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
|
+
|
1228
1273
|
###############################
|
1229
1274
|
# Chef/Modernize: Cleaning up legacy code and using new built-in resources
|
1230
1275
|
###############################
|
@@ -1251,7 +1296,7 @@ Chef/Modernize/WhyRunSupportedTrue:
|
|
1251
1296
|
- '**/libraries/*.rb'
|
1252
1297
|
|
1253
1298
|
Chef/Modernize/UnnecessaryDependsChef14:
|
1254
|
-
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.
|
1255
1300
|
StyleGuide: 'chef_modernize_unnecessarydependschef14'
|
1256
1301
|
Enabled: true
|
1257
1302
|
VersionAdded: '5.1.0'
|
@@ -1377,7 +1422,7 @@ Chef/Modernize/SevenZipArchiveResource:
|
|
1377
1422
|
- '**/metadata.rb'
|
1378
1423
|
|
1379
1424
|
Chef/Modernize/LibarchiveFileResource:
|
1380
|
-
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
|
1381
1426
|
StyleGuide: 'chef_modernize_libarchivefileresource'
|
1382
1427
|
Enabled: true
|
1383
1428
|
VersionAdded: '5.5.0'
|
@@ -1787,6 +1832,70 @@ Chef/Modernize/ActionMethodInResource:
|
|
1787
1832
|
- '**/resources/*.rb'
|
1788
1833
|
- '**/providers/*.rb'
|
1789
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 resource 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
|
+
|
1790
1899
|
###############################
|
1791
1900
|
# Chef/RedundantCode: Cleanup unnecessary code in your cookbooks regardless of Chef Infra Client release
|
1792
1901
|
###############################
|
data/config/disable_all.yml
CHANGED
@@ -219,6 +219,8 @@ Lint/AmbiguousBlockAssociation:
|
|
219
219
|
Enabled: false
|
220
220
|
Lint/AmbiguousOperator:
|
221
221
|
Enabled: false
|
222
|
+
Lint/AmbiguousRange:
|
223
|
+
Enabled: false
|
222
224
|
Lint/AmbiguousRegexpLiteral:
|
223
225
|
Enabled: false
|
224
226
|
Lint/AssignmentInCondition:
|
@@ -705,6 +707,8 @@ Style/RedundantFileExtensionInRequire:
|
|
705
707
|
Enabled: false
|
706
708
|
Style/RedundantSelfAssignment:
|
707
709
|
Enabled: false
|
710
|
+
Style/RedundantSelfAssignmentBranch:
|
711
|
+
Enabled: false
|
708
712
|
Style/SoleNestedConditional:
|
709
713
|
Enabled: false
|
710
714
|
Style/StaticClass:
|
data/config/upstream.yml
CHANGED
@@ -1434,6 +1434,13 @@ Lint/AmbiguousOperator:
|
|
1434
1434
|
VersionAdded: '0.17'
|
1435
1435
|
VersionChanged: '0.83'
|
1436
1436
|
|
1437
|
+
Lint/AmbiguousRange:
|
1438
|
+
Description: Checks for ranges with ambiguous boundaries.
|
1439
|
+
Enabled: pending
|
1440
|
+
VersionAdded: '1.19'
|
1441
|
+
SafeAutoCorrect: false
|
1442
|
+
RequireParenthesesForMethodChains: false
|
1443
|
+
|
1437
1444
|
Lint/AmbiguousRegexpLiteral:
|
1438
1445
|
Description: >-
|
1439
1446
|
Checks for ambiguous regexp literals in the first argument of
|
@@ -1824,7 +1831,6 @@ Lint/MultipleComparison:
|
|
1824
1831
|
Enabled: true
|
1825
1832
|
VersionAdded: '0.47'
|
1826
1833
|
VersionChanged: '1.1'
|
1827
|
-
AllowMethodComparison: true
|
1828
1834
|
|
1829
1835
|
Lint/NestedMethodDefinition:
|
1830
1836
|
Description: 'Do not use nested method definitions.'
|
@@ -2557,6 +2563,7 @@ Naming/InclusiveLanguage:
|
|
2557
2563
|
- denylist
|
2558
2564
|
- block
|
2559
2565
|
slave:
|
2566
|
+
WholeWord: true
|
2560
2567
|
Suggestions: ['replica', 'secondary', 'follower']
|
2561
2568
|
|
2562
2569
|
Naming/MemoizedInstanceVariableName:
|
@@ -3155,8 +3162,9 @@ Style/CommentAnnotation:
|
|
3155
3162
|
Style/CommentedKeyword:
|
3156
3163
|
Description: 'Do not place comments on the same line as certain keywords.'
|
3157
3164
|
Enabled: true
|
3165
|
+
SafeAutoCorrect: false
|
3158
3166
|
VersionAdded: '0.51'
|
3159
|
-
VersionChanged: '1.
|
3167
|
+
VersionChanged: '1.19'
|
3160
3168
|
|
3161
3169
|
Style/ConditionalAssignment:
|
3162
3170
|
Description: >-
|
@@ -3603,8 +3611,9 @@ Style/IdenticalConditionalBranches:
|
|
3603
3611
|
line at the end of each branch, which can validly be moved
|
3604
3612
|
out of the conditional.
|
3605
3613
|
Enabled: true
|
3614
|
+
SafeAutoCorrect: false
|
3606
3615
|
VersionAdded: '0.36'
|
3607
|
-
VersionChanged: '1.
|
3616
|
+
VersionChanged: '1.19'
|
3608
3617
|
|
3609
3618
|
Style/IfInsideElse:
|
3610
3619
|
Description: 'Finds if nodes inside else, which can be converted to elsif.'
|
@@ -3929,6 +3938,7 @@ Style/MultipleComparison:
|
|
3929
3938
|
Enabled: true
|
3930
3939
|
VersionAdded: '0.49'
|
3931
3940
|
VersionChanged: '1.1'
|
3941
|
+
AllowMethodComparison: true
|
3932
3942
|
|
3933
3943
|
Style/MutableConstant:
|
3934
3944
|
Description: 'Do not assign mutable objects to constants.'
|
@@ -4152,6 +4162,7 @@ Style/OptionHash:
|
|
4152
4162
|
- args
|
4153
4163
|
- params
|
4154
4164
|
- parameters
|
4165
|
+
Allowlist: []
|
4155
4166
|
|
4156
4167
|
Style/OptionalArguments:
|
4157
4168
|
Description: >-
|
@@ -4404,6 +4415,11 @@ Style/RedundantSelfAssignment:
|
|
4404
4415
|
Safe: false
|
4405
4416
|
VersionAdded: '0.90'
|
4406
4417
|
|
4418
|
+
Style/RedundantSelfAssignmentBranch:
|
4419
|
+
Description: 'Checks for places where conditional branch makes redundant self-assignment.'
|
4420
|
+
Enabled: pending
|
4421
|
+
VersionAdded: '1.19'
|
4422
|
+
|
4407
4423
|
Style/RedundantSort:
|
4408
4424
|
Description: >-
|
4409
4425
|
Use `min` instead of `sort.first`,
|
@@ -4575,6 +4591,7 @@ Style/SpecialGlobalVars:
|
|
4575
4591
|
VersionAdded: '0.13'
|
4576
4592
|
VersionChanged: '0.36'
|
4577
4593
|
SafeAutoCorrect: false
|
4594
|
+
RequireEnglish: true
|
4578
4595
|
EnforcedStyle: use_english_names
|
4579
4596
|
SupportedStyles:
|
4580
4597
|
- use_perl_names
|
@@ -4895,7 +4912,7 @@ Style/VariableInterpolation:
|
|
4895
4912
|
|
4896
4913
|
Style/WhenThen:
|
4897
4914
|
Description: 'Use when x then ... for one-line cases.'
|
4898
|
-
StyleGuide: '#
|
4915
|
+
StyleGuide: '#no-when-semicolons'
|
4899
4916
|
Enabled: true
|
4900
4917
|
VersionAdded: '0.9'
|
4901
4918
|
|
@@ -4919,7 +4936,7 @@ Style/WordArray:
|
|
4919
4936
|
StyleGuide: '#percent-w'
|
4920
4937
|
Enabled: true
|
4921
4938
|
VersionAdded: '0.9'
|
4922
|
-
VersionChanged: '
|
4939
|
+
VersionChanged: '1.19'
|
4923
4940
|
EnforcedStyle: percent
|
4924
4941
|
SupportedStyles:
|
4925
4942
|
# percent style: %w(word1 word2)
|
data/lib/cookstyle/version.rb
CHANGED
@@ -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
|
@@ -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 by 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 by 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
|
@@ -0,0 +1,65 @@
|
|
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
|
+
# The `sudo` resource in the sudo cookbook 5.0 (2018) or Chef Infra Client 14 and later have replaced the existing `:install` and `:remove` actions with `:create` and `:delete` actions to better match other resources in Chef Infra.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
#
|
26
|
+
# #### incorrect
|
27
|
+
# sudo 'admins' do
|
28
|
+
# users 'bob'
|
29
|
+
# groups 'sysadmins, superusers'
|
30
|
+
# action :remove
|
31
|
+
# end
|
32
|
+
#
|
33
|
+
# #### correct
|
34
|
+
# sudo 'admins' do
|
35
|
+
# users 'bob'
|
36
|
+
# groups 'sysadmins, superusers'
|
37
|
+
# action :delete
|
38
|
+
# end
|
39
|
+
#
|
40
|
+
class DeprecatedSudoActions < Base
|
41
|
+
include RuboCop::Chef::CookbookHelpers
|
42
|
+
extend TargetChefVersion
|
43
|
+
extend AutoCorrector
|
44
|
+
|
45
|
+
minimum_target_chef_version '14.0'
|
46
|
+
|
47
|
+
MSG = 'The `sudo` resource in the sudo cookbook 5.0 (2018) or Chef Infra Client 14 and later have replaced the existing `:install` and `:remove` actions with `:create` and `:delete` actions to better match other resources in Chef Infra.'
|
48
|
+
|
49
|
+
def on_block(node)
|
50
|
+
match_property_in_resource?(:sudo, 'action', node) do |prop_node|
|
51
|
+
next unless prop_node.arguments.first.sym_type?
|
52
|
+
next unless [s(:sym, :install), s(:sym, :remove)].include?(prop_node.arguments.first)
|
53
|
+
|
54
|
+
add_offense(prop_node, message: MSG, severity: :warning) do |corrector|
|
55
|
+
corrector.replace(prop_node, prop_node.source
|
56
|
+
.gsub('install', 'create')
|
57
|
+
.gsub('remove', 'delete'))
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -19,7 +19,7 @@ module RuboCop
|
|
19
19
|
module Cop
|
20
20
|
module Chef
|
21
21
|
module Modernize
|
22
|
-
# Don't depend on cookbooks made obsolete by Chef Infra Client 14
|
22
|
+
# 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.
|
23
23
|
#
|
24
24
|
# @example
|
25
25
|
#
|
@@ -39,7 +39,7 @@ module RuboCop
|
|
39
39
|
|
40
40
|
minimum_target_chef_version '14.0'
|
41
41
|
|
42
|
-
MSG = "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."
|
42
|
+
MSG = "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."
|
43
43
|
RESTRICT_ON_SEND = [:depends].freeze
|
44
44
|
|
45
45
|
def_node_matcher :legacy_depends?, <<-PATTERN
|
@@ -0,0 +1,57 @@
|
|
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 cookbooks made obsolete by Chef Infra Client 15.0+. These community cookbooks contain resources that are now included in Chef Infra Client itself.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
#
|
26
|
+
# #### incorrect
|
27
|
+
# depends 'libarchive'
|
28
|
+
# depends 'windows_dns'
|
29
|
+
# depends 'windows_uac'
|
30
|
+
# depends 'windows_dfs'
|
31
|
+
#
|
32
|
+
class UnnecessaryDependsChef15 < Base
|
33
|
+
extend AutoCorrector
|
34
|
+
extend TargetChefVersion
|
35
|
+
include RangeHelp
|
36
|
+
|
37
|
+
minimum_target_chef_version '15.0'
|
38
|
+
|
39
|
+
MSG = "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."
|
40
|
+
RESTRICT_ON_SEND = [:depends].freeze
|
41
|
+
|
42
|
+
def_node_matcher :legacy_depends?, <<-PATTERN
|
43
|
+
(send nil? :depends (str {"libarchive" "windows_dns" "windows_uac" "windows_dfs"}) ... )
|
44
|
+
PATTERN
|
45
|
+
|
46
|
+
def on_send(node)
|
47
|
+
legacy_depends?(node) do
|
48
|
+
add_offense(node, message: MSG, severity: :refactor) do |corrector|
|
49
|
+
corrector.remove(range_with_surrounding_space(range: node.loc.expression, side: :left))
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
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 kernel_module cookbook made obsolete by Chef Infra Client 14.3. The kernel_module resource is now included in Chef Infra Client itself.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
#
|
26
|
+
# #### incorrect
|
27
|
+
# depends 'kernel_module'
|
28
|
+
#
|
29
|
+
class DependsOnKernelModuleCookbook < Base
|
30
|
+
extend AutoCorrector
|
31
|
+
extend TargetChefVersion
|
32
|
+
include RangeHelp
|
33
|
+
|
34
|
+
minimum_target_chef_version '14.3'
|
35
|
+
|
36
|
+
MSG = "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."
|
37
|
+
RESTRICT_ON_SEND = [:depends].freeze
|
38
|
+
|
39
|
+
def_node_matcher :legacy_depends?, <<-PATTERN
|
40
|
+
(send nil? :depends (str "kernel_module") ... )
|
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,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 locale cookbook made obsolete by Chef Infra Client 14.5. The locale resource is now included in Chef Infra Client itself.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
#
|
26
|
+
# #### incorrect
|
27
|
+
# depends 'locale'
|
28
|
+
#
|
29
|
+
class DependsOnLocaleCookbook < Base
|
30
|
+
extend AutoCorrector
|
31
|
+
extend TargetChefVersion
|
32
|
+
include RangeHelp
|
33
|
+
|
34
|
+
minimum_target_chef_version '14.5'
|
35
|
+
|
36
|
+
MSG = "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."
|
37
|
+
RESTRICT_ON_SEND = [:depends].freeze
|
38
|
+
|
39
|
+
def_node_matcher :legacy_depends?, <<-PATTERN
|
40
|
+
(send nil? :depends (str "locale") ... )
|
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,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 resource 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 resource 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,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 timezone_lwrp cookbook made obsolete by Chef Infra Client 14.6. The timezone resource is now included in Chef Infra Client itself.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
#
|
26
|
+
# #### incorrect
|
27
|
+
# depends 'timezone_lwrp'
|
28
|
+
#
|
29
|
+
class DependsOnTimezoneLwrpCookbook < Base
|
30
|
+
extend AutoCorrector
|
31
|
+
extend TargetChefVersion
|
32
|
+
include RangeHelp
|
33
|
+
|
34
|
+
minimum_target_chef_version '14.6'
|
35
|
+
|
36
|
+
MSG = "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."
|
37
|
+
RESTRICT_ON_SEND = [:depends].freeze
|
38
|
+
|
39
|
+
def_node_matcher :legacy_depends?, <<-PATTERN
|
40
|
+
(send nil? :depends (str "timezone_lwrp") ... )
|
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,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 windows_firewall cookbook made obsolete by Chef Infra Client 14.7. The windows_firewall resource is now included in Chef Infra Client itself.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
#
|
26
|
+
# #### incorrect
|
27
|
+
# depends 'windows_firewall'
|
28
|
+
#
|
29
|
+
class DependsOnWindowsFirewallCookbook < Base
|
30
|
+
extend AutoCorrector
|
31
|
+
extend TargetChefVersion
|
32
|
+
include RangeHelp
|
33
|
+
|
34
|
+
minimum_target_chef_version '14.7'
|
35
|
+
|
36
|
+
MSG = "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."
|
37
|
+
RESTRICT_ON_SEND = [:depends].freeze
|
38
|
+
|
39
|
+
def_node_matcher :legacy_depends?, <<-PATTERN
|
40
|
+
(send nil? :depends (str "windows_firewall") ... )
|
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
|
@@ -19,11 +19,13 @@ module RuboCop
|
|
19
19
|
module Cop
|
20
20
|
module Chef
|
21
21
|
module Modernize
|
22
|
-
# Use the archive_file resource built into Chef Infra Client 15+ instead of the libarchive_file resource.
|
22
|
+
# Use the archive_file resource built into Chef Infra Client 15+ instead of the libarchive_file resource from the libarchive cookbook.
|
23
23
|
#
|
24
24
|
# @example
|
25
25
|
#
|
26
26
|
# #### incorrect
|
27
|
+
# depends 'libarchive'
|
28
|
+
#
|
27
29
|
# libarchive_file "C:\file.zip" do
|
28
30
|
# path 'C:\expand_here'
|
29
31
|
# end
|
@@ -39,7 +41,7 @@ module RuboCop
|
|
39
41
|
|
40
42
|
minimum_target_chef_version '15.0'
|
41
43
|
|
42
|
-
MSG = 'Use the archive_file resource built into Chef Infra Client 15+ instead of the libarchive file resource'
|
44
|
+
MSG = 'Use the archive_file resource built into Chef Infra Client 15+ instead of the libarchive file resource from the libarchive cookbook'
|
43
45
|
RESTRICT_ON_SEND = [:libarchive_file, :notifies, :subscribes].freeze
|
44
46
|
|
45
47
|
def_node_matcher :notification_property?, <<-PATTERN
|
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.20.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-08-
|
12
|
+
date: 2021-08-19 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.19.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.19.0
|
28
28
|
description:
|
29
29
|
email:
|
30
30
|
- thom@chef.io
|
@@ -78,6 +78,7 @@ files:
|
|
78
78
|
- lib/rubocop/cop/chef/correctness/octal_mode_as_string.rb
|
79
79
|
- lib/rubocop/cop/chef/correctness/openssl_password_helpers.rb
|
80
80
|
- lib/rubocop/cop/chef/correctness/powershell_delete_file.rb
|
81
|
+
- lib/rubocop/cop/chef/correctness/powershell_file_exists.rb
|
81
82
|
- lib/rubocop/cop/chef/correctness/property_without_type.rb
|
82
83
|
- lib/rubocop/cop/chef/correctness/resource_sets_internal_properties.rb
|
83
84
|
- lib/rubocop/cop/chef/correctness/resource_sets_name_property.rb
|
@@ -99,13 +100,17 @@ files:
|
|
99
100
|
- lib/rubocop/cop/chef/deprecation/chefspec_coverage_report.rb
|
100
101
|
- lib/rubocop/cop/chef/deprecation/chefspec_legacy_runner.rb
|
101
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
|
102
105
|
- lib/rubocop/cop/chef/deprecation/depends_compat_resource.rb
|
106
|
+
- lib/rubocop/cop/chef/deprecation/depends_omnibus_updater_cookbook.rb
|
103
107
|
- lib/rubocop/cop/chef/deprecation/depends_partial_search.rb
|
104
108
|
- lib/rubocop/cop/chef/deprecation/depends_poise.rb
|
105
109
|
- lib/rubocop/cop/chef/deprecation/deprecated_chefspec_platform.rb
|
106
110
|
- lib/rubocop/cop/chef/deprecation/deprecated_mixins.rb
|
107
111
|
- lib/rubocop/cop/chef/deprecation/deprecated_platform_methods.rb
|
108
112
|
- lib/rubocop/cop/chef/deprecation/deprecated_shellout_methods.rb
|
113
|
+
- lib/rubocop/cop/chef/deprecation/deprecated_sudo_actions.rb
|
109
114
|
- lib/rubocop/cop/chef/deprecation/deprecated_windows_version_check.rb
|
110
115
|
- lib/rubocop/cop/chef/deprecation/deprecated_yum_repository_actions.rb
|
111
116
|
- lib/rubocop/cop/chef/deprecation/deprecated_yum_repository_properties.rb
|
@@ -174,6 +179,7 @@ files:
|
|
174
179
|
- lib/rubocop/cop/chef/modernize/berksfile_source.rb
|
175
180
|
- lib/rubocop/cop/chef/modernize/build_essential.rb
|
176
181
|
- lib/rubocop/cop/chef/modernize/chef_14_resources.rb
|
182
|
+
- lib/rubocop/cop/chef/modernize/chef_15_resources.rb
|
177
183
|
- lib/rubocop/cop/chef/modernize/chef_gem_nokogiri.rb
|
178
184
|
- lib/rubocop/cop/chef/modernize/compile_time_resources.rb
|
179
185
|
- lib/rubocop/cop/chef/modernize/conditional_using_test.rb
|
@@ -183,6 +189,13 @@ files:
|
|
183
189
|
- lib/rubocop/cop/chef/modernize/default_action_initializer.rb
|
184
190
|
- lib/rubocop/cop/chef/modernize/defines_chefspec_matchers.rb
|
185
191
|
- lib/rubocop/cop/chef/modernize/definitions.rb
|
192
|
+
- lib/rubocop/cop/chef/modernize/depends_chef_vault_cookbook.rb
|
193
|
+
- lib/rubocop/cop/chef/modernize/depends_chocolatey_cookbooks.rb
|
194
|
+
- lib/rubocop/cop/chef/modernize/depends_kernel_module_cookbook.rb
|
195
|
+
- lib/rubocop/cop/chef/modernize/depends_locale_cookbook.rb
|
196
|
+
- lib/rubocop/cop/chef/modernize/depends_openssl_cookbook.rb
|
197
|
+
- lib/rubocop/cop/chef/modernize/depends_timezone_lwrp_cookbook.rb
|
198
|
+
- lib/rubocop/cop/chef/modernize/depends_windows_firewall_cookbook.rb
|
186
199
|
- lib/rubocop/cop/chef/modernize/depends_zypper_cookbook.rb
|
187
200
|
- lib/rubocop/cop/chef/modernize/dsl_include_in_resource.rb
|
188
201
|
- lib/rubocop/cop/chef/modernize/empty_resource_initialize.rb
|