cookstyle 7.15.4 → 7.19.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 60334725cb29031e7b6ab778a3bf005fb5ccb32e18b662155a7717b7c806398c
4
- data.tar.gz: ce345f091b1124d7b5e9dd2284e973eab41412e31653a988a72de61ec38ffd84
3
+ metadata.gz: 61c40a5894885af02650005d23a37fd8409f68286e748b17d14e96ae0fe0243f
4
+ data.tar.gz: 367b410c6654f7513e80138a389870d75810e7020feefe46b9586e76dd1821f3
5
5
  SHA512:
6
- metadata.gz: 3c575e4f1afdb3c162cfdfedad396226b4ae43411c0ef3e75e277904ceed392e65b930076fb51f08a6cfd91de1fa9925cf8d56d804ad763973157edca5228593
7
- data.tar.gz: c25278524868aadc4895d1ed7dab6fe8d59187ff5b946befcebf6e51a2366e34129f1f84ac82177adbe7b5e1251847335fdcc64d96697f45cb2a2e3009535517
6
+ metadata.gz: 2cced7f9b44a843941f8545bcbfa44996e5113227a6972be695f3acb86f2e7692c33f657f41617b12508a3523b3427612c55be6c071f56321819387efaf00a57
7
+ data.tar.gz: f0bbf8ce69ae9165c47a781654bca44904d2261269771fe117276ed9b63e6e857fe03717015e52100fa545d7c49c2a5658ca355d64a090dfc484ea6811a77b21
data/config/cookstyle.yml CHANGED
@@ -481,6 +481,23 @@ Chef/Correctness/OctalModeAsString:
481
481
  - '**/metadata.rb'
482
482
  - '**/Berksfile'
483
483
 
484
+ Chef/Correctness/MetadataMalformedDepends:
485
+ Description: Don't represent file modes as strings containing octal values. Use standard base 10 file modes instead.
486
+ StyleGuide: 'chef_correctness_metadatamalformeddepends'
487
+ Enabled: true
488
+ VersionAdded: '7.16'
489
+ Include:
490
+ - '**/metadata.rb'
491
+
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.
494
+ StyleGuide: 'chef_correctness_powershellfileexists'
495
+ Enabled: true
496
+ VersionAdded: '7.19'
497
+ Exclude:
498
+ - '**/metadata.rb'
499
+ - '**/Berksfile'
500
+
484
501
  ###############################
485
502
  # Chef/Sharing: Issues that prevent sharing code with other teams or with the Chef community in general
486
503
  ###############################
@@ -1217,6 +1234,18 @@ Chef/Deprecations/PolicyfileCommunitySource:
1217
1234
  Include:
1218
1235
  - '**/Policyfile.rb'
1219
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
+
1220
1249
  ###############################
1221
1250
  # Chef/Modernize: Cleaning up legacy code and using new built-in resources
1222
1251
  ###############################
@@ -1243,7 +1272,7 @@ Chef/Modernize/WhyRunSupportedTrue:
1243
1272
  - '**/libraries/*.rb'
1244
1273
 
1245
1274
  Chef/Modernize/UnnecessaryDependsChef14:
1246
- 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.
1275
+ 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.
1247
1276
  StyleGuide: 'chef_modernize_unnecessarydependschef14'
1248
1277
  Enabled: true
1249
1278
  VersionAdded: '5.1.0'
@@ -1369,7 +1398,7 @@ Chef/Modernize/SevenZipArchiveResource:
1369
1398
  - '**/metadata.rb'
1370
1399
 
1371
1400
  Chef/Modernize/LibarchiveFileResource:
1372
- Description: Use the archive_file resource built into Chef Infra Client 15+ instead of the libarchive file resource
1401
+ Description: Use the archive_file resource built into Chef Infra Client 15+ instead of the libarchive file resource from the libarchive cookbook
1373
1402
  StyleGuide: 'chef_modernize_libarchivefileresource'
1374
1403
  Enabled: true
1375
1404
  VersionAdded: '5.5.0'
@@ -1779,6 +1808,46 @@ Chef/Modernize/ActionMethodInResource:
1779
1808
  - '**/resources/*.rb'
1780
1809
  - '**/providers/*.rb'
1781
1810
 
1811
+ Chef/Modernize/UnnecessaryDependsChef15:
1812
+ 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.
1813
+ StyleGuide: 'chef_modernize_unnecessarydependschef15'
1814
+ Enabled: true
1815
+ VersionAdded: '7.19.0'
1816
+ Include:
1817
+ - '**/metadata.rb'
1818
+
1819
+ Chef/Modernize/DependsOnLocaleCookbook:
1820
+ 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.
1821
+ StyleGuide: 'chef_modernize_dependsonlocalecookbook'
1822
+ Enabled: true
1823
+ VersionAdded: '7.19.0'
1824
+ Include:
1825
+ - '**/metadata.rb'
1826
+
1827
+ Chef/Modernize/DependsOnTimezoneLwrpCookbook:
1828
+ 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.
1829
+ StyleGuide: 'chef_modernize_dependsontimezonelwrpcookbook'
1830
+ Enabled: true
1831
+ VersionAdded: '7.19.0'
1832
+ Include:
1833
+ - '**/metadata.rb'
1834
+
1835
+ Chef/Modernize/DependsOnWindowsFirewallCookbook:
1836
+ 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.
1837
+ StyleGuide: 'chef_modernize_dependsonwindowsfirewallcookbook'
1838
+ Enabled: true
1839
+ VersionAdded: '7.19.0'
1840
+ Include:
1841
+ - '**/metadata.rb'
1842
+
1843
+ Chef/Modernize/DependsOnKernelModuleCookbook:
1844
+ 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.
1845
+ StyleGuide: 'chef_modernize_dependsonkernelmodulecookbook'
1846
+ Enabled: true
1847
+ VersionAdded: '7.19.0'
1848
+ Include:
1849
+ - '**/metadata.rb'
1850
+
1782
1851
  ###############################
1783
1852
  # Chef/RedundantCode: Cleanup unnecessary code in your cookbooks regardless of Chef Infra Client release
1784
1853
  ###############################
@@ -2450,6 +2519,8 @@ Lint/HandleExceptions:
2450
2519
  Enabled: true
2451
2520
  Lint/ImplicitStringConcatenation:
2452
2521
  Enabled: true
2522
+ Exclude:
2523
+ - '**/metadata.rb' # this prevents conflicts with Chef/Correctness/MetadataMalformedDepends
2453
2524
  Lint/IneffectiveAccessModifier:
2454
2525
  Enabled: true
2455
2526
  Lint/LiteralAsCondition:
@@ -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.7'
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.16'
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: '#one-line-cases'
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: '0.36'
4939
+ VersionChanged: '1.19'
4923
4940
  EnforcedStyle: percent
4924
4941
  SupportedStyles:
4925
4942
  # percent style: %w(word1 word2)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  module Cookstyle
3
- VERSION = "7.15.4" # rubocop: disable Style/StringLiterals
4
- RUBOCOP_VERSION = '1.18.4'
3
+ VERSION = "7.19.0" # rubocop: disable Style/StringLiterals
4
+ RUBOCOP_VERSION = '1.19.0'
5
5
  end
@@ -0,0 +1,58 @@
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
+ # metadata.rb cookbook dependencies and version constraints should be comma separated
23
+ #
24
+ # @example
25
+ #
26
+ # #### incorrect
27
+ # depends 'some_awesome_cookbook' '= 4.5.5'
28
+ # depends 'some_other_cool_cookbook' '< 8.0'
29
+ #
30
+ # #### correct
31
+ # depends 'some_awesome_cookbook', '= 4.5.5'
32
+ # depends 'some_other_cool_cookbook', '< 8.0'
33
+ #
34
+ class MetadataMalformedDepends < Base
35
+ extend RuboCop::Cop::AutoCorrector
36
+
37
+ RESTRICT_ON_SEND = [:depends].freeze
38
+ MSG = 'metadata.rb cookbook dependencies and version constraints should be comma separated'
39
+
40
+ def_node_matcher :depends_without_comma?, <<-PATTERN
41
+ (send nil? :depends
42
+ (dstr
43
+ $(str _ )
44
+ $(str _ )))
45
+ PATTERN
46
+
47
+ def on_send(node)
48
+ depends_without_comma?(node) do |cb, ver|
49
+ add_offense(node, message: MSG, severity: :refactor) do |corrector|
50
+ corrector.replace(node, "depends '#{cb.value}', '#{ver.value}'")
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  #
3
- # Copyright:: 2019, Chef Software Inc.
3
+ # Copyright:: 2019-2021, Chef Software Inc.
4
4
  # Author:: Tim Smith (<tsmith@chef.io>)
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -27,6 +27,7 @@ module RuboCop
27
27
  # name 'foo'
28
28
  #
29
29
  class MetadataMissingName < Base
30
+ extend AutoCorrector
30
31
  include RangeHelp
31
32
 
32
33
  MSG = 'metadata.rb needs to include the name method or it will fail on Chef Infra Client 12 and later.'
@@ -37,11 +38,10 @@ module RuboCop
37
38
  # Using range similar to RuboCop::Cop::Naming::Filename (file_name.rb)
38
39
  return if cb_name?(processed_source.ast)
39
40
  range = source_range(processed_source.buffer, 1, 0)
40
- add_offense(range, message: MSG, severity: :refactor) do |_corrector|
41
+ add_offense(range, message: MSG, severity: :refactor) do |corrector|
41
42
  path = processed_source.path
42
43
  cb_name = File.basename(File.dirname(path))
43
- metadata = IO.read(path)
44
- IO.write(path, "name '#{cb_name}'\n" + metadata)
44
+ corrector.insert_before(processed_source.ast, "name '#{cb_name}'\n")
45
45
  end
46
46
  end
47
47
  end
@@ -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') 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') 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,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+. These community cookbooks contain resources that are now included in Chef Infra Client itself.
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 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 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.15.4
4
+ version: 7.19.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-07-30 00:00:00.000000000 Z
12
+ date: 2021-08-18 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.18.4
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.18.4
27
+ version: 1.19.0
28
28
  description:
29
29
  email:
30
30
  - thom@chef.io
@@ -69,6 +69,7 @@ files:
69
69
  - lib/rubocop/cop/chef/correctness/lazy_in_resource_guard.rb
70
70
  - lib/rubocop/cop/chef/correctness/macos_userdefaults_invalid_type.rb
71
71
  - lib/rubocop/cop/chef/correctness/malformed_value_for_platform.rb
72
+ - lib/rubocop/cop/chef/correctness/metadata_malformed_version.rb
72
73
  - lib/rubocop/cop/chef/correctness/metadata_missing_name.rb
73
74
  - lib/rubocop/cop/chef/correctness/node_normal.rb
74
75
  - lib/rubocop/cop/chef/correctness/node_normal_unless.rb
@@ -77,6 +78,7 @@ files:
77
78
  - lib/rubocop/cop/chef/correctness/octal_mode_as_string.rb
78
79
  - lib/rubocop/cop/chef/correctness/openssl_password_helpers.rb
79
80
  - lib/rubocop/cop/chef/correctness/powershell_delete_file.rb
81
+ - lib/rubocop/cop/chef/correctness/powershell_file_exists.rb
80
82
  - lib/rubocop/cop/chef/correctness/property_without_type.rb
81
83
  - lib/rubocop/cop/chef/correctness/resource_sets_internal_properties.rb
82
84
  - lib/rubocop/cop/chef/correctness/resource_sets_name_property.rb
@@ -105,6 +107,7 @@ files:
105
107
  - lib/rubocop/cop/chef/deprecation/deprecated_mixins.rb
106
108
  - lib/rubocop/cop/chef/deprecation/deprecated_platform_methods.rb
107
109
  - lib/rubocop/cop/chef/deprecation/deprecated_shellout_methods.rb
110
+ - lib/rubocop/cop/chef/deprecation/deprecated_sudo_actions.rb
108
111
  - lib/rubocop/cop/chef/deprecation/deprecated_windows_version_check.rb
109
112
  - lib/rubocop/cop/chef/deprecation/deprecated_yum_repository_actions.rb
110
113
  - lib/rubocop/cop/chef/deprecation/deprecated_yum_repository_properties.rb
@@ -173,6 +176,7 @@ files:
173
176
  - lib/rubocop/cop/chef/modernize/berksfile_source.rb
174
177
  - lib/rubocop/cop/chef/modernize/build_essential.rb
175
178
  - lib/rubocop/cop/chef/modernize/chef_14_resources.rb
179
+ - lib/rubocop/cop/chef/modernize/chef_15_resources.rb
176
180
  - lib/rubocop/cop/chef/modernize/chef_gem_nokogiri.rb
177
181
  - lib/rubocop/cop/chef/modernize/compile_time_resources.rb
178
182
  - lib/rubocop/cop/chef/modernize/conditional_using_test.rb
@@ -182,6 +186,10 @@ files:
182
186
  - lib/rubocop/cop/chef/modernize/default_action_initializer.rb
183
187
  - lib/rubocop/cop/chef/modernize/defines_chefspec_matchers.rb
184
188
  - lib/rubocop/cop/chef/modernize/definitions.rb
189
+ - lib/rubocop/cop/chef/modernize/depends_kernel_module_cookbook.rb
190
+ - lib/rubocop/cop/chef/modernize/depends_locale_cookbook.rb
191
+ - lib/rubocop/cop/chef/modernize/depends_timezone_lwrp_cookbook.rb
192
+ - lib/rubocop/cop/chef/modernize/depends_windows_firewall_cookbook.rb
185
193
  - lib/rubocop/cop/chef/modernize/depends_zypper_cookbook.rb
186
194
  - lib/rubocop/cop/chef/modernize/dsl_include_in_resource.rb
187
195
  - lib/rubocop/cop/chef/modernize/empty_resource_initialize.rb