cookstyle 7.22.3 → 7.25.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -4
- data/config/cookstyle.yml +37 -2
- data/config/disable_all.yml +15 -1
- data/config/upstream.yml +64 -15
- data/lib/cookstyle/version.rb +2 -2
- data/lib/rubocop/cop/chef/correctness/metadata_missing_version.rb +48 -0
- data/lib/rubocop/cop/chef/deprecation/resource_without_unified_mode_true.rb +1 -1
- data/lib/rubocop/cop/chef/modernize/class_eval_action_class.rb +63 -0
- data/lib/rubocop/cop/chef/modernize/declare_action_class.rb +54 -0
- data/lib/rubocop/cop/chef/modernize/use_chef_language_cloud_helpers.rb +5 -2
- data/lib/rubocop/cop/chef/modernize/use_chef_language_env_helpers.rb +4 -1
- data/lib/rubocop/cop/chef/modernize/use_chef_language_systemd_helper.rb +60 -0
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c878c6f71305a020ad727f7487803d5b2e669b98efa8c454507fcdbf1b5d7780
|
4
|
+
data.tar.gz: 5bf633217017d6fff058d1214f7f0f28fe87b99107cf5d768bce2e68a2d1398e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f575ac4b8b913935583fa697f82bb9fc6387f135c1a78d0ef2782df47def871bb5bce54f2a3b2df9c187af18eee08791e6173f6cb7a284356cfecbd844e8644a
|
7
|
+
data.tar.gz: 49a470d1a612896c887cbd8b879ab5c31a1d5180e454245f3abcd431f0725d7d3d9553342f48fdddf68b36fca682d2f778f42c642baf6e2acb65685b18edb5fc
|
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
|
-
|
19
|
-
|
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
|
###############################
|
@@ -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
|
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'
|
@@ -1907,7 +1915,7 @@ Chef/Modernize/UseChefLanguageEnvHelpers:
|
|
1907
1915
|
- '**/recipes/*.rb'
|
1908
1916
|
|
1909
1917
|
Chef/Modernize/UseChefLanguageCloudHelpers:
|
1910
|
-
Description:
|
1918
|
+
Description: Chef Infra Client 15.5 and later include cloud helpers to make detecting instances that run on public and private clouds easier.
|
1911
1919
|
StyleGuide: 'chef_modernize_usecheflanguagecloudhelpers'
|
1912
1920
|
Enabled: true
|
1913
1921
|
VersionAdded: '7.22.0'
|
@@ -1916,6 +1924,32 @@ Chef/Modernize/UseChefLanguageCloudHelpers:
|
|
1916
1924
|
- '**/providers/*.rb'
|
1917
1925
|
- '**/recipes/*.rb'
|
1918
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
|
+
|
1944
|
+
Chef/Modernize/DeclareActionClass:
|
1945
|
+
Description: In Chef Infra Client 12.9 and later `action_class` can be used instead of `declare_action_class`.
|
1946
|
+
StyleGuide: 'chef_modernize_declareactionclass'
|
1947
|
+
Enabled: true
|
1948
|
+
VersionAdded: '7.26.0'
|
1949
|
+
Include:
|
1950
|
+
- '**/resources/*.rb'
|
1951
|
+
- '**/libraries/*.rb'
|
1952
|
+
|
1919
1953
|
###############################
|
1920
1954
|
# Chef/RedundantCode: Cleanup unnecessary code in your cookbooks regardless of Chef Infra Client release
|
1921
1955
|
###############################
|
@@ -2788,6 +2822,7 @@ Style/GuardClause:
|
|
2788
2822
|
# Users really shouldn't have a gem, but if they do they should do it securely
|
2789
2823
|
Bundler/InsecureProtocolSource:
|
2790
2824
|
Enabled: true
|
2825
|
+
AllowHttpProtocol: false
|
2791
2826
|
|
2792
2827
|
# It's easier to read a simple .each and they're faster
|
2793
2828
|
Lint/RedundantWithIndex:
|
data/config/disable_all.yml
CHANGED
@@ -221,6 +221,8 @@ Lint/AmbiguousBlockAssociation:
|
|
221
221
|
Enabled: false
|
222
222
|
Lint/AmbiguousOperator:
|
223
223
|
Enabled: false
|
224
|
+
Lint/AmbiguousOperatorPrecedence:
|
225
|
+
Enabled: false
|
224
226
|
Lint/AmbiguousRange:
|
225
227
|
Enabled: false
|
226
228
|
Lint/AmbiguousRegexpLiteral:
|
@@ -307,10 +309,12 @@ Lint/IdentityComparison:
|
|
307
309
|
Enabled: false
|
308
310
|
Lint/ImplicitStringConcatenation:
|
309
311
|
Enabled: false
|
310
|
-
Lint/
|
312
|
+
Lint/IncompatibleIoSelectWithFiberScheduler:
|
311
313
|
Enabled: false
|
312
314
|
Lint/IneffectiveAccessModifier:
|
313
315
|
Enabled: false
|
316
|
+
Lint/InheritException:
|
317
|
+
Enabled: false
|
314
318
|
Lint/InterpolationCheck:
|
315
319
|
Enabled: false
|
316
320
|
Lint/LambdaWithoutLiteralBlock:
|
@@ -383,6 +387,8 @@ Lint/RegexpAsCondition:
|
|
383
387
|
Enabled: false
|
384
388
|
Lint/RequireParentheses:
|
385
389
|
Enabled: false
|
390
|
+
Lint/RequireRelativeSelfPath:
|
391
|
+
Enabled: false
|
386
392
|
Lint/RescueException:
|
387
393
|
Enabled: false
|
388
394
|
Lint/RescueType:
|
@@ -701,6 +707,8 @@ Style/MethodCallWithArgsParentheses:
|
|
701
707
|
Enabled: false
|
702
708
|
Style/MultilineInPatternThen:
|
703
709
|
Enabled: false
|
710
|
+
Style/NumberedParameters:
|
711
|
+
Enabled: false
|
704
712
|
Style/RedundantAssignment:
|
705
713
|
Enabled: false
|
706
714
|
Style/RedundantFetchBlock:
|
@@ -773,6 +781,8 @@ Style/NonNilCheck:
|
|
773
781
|
Enabled: false
|
774
782
|
Style/Not:
|
775
783
|
Enabled: false
|
784
|
+
Style/NumberedParametersLimit:
|
785
|
+
Enabled: false
|
776
786
|
Style/NumericLiterals:
|
777
787
|
Enabled: false
|
778
788
|
Style/NumericLiteralPrefix:
|
@@ -853,6 +863,8 @@ Style/SafeNavigation:
|
|
853
863
|
Enabled: false
|
854
864
|
Style/Sample:
|
855
865
|
Enabled: false
|
866
|
+
Style/SelectByRegexp:
|
867
|
+
Enabled: false
|
856
868
|
Style/SelfAssignment:
|
857
869
|
Enabled: false
|
858
870
|
Style/Semicolon:
|
@@ -945,6 +957,8 @@ Style/ZeroLengthPredicate:
|
|
945
957
|
Enabled: false
|
946
958
|
Security/Eval:
|
947
959
|
Enabled: false
|
960
|
+
Security/IoMethods:
|
961
|
+
Enabled: false
|
948
962
|
Security/JSONLoad:
|
949
963
|
Enabled: false
|
950
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
|
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
|
@@ -209,6 +209,7 @@ Bundler/InsecureProtocolSource:
|
|
209
209
|
'https://rubygems.org' if possible, or 'http://rubygems.org' if not.
|
210
210
|
Enabled: true
|
211
211
|
VersionAdded: '0.50'
|
212
|
+
AllowHttpProtocol: true
|
212
213
|
Include:
|
213
214
|
- '**/*.gemfile'
|
214
215
|
- '**/Gemfile'
|
@@ -261,7 +262,7 @@ Gemspec/RequiredRubyVersion:
|
|
261
262
|
Description: 'Checks that `required_ruby_version` of gemspec is specified and equal to `TargetRubyVersion` of .rubocop.yml.'
|
262
263
|
Enabled: true
|
263
264
|
VersionAdded: '0.52'
|
264
|
-
VersionChanged: '
|
265
|
+
VersionChanged: '1.22'
|
265
266
|
Include:
|
266
267
|
- '**/*.gemspec'
|
267
268
|
|
@@ -957,7 +958,6 @@ Layout/LineLength:
|
|
957
958
|
Enabled: true
|
958
959
|
VersionAdded: '0.25'
|
959
960
|
VersionChanged: '1.4'
|
960
|
-
AutoCorrect: true
|
961
961
|
Max: 120
|
962
962
|
# To make it possible to copy or click on URIs in the code, we allow lines
|
963
963
|
# containing a URI to be longer than Max.
|
@@ -1361,10 +1361,11 @@ Layout/SpaceInsideParens:
|
|
1361
1361
|
StyleGuide: '#spaces-braces'
|
1362
1362
|
Enabled: true
|
1363
1363
|
VersionAdded: '0.49'
|
1364
|
-
VersionChanged: '
|
1364
|
+
VersionChanged: '1.22'
|
1365
1365
|
EnforcedStyle: no_space
|
1366
1366
|
SupportedStyles:
|
1367
1367
|
- space
|
1368
|
+
- compact
|
1368
1369
|
- no_space
|
1369
1370
|
|
1370
1371
|
Layout/SpaceInsidePercentLiteralDelimiters:
|
@@ -1448,6 +1449,13 @@ Lint/AmbiguousOperator:
|
|
1448
1449
|
VersionAdded: '0.17'
|
1449
1450
|
VersionChanged: '0.83'
|
1450
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
|
+
|
1451
1459
|
Lint/AmbiguousRange:
|
1452
1460
|
Description: Checks for ranges with ambiguous boundaries.
|
1453
1461
|
Enabled: pending
|
@@ -1485,9 +1493,9 @@ Lint/BinaryOperatorWithIdenticalOperands:
|
|
1485
1493
|
Lint/BooleanSymbol:
|
1486
1494
|
Description: 'Check for `:true` and `:false` symbols.'
|
1487
1495
|
Enabled: true
|
1488
|
-
|
1496
|
+
SafeAutoCorrect: false
|
1489
1497
|
VersionAdded: '0.50'
|
1490
|
-
VersionChanged: '
|
1498
|
+
VersionChanged: '1.22'
|
1491
1499
|
|
1492
1500
|
Lint/CircularArgumentReference:
|
1493
1501
|
Description: "Default values in optional keyword arguments and optional ordinal arguments should not refer back to the name of the argument."
|
@@ -1771,6 +1779,11 @@ Lint/ImplicitStringConcatenation:
|
|
1771
1779
|
Enabled: true
|
1772
1780
|
VersionAdded: '0.36'
|
1773
1781
|
|
1782
|
+
Lint/IncompatibleIoSelectWithFiberScheduler:
|
1783
|
+
Description: 'Checks for `IO.select` that is incompatible with Fiber Scheduler.'
|
1784
|
+
Enabled: pending
|
1785
|
+
VersionAdded: '1.21'
|
1786
|
+
|
1774
1787
|
Lint/IneffectiveAccessModifier:
|
1775
1788
|
Description: >-
|
1776
1789
|
Checks for attempts to use `private` or `protected` to set
|
@@ -2034,6 +2047,11 @@ Lint/RequireParentheses:
|
|
2034
2047
|
Enabled: true
|
2035
2048
|
VersionAdded: '0.18'
|
2036
2049
|
|
2050
|
+
Lint/RequireRelativeSelfPath:
|
2051
|
+
Description: 'Checks for uses a file requiring itself with `require_relative`.'
|
2052
|
+
Enabled: pending
|
2053
|
+
VersionAdded: '1.22'
|
2054
|
+
|
2037
2055
|
Lint/RescueException:
|
2038
2056
|
Description: 'Avoid rescuing the Exception class.'
|
2039
2057
|
StyleGuide: '#no-blind-rescues'
|
@@ -2563,8 +2581,9 @@ Naming/HeredocDelimiterNaming:
|
|
2563
2581
|
|
2564
2582
|
Naming/InclusiveLanguage:
|
2565
2583
|
Description: 'Recommend the use of inclusive language instead of problematic terms.'
|
2566
|
-
Enabled:
|
2584
|
+
Enabled: false
|
2567
2585
|
VersionAdded: '1.18'
|
2586
|
+
VersionChanged: '1.21'
|
2568
2587
|
CheckIdentifiers: true
|
2569
2588
|
CheckConstants: true
|
2570
2589
|
CheckVariables: true
|
@@ -2720,6 +2739,14 @@ Security/Eval:
|
|
2720
2739
|
Enabled: true
|
2721
2740
|
VersionAdded: '0.47'
|
2722
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
|
+
|
2723
2750
|
Security/JSONLoad:
|
2724
2751
|
Description: >-
|
2725
2752
|
Prefer usage of `JSON.parse` over `JSON.load` due to potential
|
@@ -2727,10 +2754,9 @@ Security/JSONLoad:
|
|
2727
2754
|
Reference: 'https://ruby-doc.org/stdlib-2.7.0/libdoc/json/rdoc/JSON.html#method-i-load'
|
2728
2755
|
Enabled: true
|
2729
2756
|
VersionAdded: '0.43'
|
2730
|
-
VersionChanged: '
|
2757
|
+
VersionChanged: '1.22'
|
2731
2758
|
# Autocorrect here will change to a method that may cause crashes depending
|
2732
2759
|
# on the value of the argument.
|
2733
|
-
AutoCorrect: false
|
2734
2760
|
SafeAutoCorrect: false
|
2735
2761
|
|
2736
2762
|
Security/MarshalLoad:
|
@@ -2796,8 +2822,9 @@ Style/AndOr:
|
|
2796
2822
|
Description: 'Use &&/|| instead of and/or.'
|
2797
2823
|
StyleGuide: '#no-and-or-or'
|
2798
2824
|
Enabled: true
|
2825
|
+
SafeAutoCorrect: false
|
2799
2826
|
VersionAdded: '0.9'
|
2800
|
-
VersionChanged: '
|
2827
|
+
VersionChanged: '1.21'
|
2801
2828
|
# Whether `and` and `or` are banned only in conditionals (conditionals)
|
2802
2829
|
# or completely (always).
|
2803
2830
|
EnforcedStyle: conditionals
|
@@ -2831,9 +2858,9 @@ Style/ArrayJoin:
|
|
2831
2858
|
Style/AsciiComments:
|
2832
2859
|
Description: 'Use only ascii symbols in comments.'
|
2833
2860
|
StyleGuide: '#english-comments'
|
2834
|
-
Enabled:
|
2861
|
+
Enabled: false
|
2835
2862
|
VersionAdded: '0.9'
|
2836
|
-
VersionChanged: '
|
2863
|
+
VersionChanged: '1.21'
|
2837
2864
|
AllowedChars:
|
2838
2865
|
- ©
|
2839
2866
|
|
@@ -2995,7 +3022,7 @@ Style/CaseEquality:
|
|
2995
3022
|
Enabled: true
|
2996
3023
|
VersionAdded: '0.9'
|
2997
3024
|
VersionChanged: '0.89'
|
2998
|
-
# If AllowOnConstant is enabled, the cop will ignore violations when the receiver of
|
3025
|
+
# If `AllowOnConstant` option is enabled, the cop will ignore violations when the receiver of
|
2999
3026
|
# the case equality operator is a constant.
|
3000
3027
|
#
|
3001
3028
|
# # bad
|
@@ -3690,7 +3717,7 @@ Style/InPatternThen:
|
|
3690
3717
|
Style/InfiniteLoop:
|
3691
3718
|
Description: >-
|
3692
3719
|
Use Kernel#loop for infinite loops.
|
3693
|
-
This cop is unsafe
|
3720
|
+
This cop is unsafe if the body may raise a `StopIteration` exception.
|
3694
3721
|
Safe: false
|
3695
3722
|
StyleGuide: '#infinite-loop'
|
3696
3723
|
Enabled: true
|
@@ -4116,6 +4143,21 @@ Style/Not:
|
|
4116
4143
|
VersionAdded: '0.9'
|
4117
4144
|
VersionChanged: '0.20'
|
4118
4145
|
|
4146
|
+
Style/NumberedParameters:
|
4147
|
+
Description: 'Restrict the usage of numbered parameters.'
|
4148
|
+
Enabled: pending
|
4149
|
+
VersionAdded: '1.22'
|
4150
|
+
EnforcedStyle: allow_single_line
|
4151
|
+
SupportedStyles:
|
4152
|
+
- allow_single_line
|
4153
|
+
- disallow
|
4154
|
+
|
4155
|
+
Style/NumberedParametersLimit:
|
4156
|
+
Description: 'Avoid excessive numbered params in a single block.'
|
4157
|
+
Enabled: pending
|
4158
|
+
VersionAdded: '1.22'
|
4159
|
+
Max: 1
|
4160
|
+
|
4119
4161
|
Style/NumericLiteralPrefix:
|
4120
4162
|
Description: 'Use smallcase prefixes for numeric literals.'
|
4121
4163
|
StyleGuide: '#numeric-literal-prefixes'
|
@@ -4126,7 +4168,6 @@ Style/NumericLiteralPrefix:
|
|
4126
4168
|
- zero_with_o
|
4127
4169
|
- zero_only
|
4128
4170
|
|
4129
|
-
|
4130
4171
|
Style/NumericLiterals:
|
4131
4172
|
Description: >-
|
4132
4173
|
Add underscores to large numeric literals to improve their
|
@@ -4447,6 +4488,8 @@ Style/RedundantSort:
|
|
4447
4488
|
`max_by` instead of `sort_by...last`, etc.
|
4448
4489
|
Enabled: true
|
4449
4490
|
VersionAdded: '0.76'
|
4491
|
+
VersionChanged: '1.22'
|
4492
|
+
Safe: false
|
4450
4493
|
|
4451
4494
|
Style/RedundantSortBy:
|
4452
4495
|
Description: 'Use `sort` instead of `sort_by { |x| x }`.'
|
@@ -4527,6 +4570,12 @@ Style/Sample:
|
|
4527
4570
|
Enabled: true
|
4528
4571
|
VersionAdded: '0.30'
|
4529
4572
|
|
4573
|
+
Style/SelectByRegexp:
|
4574
|
+
Description: 'Prefer grep/grep_v to select/reject with a regexp match.'
|
4575
|
+
Enabled: pending
|
4576
|
+
SafeAutoCorrect: false
|
4577
|
+
VersionAdded: '1.22'
|
4578
|
+
|
4530
4579
|
Style/SelfAssignment:
|
4531
4580
|
Description: >-
|
4532
4581
|
Checks for places where self-assignment shorthand should have
|
data/lib/cookstyle/version.rb
CHANGED
@@ -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
|
-
# 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
|
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,63 @@
|
|
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
|
+
|
44
|
+
def_node_matcher :class_eval_action_class?, <<-PATTERN
|
45
|
+
(block
|
46
|
+
(send
|
47
|
+
(send nil? :action_class) :class_eval)
|
48
|
+
(args)
|
49
|
+
... )
|
50
|
+
PATTERN
|
51
|
+
|
52
|
+
def on_block(node)
|
53
|
+
class_eval_action_class?(node) do
|
54
|
+
add_offense(node, message: MSG, severity: :refactor) do |corrector|
|
55
|
+
corrector.replace(node, node.source.gsub('.class_eval', ''))
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
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
|
+
# In Chef Infra Client 12.9 and later `action_class` can be used instead of `declare_action_class`.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
#
|
26
|
+
# #### incorrect
|
27
|
+
# declare_action_class do
|
28
|
+
# foo
|
29
|
+
# end
|
30
|
+
#
|
31
|
+
# #### correct
|
32
|
+
# action_class do
|
33
|
+
# foo
|
34
|
+
# end
|
35
|
+
#
|
36
|
+
class DeclareActionClass < 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 `action_class` can be used instead of `declare_action_class`.'
|
43
|
+
RESTRICT_ON_SEND = [:declare_action_class].freeze
|
44
|
+
|
45
|
+
def on_send(node)
|
46
|
+
add_offense(node, message: MSG, severity: :refactor) do |corrector|
|
47
|
+
corrector.replace(node, node.source.gsub('declare_action_class', 'action_class'))
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -19,7 +19,7 @@ module RuboCop
|
|
19
19
|
module Cop
|
20
20
|
module Chef
|
21
21
|
module Modernize
|
22
|
-
# Chef Infra Client 15.5 and later include cloud helpers to make detecting
|
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
|
#
|
@@ -49,8 +49,11 @@ module RuboCop
|
|
49
49
|
#
|
50
50
|
class UseChefLanguageCloudHelpers < Base
|
51
51
|
extend AutoCorrector
|
52
|
+
extend TargetChefVersion
|
52
53
|
|
53
|
-
|
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.'
|
54
57
|
RESTRICT_ON_SEND = [:==, :[]].freeze
|
55
58
|
VALID_CLOUDS = %w(alibaba ec2 gce rackspace eucalyptus linode openstack azure digital_ocean softlayer).freeze
|
56
59
|
|
@@ -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
|
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,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.25.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thom May
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-10-22 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.22.2
|
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.22.2
|
28
28
|
description:
|
29
29
|
email:
|
30
30
|
- thom@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,11 +182,13 @@ 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
|
187
189
|
- lib/rubocop/cop/chef/modernize/cron_manage_resource.rb
|
188
190
|
- lib/rubocop/cop/chef/modernize/databag_helpers.rb
|
191
|
+
- lib/rubocop/cop/chef/modernize/declare_action_class.rb
|
189
192
|
- lib/rubocop/cop/chef/modernize/default_action_initializer.rb
|
190
193
|
- lib/rubocop/cop/chef/modernize/defines_chefspec_matchers.rb
|
191
194
|
- lib/rubocop/cop/chef/modernize/definitions.rb
|
@@ -238,6 +241,7 @@ files:
|
|
238
241
|
- lib/rubocop/cop/chef/modernize/unnecessary_mixlib_shellout_require.rb
|
239
242
|
- lib/rubocop/cop/chef/modernize/use_chef_language_cloud_helpers.rb
|
240
243
|
- lib/rubocop/cop/chef/modernize/use_chef_language_env_helpers.rb
|
244
|
+
- lib/rubocop/cop/chef/modernize/use_chef_language_systemd_helper.rb
|
241
245
|
- lib/rubocop/cop/chef/modernize/use_multipackage_installs.rb
|
242
246
|
- lib/rubocop/cop/chef/modernize/use_require_relative.rb
|
243
247
|
- lib/rubocop/cop/chef/modernize/whyrun_supported_true.rb
|