cookstyle 7.21.0 → 7.25.6

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: 48e9eba9990f29d5ece83efea73a5ceba5c49ed781909b437c40c43da790210a
4
- data.tar.gz: 9f177a0a2cadc3cb703ec87337bd4485e872ae748d9af95f53473dec22eebd7d
3
+ metadata.gz: 1a67abdf6a42bec1022fc57e53a61a9aa6f371641e6afe429eee6a9489ff2355
4
+ data.tar.gz: c3ff11c1e6ef1be4af29d034d662a6b662a731103082477b0d8d0e9e3a0455e2
5
5
  SHA512:
6
- metadata.gz: fbeebdde748ba5abca797bf203ab8465c74e1b1714847d27e35576b3801daae3e962b9bfb3516c84f684e69a3088535d8811ea7df74005f6262005bb844295a7
7
- data.tar.gz: 4e3c683249684fdae3717f88b9ea92c9eb26147d55eb90e43e024f7c0ce03870d03c66b4f2c7ad6eb9c057cf1eb687ce28ed44efea7b2a61e5a9002b3b143628
6
+ metadata.gz: 79074fc5f3c7ef245dbcb64a4739a49298cda263bc216333215599bbc7e052f0979981e67572eec6d77b33c8e620370087b32ad20f90d2c5f5ddcbfaf99182cc
7
+ data.tar.gz: 116535d0ada1a04fd19bb9af708390402aeeb983a962af1a681d66e9f9fa81afc515450f1bcae187dcf8de83876a8fd5c9a091ea0d93313033821f34263f51a8
data/Gemfile CHANGED
@@ -6,8 +6,6 @@ gemspec
6
6
 
7
7
  group :debug do
8
8
  gem 'pry'
9
- gem 'pry-byebug'
10
- gem 'pry-stack_explorer', '< 0.4.13' # 0.4.13+ drops support for Ruby < 2.6
11
9
  end
12
10
 
13
11
  group :docs do
@@ -15,8 +13,10 @@ group :docs do
15
13
  end
16
14
 
17
15
  group :profiling do
18
- gem 'memory_profiler'
19
- gem 'stackprof'
16
+ platforms :ruby do
17
+ gem 'memory_profiler'
18
+ gem 'stackprof'
19
+ end
20
20
  end
21
21
 
22
22
  group :rubocop_gems do
data/config/cookstyle.yml CHANGED
@@ -498,6 +498,14 @@ Chef/Correctness/PowershellFileExists:
498
498
  - '**/metadata.rb'
499
499
  - '**/Berksfile'
500
500
 
501
+ Chef/Correctness/MetadataMissingVersion:
502
+ Description: metadata.rb should define a version for the cookbook.
503
+ StyleGuide: 'chef_correctness_metadatamissingversion'
504
+ Enabled: true
505
+ VersionAdded: '7.25'
506
+ Include:
507
+ - '**/metadata.rb'
508
+
501
509
  ###############################
502
510
  # Chef/Sharing: Issues that prevent sharing code with other teams or with the Chef community in general
503
511
  ###############################
@@ -979,7 +987,7 @@ Chef/Deprecations/DeprecatedPlatformMethods:
979
987
  - '**/providers/*.rb'
980
988
 
981
989
  Chef/Deprecations/DeprecatedChefSpecPlatform:
982
- Description: Use currently supported platforms in ChefSpec listed at https://github.com/chefspec/fauxhai/blob/master/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
990
+ Description: Use currently supported platforms in ChefSpec listed at https://github.com/chefspec/fauxhai/blob/main/PLATFORMS.md. Fauxhai / ChefSpec will perform fuzzy matching on platform version so it's always best to be less specific ie. 10 instead of 10.3
983
991
  StyleGuide: 'chef_deprecations_deprecatedchefspecplatform'
984
992
  Enabled: true
985
993
  VersionAdded: '5.20.0'
@@ -1198,7 +1206,7 @@ Chef/Deprecations/DeprecatedYumRepositoryActions:
1198
1206
  - '**/Rakefile'
1199
1207
 
1200
1208
  Chef/Deprecations/ChefSugarHelpers:
1201
- Description: Do not use legacy chef-sugar helper methods, which will not be moved into Chef Infra Client itself. For a complete set of chef-sugar helpers now shipping in Chef Infra Client itself see https://github.com/chef/chef/tree/master/chef-utils#getting-started
1209
+ Description: Do not use legacy chef-sugar helper methods, which will not be moved into Chef Infra Client itself. For a complete set of chef-sugar helpers now shipping in Chef Infra Client itself see https://github.com/chef/chef/tree/main/chef-utils#getting-started
1202
1210
  StyleGuide: 'chef_deprecations_chefsugarhelpers'
1203
1211
  Enabled: true
1204
1212
  VersionAdded: '7.3.0'
@@ -1897,7 +1905,7 @@ Chef/Modernize/DependsOnOpensslCookbook:
1897
1905
  - '**/metadata.rb'
1898
1906
 
1899
1907
  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.
1908
+ Description: Chef Infra Client 15.5 and later include a large number of new helpers in the Chef Infra Language to simplify checking the system configuration in recipes and resources. These should be used when possible over more complex attributes or ENV var comparisons.
1901
1909
  StyleGuide: 'chef_modernize_usecheflanguageenvhelpers'
1902
1910
  Enabled: true
1903
1911
  VersionAdded: '7.21.0'
@@ -1906,6 +1914,33 @@ Chef/Modernize/UseChefLanguageEnvHelpers:
1906
1914
  - '**/providers/*.rb'
1907
1915
  - '**/recipes/*.rb'
1908
1916
 
1917
+ Chef/Modernize/UseChefLanguageCloudHelpers:
1918
+ Description: Chef Infra Client 15.5 and later include cloud helpers to make detecting instances that run on public and private clouds easier.
1919
+ StyleGuide: 'chef_modernize_usecheflanguagecloudhelpers'
1920
+ Enabled: true
1921
+ VersionAdded: '7.22.0'
1922
+ Include:
1923
+ - '**/resources/*.rb'
1924
+ - '**/providers/*.rb'
1925
+ - '**/recipes/*.rb'
1926
+
1927
+ Chef/Modernize/ClassEvalActionClass:
1928
+ Description: In Chef Infra Client 12.9 and later it is no longer necessary to call the class_eval method on the action class block.
1929
+ StyleGuide: 'chef_modernize_classevalactionclass'
1930
+ Enabled: true
1931
+ VersionAdded: '7.23.0'
1932
+ Include:
1933
+ - '**/resources/*.rb'
1934
+
1935
+ Chef/Modernize/UseChefLanguageSystemdHelper:
1936
+ Description: Chef Infra Client 15.5 and later include a `systemd?` helper for checking if a Linux system uses systemd.
1937
+ StyleGuide: 'chef_modernize_usecheflanguagesystemdhelper'
1938
+ Enabled: true
1939
+ VersionAdded: '7.24.0'
1940
+ Exclude:
1941
+ - '**/metadata.rb'
1942
+ - '**/Berksfile'
1943
+
1909
1944
  ###############################
1910
1945
  # Chef/RedundantCode: Cleanup unnecessary code in your cookbooks regardless of Chef Infra Client release
1911
1946
  ###############################
@@ -2778,6 +2813,7 @@ Style/GuardClause:
2778
2813
  # Users really shouldn't have a gem, but if they do they should do it securely
2779
2814
  Bundler/InsecureProtocolSource:
2780
2815
  Enabled: true
2816
+ AllowHttpProtocol: false
2781
2817
 
2782
2818
  # It's easier to read a simple .each and they're faster
2783
2819
  Lint/RedundantWithIndex:
@@ -5,6 +5,8 @@ Bundler/DuplicatedGem:
5
5
  Enabled: false
6
6
  Bundler/GemComment:
7
7
  Enabled: false
8
+ Bundler/GemFilename:
9
+ Enabled: false
8
10
  Bundler/GemVersion:
9
11
  Enabled: false
10
12
  Bundler/InsecureProtocolSource:
@@ -219,6 +221,8 @@ Lint/AmbiguousBlockAssociation:
219
221
  Enabled: false
220
222
  Lint/AmbiguousOperator:
221
223
  Enabled: false
224
+ Lint/AmbiguousOperatorPrecedence:
225
+ Enabled: false
222
226
  Lint/AmbiguousRange:
223
227
  Enabled: false
224
228
  Lint/AmbiguousRegexpLiteral:
@@ -305,10 +309,12 @@ Lint/IdentityComparison:
305
309
  Enabled: false
306
310
  Lint/ImplicitStringConcatenation:
307
311
  Enabled: false
308
- Lint/InheritException:
312
+ Lint/IncompatibleIoSelectWithFiberScheduler:
309
313
  Enabled: false
310
314
  Lint/IneffectiveAccessModifier:
311
315
  Enabled: false
316
+ Lint/InheritException:
317
+ Enabled: false
312
318
  Lint/InterpolationCheck:
313
319
  Enabled: false
314
320
  Lint/LambdaWithoutLiteralBlock:
@@ -381,6 +387,8 @@ Lint/RegexpAsCondition:
381
387
  Enabled: false
382
388
  Lint/RequireParentheses:
383
389
  Enabled: false
390
+ Lint/RequireRelativeSelfPath:
391
+ Enabled: false
384
392
  Lint/RescueException:
385
393
  Enabled: false
386
394
  Lint/RescueType:
@@ -699,6 +707,8 @@ Style/MethodCallWithArgsParentheses:
699
707
  Enabled: false
700
708
  Style/MultilineInPatternThen:
701
709
  Enabled: false
710
+ Style/NumberedParameters:
711
+ Enabled: false
702
712
  Style/RedundantAssignment:
703
713
  Enabled: false
704
714
  Style/RedundantFetchBlock:
@@ -771,6 +781,8 @@ Style/NonNilCheck:
771
781
  Enabled: false
772
782
  Style/Not:
773
783
  Enabled: false
784
+ Style/NumberedParametersLimit:
785
+ Enabled: false
774
786
  Style/NumericLiterals:
775
787
  Enabled: false
776
788
  Style/NumericLiteralPrefix:
@@ -851,6 +863,8 @@ Style/SafeNavigation:
851
863
  Enabled: false
852
864
  Style/Sample:
853
865
  Enabled: false
866
+ Style/SelectByRegexp:
867
+ Enabled: false
854
868
  Style/SelfAssignment:
855
869
  Enabled: false
856
870
  Style/Semicolon:
@@ -943,6 +957,8 @@ Style/ZeroLengthPredicate:
943
957
  Enabled: false
944
958
  Security/Eval:
945
959
  Enabled: false
960
+ Security/IoMethods:
961
+ Enabled: false
946
962
  Security/JSONLoad:
947
963
  Enabled: false
948
964
  Security/MarshalLoad:
data/config/upstream.yml CHANGED
@@ -130,7 +130,7 @@ AllCops:
130
130
  # What MRI version of the Ruby interpreter is the inspected code intended to
131
131
  # run on? (If there is more than one, set this to the lowest version.)
132
132
  # If a value is specified for TargetRubyVersion then it is used. Acceptable
133
- # values are specificed as a float (i.e. 3.0); the teeny version of Ruby
133
+ # values are specified as a float (i.e. 3.0); the teeny version of Ruby
134
134
  # should not be included. If the project specifies a Ruby version in the
135
135
  # .tool-versions or .ruby-version files, Gemfile or gems.rb file, RuboCop will
136
136
  # try to determine the desired version of Ruby by inspecting the
@@ -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
@@ -195,6 +209,7 @@ Bundler/InsecureProtocolSource:
195
209
  'https://rubygems.org' if possible, or 'http://rubygems.org' if not.
196
210
  Enabled: true
197
211
  VersionAdded: '0.50'
212
+ AllowHttpProtocol: true
198
213
  Include:
199
214
  - '**/*.gemfile'
200
215
  - '**/Gemfile'
@@ -943,7 +958,6 @@ Layout/LineLength:
943
958
  Enabled: true
944
959
  VersionAdded: '0.25'
945
960
  VersionChanged: '1.4'
946
- AutoCorrect: true
947
961
  Max: 120
948
962
  # To make it possible to copy or click on URIs in the code, we allow lines
949
963
  # containing a URI to be longer than Max.
@@ -1347,10 +1361,11 @@ Layout/SpaceInsideParens:
1347
1361
  StyleGuide: '#spaces-braces'
1348
1362
  Enabled: true
1349
1363
  VersionAdded: '0.49'
1350
- VersionChanged: '0.55'
1364
+ VersionChanged: '1.22'
1351
1365
  EnforcedStyle: no_space
1352
1366
  SupportedStyles:
1353
1367
  - space
1368
+ - compact
1354
1369
  - no_space
1355
1370
 
1356
1371
  Layout/SpaceInsidePercentLiteralDelimiters:
@@ -1434,6 +1449,13 @@ Lint/AmbiguousOperator:
1434
1449
  VersionAdded: '0.17'
1435
1450
  VersionChanged: '0.83'
1436
1451
 
1452
+ Lint/AmbiguousOperatorPrecedence:
1453
+ Description: >-
1454
+ Checks for expressions containing multiple binary operations with
1455
+ ambiguous precedence.
1456
+ Enabled: pending
1457
+ VersionAdded: '1.21'
1458
+
1437
1459
  Lint/AmbiguousRange:
1438
1460
  Description: Checks for ranges with ambiguous boundaries.
1439
1461
  Enabled: pending
@@ -1471,9 +1493,9 @@ Lint/BinaryOperatorWithIdenticalOperands:
1471
1493
  Lint/BooleanSymbol:
1472
1494
  Description: 'Check for `:true` and `:false` symbols.'
1473
1495
  Enabled: true
1474
- Safe: false
1496
+ SafeAutoCorrect: false
1475
1497
  VersionAdded: '0.50'
1476
- VersionChanged: '0.83'
1498
+ VersionChanged: '1.22'
1477
1499
 
1478
1500
  Lint/CircularArgumentReference:
1479
1501
  Description: "Default values in optional keyword arguments and optional ordinal arguments should not refer back to the name of the argument."
@@ -1519,6 +1541,11 @@ Lint/Debugger:
1519
1541
  Capybara:
1520
1542
  - save_and_open_page
1521
1543
  - save_and_open_screenshot
1544
+ debug.rb:
1545
+ - binding.b
1546
+ - binding.break
1547
+ - Kernel.binding.b
1548
+ - Kernel.binding.break
1522
1549
  Pry:
1523
1550
  - binding.pry
1524
1551
  - binding.remote_pry
@@ -1527,6 +1554,8 @@ Lint/Debugger:
1527
1554
  Rails:
1528
1555
  - debugger
1529
1556
  - Kernel.debugger
1557
+ RubyJard:
1558
+ - jard
1530
1559
  WebConsole:
1531
1560
  - binding.console
1532
1561
 
@@ -1750,6 +1779,11 @@ Lint/ImplicitStringConcatenation:
1750
1779
  Enabled: true
1751
1780
  VersionAdded: '0.36'
1752
1781
 
1782
+ Lint/IncompatibleIoSelectWithFiberScheduler:
1783
+ Description: 'Checks for `IO.select` that is incompatible with Fiber Scheduler.'
1784
+ Enabled: pending
1785
+ VersionAdded: '1.21'
1786
+
1753
1787
  Lint/IneffectiveAccessModifier:
1754
1788
  Description: >-
1755
1789
  Checks for attempts to use `private` or `protected` to set
@@ -2013,6 +2047,11 @@ Lint/RequireParentheses:
2013
2047
  Enabled: true
2014
2048
  VersionAdded: '0.18'
2015
2049
 
2050
+ Lint/RequireRelativeSelfPath:
2051
+ Description: 'Checks for uses a file requiring itself with `require_relative`.'
2052
+ Enabled: pending
2053
+ VersionAdded: '1.22'
2054
+
2016
2055
  Lint/RescueException:
2017
2056
  Description: 'Avoid rescuing the Exception class.'
2018
2057
  StyleGuide: '#no-blind-rescues'
@@ -2542,8 +2581,9 @@ Naming/HeredocDelimiterNaming:
2542
2581
 
2543
2582
  Naming/InclusiveLanguage:
2544
2583
  Description: 'Recommend the use of inclusive language instead of problematic terms.'
2545
- Enabled: pending
2584
+ Enabled: false
2546
2585
  VersionAdded: '1.18'
2586
+ VersionChanged: '1.21'
2547
2587
  CheckIdentifiers: true
2548
2588
  CheckConstants: true
2549
2589
  CheckVariables: true
@@ -2699,6 +2739,14 @@ Security/Eval:
2699
2739
  Enabled: true
2700
2740
  VersionAdded: '0.47'
2701
2741
 
2742
+ Security/IoMethods:
2743
+ Description: >-
2744
+ Checks for the first argument to `IO.read`, `IO.binread`, `IO.write`, `IO.binwrite`,
2745
+ `IO.foreach`, and `IO.readlines`.
2746
+ Enabled: pending
2747
+ Safe: false
2748
+ VersionAdded: '1.22'
2749
+
2702
2750
  Security/JSONLoad:
2703
2751
  Description: >-
2704
2752
  Prefer usage of `JSON.parse` over `JSON.load` due to potential
@@ -2775,8 +2823,9 @@ Style/AndOr:
2775
2823
  Description: 'Use &&/|| instead of and/or.'
2776
2824
  StyleGuide: '#no-and-or-or'
2777
2825
  Enabled: true
2826
+ SafeAutoCorrect: false
2778
2827
  VersionAdded: '0.9'
2779
- VersionChanged: '0.25'
2828
+ VersionChanged: '1.21'
2780
2829
  # Whether `and` and `or` are banned only in conditionals (conditionals)
2781
2830
  # or completely (always).
2782
2831
  EnforcedStyle: conditionals
@@ -2810,9 +2859,9 @@ Style/ArrayJoin:
2810
2859
  Style/AsciiComments:
2811
2860
  Description: 'Use only ascii symbols in comments.'
2812
2861
  StyleGuide: '#english-comments'
2813
- Enabled: true
2862
+ Enabled: false
2814
2863
  VersionAdded: '0.9'
2815
- VersionChanged: '0.52'
2864
+ VersionChanged: '1.21'
2816
2865
  AllowedChars:
2817
2866
  - ©
2818
2867
 
@@ -2974,7 +3023,7 @@ Style/CaseEquality:
2974
3023
  Enabled: true
2975
3024
  VersionAdded: '0.9'
2976
3025
  VersionChanged: '0.89'
2977
- # If AllowOnConstant is enabled, the cop will ignore violations when the receiver of
3026
+ # If `AllowOnConstant` option is enabled, the cop will ignore violations when the receiver of
2978
3027
  # the case equality operator is a constant.
2979
3028
  #
2980
3029
  # # bad
@@ -3149,7 +3198,7 @@ Style/CommentAnnotation:
3149
3198
  StyleGuide: '#annotate-keywords'
3150
3199
  Enabled: true
3151
3200
  VersionAdded: '0.10'
3152
- VersionChanged: '1.3'
3201
+ VersionChanged: '1.20'
3153
3202
  Keywords:
3154
3203
  - TODO
3155
3204
  - FIXME
@@ -3669,7 +3718,7 @@ Style/InPatternThen:
3669
3718
  Style/InfiniteLoop:
3670
3719
  Description: >-
3671
3720
  Use Kernel#loop for infinite loops.
3672
- This cop is unsafe in the body may raise a `StopIteration` exception.
3721
+ This cop is unsafe if the body may raise a `StopIteration` exception.
3673
3722
  Safe: false
3674
3723
  StyleGuide: '#infinite-loop'
3675
3724
  Enabled: true
@@ -4095,6 +4144,21 @@ Style/Not:
4095
4144
  VersionAdded: '0.9'
4096
4145
  VersionChanged: '0.20'
4097
4146
 
4147
+ Style/NumberedParameters:
4148
+ Description: 'Restrict the usage of numbered parameters.'
4149
+ Enabled: pending
4150
+ VersionAdded: '1.22'
4151
+ EnforcedStyle: allow_single_line
4152
+ SupportedStyles:
4153
+ - allow_single_line
4154
+ - disallow
4155
+
4156
+ Style/NumberedParametersLimit:
4157
+ Description: 'Avoid excessive numbered params in a single block.'
4158
+ Enabled: pending
4159
+ VersionAdded: '1.22'
4160
+ Max: 1
4161
+
4098
4162
  Style/NumericLiteralPrefix:
4099
4163
  Description: 'Use smallcase prefixes for numeric literals.'
4100
4164
  StyleGuide: '#numeric-literal-prefixes'
@@ -4105,7 +4169,6 @@ Style/NumericLiteralPrefix:
4105
4169
  - zero_with_o
4106
4170
  - zero_only
4107
4171
 
4108
-
4109
4172
  Style/NumericLiterals:
4110
4173
  Description: >-
4111
4174
  Add underscores to large numeric literals to improve their
@@ -4426,6 +4489,8 @@ Style/RedundantSort:
4426
4489
  `max_by` instead of `sort_by...last`, etc.
4427
4490
  Enabled: true
4428
4491
  VersionAdded: '0.76'
4492
+ VersionChanged: '1.22'
4493
+ Safe: false
4429
4494
 
4430
4495
  Style/RedundantSortBy:
4431
4496
  Description: 'Use `sort` instead of `sort_by { |x| x }`.'
@@ -4506,6 +4571,12 @@ Style/Sample:
4506
4571
  Enabled: true
4507
4572
  VersionAdded: '0.30'
4508
4573
 
4574
+ Style/SelectByRegexp:
4575
+ Description: 'Prefer grep/grep_v to select/reject with a regexp match.'
4576
+ Enabled: pending
4577
+ SafeAutoCorrect: false
4578
+ VersionAdded: '1.22'
4579
+
4509
4580
  Style/SelfAssignment:
4510
4581
  Description: >-
4511
4582
  Checks for places where self-assignment shorthand should have
@@ -4692,8 +4763,9 @@ Style/StructInheritance:
4692
4763
  Description: 'Checks for inheritance from Struct.new.'
4693
4764
  StyleGuide: '#no-extend-struct-new'
4694
4765
  Enabled: true
4766
+ SafeAutoCorrect: false
4695
4767
  VersionAdded: '0.29'
4696
- VersionChanged: '0.86'
4768
+ VersionChanged: '1.20'
4697
4769
 
4698
4770
  Style/SwapValues:
4699
4771
  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/master/CHANGELOG.md',
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',
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  module Cookstyle
3
- VERSION = "7.21.0" # rubocop: disable Style/StringLiterals
4
- RUBOCOP_VERSION = '1.19.0'
3
+ VERSION = "7.25.6" # rubocop: disable Style/StringLiterals
4
+ RUBOCOP_VERSION = '1.22.0'
5
5
  end
@@ -0,0 +1,48 @@
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 should define a version for the cookbook.
23
+ #
24
+ # @example
25
+ #
26
+ # #### correct
27
+ # name 'foo'
28
+ # version '1.0.0'
29
+ #
30
+ class MetadataMissingVersion < Base
31
+ extend AutoCorrector
32
+ include RangeHelp
33
+
34
+ MSG = 'metadata.rb should define a version for the cookbook.'
35
+
36
+ def_node_search :cb_version?, '(send nil? :version str ...)'
37
+
38
+ def on_new_investigation
39
+ # Using range similar to RuboCop::Cop::Naming::Filename (file_name.rb)
40
+ return if cb_version?(processed_source.ast)
41
+ range = source_range(processed_source.buffer, 1, 0)
42
+ add_offense(range, message: MSG, severity: :refactor)
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ 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/master/chef-utils#getting-started
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/master/chef-utils#getting-started'
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)
@@ -19,7 +19,7 @@ module RuboCop
19
19
  module Cop
20
20
  module Chef
21
21
  module Deprecations
22
- # Use currently supported platforms in ChefSpec listed at https://github.com/chefspec/fauxhai/blob/master/PLATFORMS.md. Fauxhai / ChefSpec will perform fuzzy matching on platform version values so it's always best to be less specific ie. 10 instead of 10.3
22
+ # Use currently supported platforms in ChefSpec listed at https://github.com/chefspec/fauxhai/blob/main/PLATFORMS.md. Fauxhai / ChefSpec will perform fuzzy matching on platform version values so it's always best to be less specific ie. 10 instead of 10.3
23
23
  #
24
24
  # @example
25
25
  #
@@ -29,7 +29,7 @@ module RuboCop
29
29
  include RuboCop::Chef::CookbookHelpers
30
30
  extend AutoCorrector
31
31
 
32
- MSG = "Use currently supported platforms in ChefSpec listed at https://github.com/chefspec/fauxhai/blob/master/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"
32
+ MSG = "Use currently supported platforms in ChefSpec listed at https://github.com/chefspec/fauxhai/blob/main/PLATFORMS.md. Fauxhai / ChefSpec will perform fuzzy matching on platform version so it's always best to be less specific ie. 10 instead of 10.3"
33
33
 
34
34
  DEPRECATED_MAPPING = {
35
35
  'amazon' => {
@@ -19,7 +19,7 @@ module RuboCop
19
19
  module Cop
20
20
  module Chef
21
21
  module Deprecations
22
- # Chef Infra Client 15.3 and later include a new Unified Mode that simplies the execution of resoures by replace the traditional compile and converge phases with a single phase. Unified mode simplies writing advanced resources and avoids confusing errors that often occur when mixing ruby and Chef Infra resources. Chef Infra Client 17.0 and later will beging warning that `unified_mode true` should be set in all resources to validate that they will continue to function in Chef Infra Client 18.0 (April 2022) when Unified Mode becomes the default.
22
+ # Chef Infra Client 15.3 and later include a new Unified Mode that simplifies the execution of resources by replace the traditional compile and converge phases with a single phase. Unified mode simplifies writing advanced resources and avoids confusing errors that often occur when mixing ruby and Chef Infra resources. Chef Infra Client 17.0 and later will begin warning that `unified_mode true` should be set in all resources to validate that they will continue to function in Chef Infra Client 18.0 (April 2022) when Unified Mode becomes the default.
23
23
  #
24
24
  # @example
25
25
  #
@@ -19,7 +19,7 @@ module RuboCop
19
19
  module Cop
20
20
  module Chef
21
21
  module Deprecations
22
- # Chef Infra Client 15.3 and later include a new Unified Mode that simplies the execution of resoures by replace the traditional compile and converge phases with a single phase. Unified mode simplies writing advanced resources and avoids confusing errors that often occur when mixing ruby and Chef Infra resources. Chef Infra Client 17.0 and later will beging warning that `unified_mode true` should be set in all resources to validate that they will continue to function in Chef Infra Client 18.0 (April 2022) when Unified Mode becomes the default.
22
+ # Chef Infra Client 15.3 and later include a new Unified Mode that simplifies the execution of resources by replace the traditional compile and converge phases with a single phase. Unified mode simplifies writing advanced resources and avoids confusing errors that often occur when mixing ruby and Chef Infra resources. Chef Infra Client 17.0 and later will begin warning that `unified_mode true` should be set in all resources to validate that they will continue to function in Chef Infra Client 18.0 (April 2022) when Unified Mode becomes the default.
23
23
  #
24
24
  # @example
25
25
  #
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # Copyright:: 2021, Chef Software, Inc.
4
+ # Author:: Tim Smith (<tsmith@chef.io>)
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+ module RuboCop
19
+ module Cop
20
+ module Chef
21
+ module Modernize
22
+ # In Chef Infra Client 12.9 and later it is no longer necessary to call the class_eval method on the action class block.
23
+ #
24
+ # @example
25
+ #
26
+ # #### incorrect
27
+ # action_class.class_eval do
28
+ # foo
29
+ # end
30
+ #
31
+ # #### correct
32
+ # action_class do
33
+ # foo
34
+ # end
35
+ #
36
+ class ClassEvalActionClass < Base
37
+ extend TargetChefVersion
38
+ extend AutoCorrector
39
+
40
+ minimum_target_chef_version '12.9'
41
+
42
+ MSG = 'In Chef Infra Client 12.9 and later it is no longer necessary to call the class_eval method on the action class block.'
43
+ RESTRICT_ON_SEND = [:include_recipe].freeze
44
+
45
+ def_node_matcher :class_eval_action_class?, <<-PATTERN
46
+ (block
47
+ (send
48
+ (send nil? :action_class) :class_eval)
49
+ (args)
50
+ ... )
51
+ PATTERN
52
+
53
+ def on_block(node)
54
+ class_eval_action_class?(node) do
55
+ add_offense(node, message: MSG, severity: :refactor) do |corrector|
56
+ corrector.replace(node, node.source.gsub('.class_eval', ''))
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -19,22 +19,41 @@ module RuboCop
19
19
  module Cop
20
20
  module Chef
21
21
  module Modernize
22
- # Chef Infra Client 15.5 and later include cloud helpers to make detecting instance that run on public and private clouds easier.
22
+ # Chef Infra Client 15.5 and later include cloud helpers to make detecting instances that run on public and private clouds easier.
23
23
  #
24
24
  # @example
25
25
  #
26
26
  # #### incorrect
27
- # ENV['CI']
28
- # ENV['TEST_KITCHEN']
27
+ # node['cloud']['provider'] == 'alibaba'
28
+ # node['cloud']['provider'] == 'ec2'
29
+ # node['cloud']['provider'] == 'gce'
30
+ # node['cloud']['provider'] == 'rackspace'
31
+ # node['cloud']['provider'] == 'eucalyptus'
32
+ # node['cloud']['provider'] == 'linode'
33
+ # node['cloud']['provider'] == 'openstack'
34
+ # node['cloud']['provider'] == 'azure'
35
+ # node['cloud']['provider'] == 'digital_ocean'
36
+ # node['cloud']['provider'] == 'softlayer'
29
37
  #
30
38
  # #### correct
31
- # ci?
32
- # kitchen?
39
+ # alibaba?
40
+ # ec2?
41
+ # gce?
42
+ # rackspace?
43
+ # eucalyptus?
44
+ # linode?
45
+ # openstack?
46
+ # azure?
47
+ # digital_ocean?
48
+ # softlayer?
33
49
  #
34
50
  class UseChefLanguageCloudHelpers < Base
35
51
  extend AutoCorrector
52
+ extend TargetChefVersion
36
53
 
37
- MSG = 'Chef Infra Client 15.5 and later include cloud helpers to make detecting instance that run on public and private clouds easier.'.freeze
54
+ minimum_target_chef_version '15.5'
55
+
56
+ MSG = 'Chef Infra Client 15.5 and later include cloud helpers to make detecting instances that run on public and private clouds easier.'
38
57
  RESTRICT_ON_SEND = [:==, :[]].freeze
39
58
  VALID_CLOUDS = %w(alibaba ec2 gce rackspace eucalyptus linode openstack azure digital_ocean softlayer).freeze
40
59
 
@@ -48,12 +67,6 @@ module RuboCop
48
67
  (str $_))
49
68
  PATTERN
50
69
 
51
- def_node_matcher :node_check?, <<-PATTERN
52
- (send
53
- (send nil? :node) :[]
54
- (str ${"ec2"}))
55
- PATTERN
56
-
57
70
  def_node_matcher :node_cloud?, <<-PATTERN
58
71
  (send
59
72
  (send nil? :node) :[]
@@ -61,19 +74,13 @@ module RuboCop
61
74
  PATTERN
62
75
 
63
76
  def on_send(node)
64
- node_check?(node) do |cloud_name|
65
- add_offense(node, message: MSG, severity: :refactor) do |corrector|
66
- corrector.replace(node, "#{cloud_name}?")
67
- end
68
- end
69
-
70
77
  provider_comparison?(node) do |cloud_name|
71
78
  # skip it if someone was checking for a bogus cloud provider
72
79
  next unless VALID_CLOUDS.include?(cloud_name)
73
80
 
74
81
  # if they were checking for node['cloud'] and the provider replace it all
75
82
  node = node.parent if node.parent.and_type? && node_cloud?(node.left_sibling)
76
-
83
+
77
84
  add_offense(node, message: MSG, severity: :refactor) do |corrector|
78
85
  corrector.replace(node, "#{cloud_name}?")
79
86
  end
@@ -19,7 +19,7 @@ module RuboCop
19
19
  module Cop
20
20
  module Chef
21
21
  module Modernize
22
- # Chef Infra Client 15.5 and later include a large number of new helpers in the Chef Infra Language to simplify checking the system configuration in recipes and resources. These should be used when possible over more complex attribute or ENV var comparisons.
22
+ # Chef Infra Client 15.5 and later include a large number of new helpers in the Chef Infra Language to simplify checking the system configuration in recipes and resources. These should be used when possible over more complex attributes or ENV var comparisons.
23
23
  #
24
24
  # @example
25
25
  #
@@ -33,6 +33,9 @@ module RuboCop
33
33
  #
34
34
  class UseChefLanguageEnvHelpers < Base
35
35
  extend AutoCorrector
36
+ extend TargetChefVersion
37
+
38
+ minimum_target_chef_version '15.5'
36
39
 
37
40
  RESTRICT_ON_SEND = [:[]].freeze
38
41
 
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # Copyright:: 2021, Chef Software, Inc.
4
+ # Author:: Tim Smith (<tsmith@chef.io>)
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+ module RuboCop
19
+ module Cop
20
+ module Chef
21
+ module Modernize
22
+ # Chef Infra Client 15.5 and later include a `systemd?` helper for checking if a Linux system uses systemd.
23
+ #
24
+ # @example
25
+ #
26
+ # #### incorrect
27
+ # node['init_package'] == 'systemd'
28
+ #
29
+ # #### correct
30
+ # systemd?
31
+ #
32
+ class UseChefLanguageSystemdHelper < Base
33
+ extend AutoCorrector
34
+ extend TargetChefVersion
35
+
36
+ minimum_target_chef_version '15.5'
37
+
38
+ MSG = 'Chef Infra Client 15.5 and later include a `systemd?` helper for checking if a Linux system uses systemd.'
39
+ RESTRICT_ON_SEND = [:==].freeze
40
+
41
+ def_node_matcher :node_init_package?, <<-PATTERN
42
+ (send
43
+ (send
44
+ (send nil? :node) :[]
45
+ (str "init_package")) :==
46
+ (str "systemd"))
47
+ PATTERN
48
+
49
+ def on_send(node)
50
+ node_init_package?(node) do |_cloud_name|
51
+ add_offense(node, message: MSG, severity: :refactor) do |corrector|
52
+ corrector.replace(node, 'systemd?')
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cookstyle
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.21.0
4
+ version: 7.25.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thom May
8
8
  - Tim Smith
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-08-26 00:00:00.000000000 Z
12
+ date: 2021-09-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rubocop
@@ -17,15 +17,15 @@ dependencies:
17
17
  requirements:
18
18
  - - '='
19
19
  - !ruby/object:Gem::Version
20
- version: 1.19.0
20
+ version: 1.22.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.19.0
28
- description:
27
+ version: 1.22.0
28
+ description:
29
29
  email:
30
30
  - thom@chef.io
31
31
  - tsmith@chef.io
@@ -71,6 +71,7 @@ files:
71
71
  - lib/rubocop/cop/chef/correctness/malformed_value_for_platform.rb
72
72
  - lib/rubocop/cop/chef/correctness/metadata_malformed_version.rb
73
73
  - lib/rubocop/cop/chef/correctness/metadata_missing_name.rb
74
+ - lib/rubocop/cop/chef/correctness/metadata_missing_version.rb
74
75
  - lib/rubocop/cop/chef/correctness/node_normal.rb
75
76
  - lib/rubocop/cop/chef/correctness/node_normal_unless.rb
76
77
  - lib/rubocop/cop/chef/correctness/node_save.rb
@@ -181,6 +182,7 @@ files:
181
182
  - lib/rubocop/cop/chef/modernize/chef_14_resources.rb
182
183
  - lib/rubocop/cop/chef/modernize/chef_15_resources.rb
183
184
  - lib/rubocop/cop/chef/modernize/chef_gem_nokogiri.rb
185
+ - lib/rubocop/cop/chef/modernize/class_eval_action_class.rb
184
186
  - lib/rubocop/cop/chef/modernize/compile_time_resources.rb
185
187
  - lib/rubocop/cop/chef/modernize/conditional_using_test.rb
186
188
  - lib/rubocop/cop/chef/modernize/cron_d_file_or_template.rb
@@ -238,6 +240,7 @@ files:
238
240
  - lib/rubocop/cop/chef/modernize/unnecessary_mixlib_shellout_require.rb
239
241
  - lib/rubocop/cop/chef/modernize/use_chef_language_cloud_helpers.rb
240
242
  - lib/rubocop/cop/chef/modernize/use_chef_language_env_helpers.rb
243
+ - lib/rubocop/cop/chef/modernize/use_chef_language_systemd_helper.rb
241
244
  - lib/rubocop/cop/chef/modernize/use_multipackage_installs.rb
242
245
  - lib/rubocop/cop/chef/modernize/use_require_relative.rb
243
246
  - lib/rubocop/cop/chef/modernize/whyrun_supported_true.rb
@@ -305,11 +308,11 @@ licenses:
305
308
  - Apache-2.0
306
309
  metadata:
307
310
  homepage_uri: https://github.com/chef/cookstyle
308
- changelog_uri: https://github.com/chef/cookstyle/blob/master/CHANGELOG.md
311
+ changelog_uri: https://github.com/chef/cookstyle/blob/main/CHANGELOG.md
309
312
  source_code_uri: https://github.com/chef/cookstyle
310
313
  documentation_uri: https://docs.chef.io/workstation/cookstyle/
311
314
  bug_tracker_uri: https://github.com/chef/cookstyle/issues
312
- post_install_message:
315
+ post_install_message:
313
316
  rdoc_options: []
314
317
  require_paths:
315
318
  - lib
@@ -324,8 +327,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
324
327
  - !ruby/object:Gem::Version
325
328
  version: '0'
326
329
  requirements: []
327
- rubygems_version: 3.2.22
328
- signing_key:
330
+ rubygems_version: 3.1.4
331
+ signing_key:
329
332
  specification_version: 4
330
333
  summary: Cookstyle is a code linting tool that helps you to write better Chef Infra
331
334
  cookbooks by detecting and automatically correcting style, syntax, and logic mistakes