cookstyle 7.13.0 → 7.15.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 811ea8aed6ff56a955606ba47fd8c30181ea3827c816879fd2e8e98443db92bc
4
- data.tar.gz: ab8a7d83c787649299f98c6e86722be5728d3aa2b510c50a2d5f72cd0718999b
3
+ metadata.gz: dfc2c66f2febd5fbd7ee14e3fe798ae10f1dc8b7fa3df2a3ebfd068a024f845f
4
+ data.tar.gz: 9f6bef8fb1d57f40fd9a94900d5b0e4a95c98682124b79f7de85e83af244899c
5
5
  SHA512:
6
- metadata.gz: 3e1184b274aa2fb50748e5e693f3f30a9ec6bf23230187152c3934c03a42350fbbb44624772722a871801cc8b9dbb9f9a5e676fbf9dabcfe34cdc0582584a0d4
7
- data.tar.gz: '09c3f666ede2289ea7dfbe677e73c9df1f1763ae19c16d8b1c51ae33dddde2ead0eaee275d4dd45fee304769422549d171a0bfaede0262ef059dd6b4307c226e'
6
+ metadata.gz: 78197b457795eff5976c4ed4bd6b8458be306b900142799027f4a5848bd0f722d5c9b3b3431349c4a2c48783038289b06a983dba383c13c05bc0391c4ab6c1aa
7
+ data.tar.gz: 6af82797747ea7eebc69a5f21e8a1d79858534ec318b620ee324bedb9a18530b5e897f087b58bfaa9d7d4e240041c3aa497cb42326725f827d62fd551f092dc4
data/config/cookstyle.yml CHANGED
@@ -1208,6 +1208,14 @@ Chef/Deprecations/ResourceWithoutUnifiedTrue:
1208
1208
  Exclude:
1209
1209
  - '**/spec/**/*.rb'
1210
1210
 
1211
+ Chef/Deprecations/PolicyfileCommunitySource:
1212
+ Description: The Policyfile source of `:community` has been replaced with `:supermarket`
1213
+ StyleGuide: 'chef_deprecations_policyfilecommunitysource'
1214
+ Enabled: true
1215
+ VersionAdded: '7.15.0'
1216
+ Include:
1217
+ - '**/Policyfile.rb'
1218
+
1211
1219
  ###############################
1212
1220
  # Chef/Modernize: Cleaning up legacy code and using new built-in resources
1213
1221
  ###############################
@@ -2080,6 +2088,27 @@ Chef/Effortless/Berksfile:
2080
2088
  Include:
2081
2089
  - '**/Berksfile'
2082
2090
 
2091
+ #### InSpec cops
2092
+
2093
+ InSpec/Deprecations:
2094
+ StyleGuideBaseURL: https://docs.chef.io/workstation/cookstyle/
2095
+
2096
+ InSpec/Deprecations/AttributeHelper:
2097
+ Description: InSpec attributes have been renamed to inputs. Use the `input` method not the deprecation `attribute` method to access these values.
2098
+ StyleGuide: 'inspec_deprecations_attributehelper'
2099
+ Enabled: true
2100
+ VersionAdded: '7.14.0'
2101
+ Include:
2102
+ - '**/controls/*.rb'
2103
+
2104
+ InSpec/Deprecations/AttributeDefault:
2105
+ Description: The InSpec inputs `default` option has been replaced with the `value` option.
2106
+ StyleGuide: 'inspec_deprecations_attributedefaults'
2107
+ Enabled: true
2108
+ VersionAdded: '7.14.0'
2109
+ Include:
2110
+ - '**/controls/*.rb'
2111
+
2083
2112
  #### The base rubocop 0.37 enabled.yml file we started with ####
2084
2113
 
2085
2114
  Layout/AccessModifierIndentation:
@@ -123,6 +123,8 @@ Layout/LeadingCommentSpace:
123
123
  Enabled: false
124
124
  Layout/LeadingEmptyLines:
125
125
  Enabled: false
126
+ Layout/LineEndStringConcatenationIndentation:
127
+ Enabled: false
126
128
  Layout/LineLength:
127
129
  Enabled: false
128
130
  Layout/MultilineArrayBraceLayout:
@@ -275,6 +277,8 @@ Lint/EmptyExpression:
275
277
  Enabled: false
276
278
  Lint/EmptyFile:
277
279
  Enabled: false
280
+ Lint/EmptyInPattern:
281
+ Enabled: false
278
282
  Lint/EmptyInterpolation:
279
283
  Enabled: false
280
284
  Lint/EmptyWhen:
@@ -485,6 +489,8 @@ Naming/HeredocDelimiterCase:
485
489
  Enabled: false
486
490
  Naming/HeredocDelimiterNaming:
487
491
  Enabled: false
492
+ Naming/InclusiveLanguage:
493
+ Enabled: false
488
494
  Naming/MemoizedInstanceVariableName:
489
495
  Enabled: false
490
496
  Naming/MethodName:
@@ -667,6 +673,8 @@ Style/IfWithSemicolon:
667
673
  Enabled: false
668
674
  Style/ImplicitRuntimeError:
669
675
  Enabled: false
676
+ Style/InPatternThen:
677
+ Enabled: false
670
678
  Style/InfiniteLoop:
671
679
  Enabled: false
672
680
  Style/InverseMethods:
@@ -687,6 +695,8 @@ Style/MethodCallWithoutArgsParentheses:
687
695
  Enabled: false
688
696
  Style/MethodCallWithArgsParentheses:
689
697
  Enabled: false
698
+ Style/MultilineInPatternThen:
699
+ Enabled: false
690
700
  Style/RedundantAssignment:
691
701
  Enabled: false
692
702
  Style/RedundantFetchBlock:
@@ -787,6 +797,8 @@ Style/PreferredHashMethods:
787
797
  Enabled: false
788
798
  Style/Proc:
789
799
  Enabled: false
800
+ Style/QuotedSymbols:
801
+ Enabled: false
790
802
  Style/RaiseArgs:
791
803
  Enabled: false
792
804
  Style/RandomWithOffset:
@@ -935,3 +947,7 @@ Security/Open:
935
947
  Enabled: false
936
948
  Security/YAMLLoad:
937
949
  Enabled: false
950
+ InSpec/Deprecations/AttributeDefault:
951
+ Enabled: false
952
+ InSpec/Deprecations/AttributeHelper:
953
+ Enabled: false
data/config/upstream.yml CHANGED
@@ -270,8 +270,8 @@ Layout/AccessModifierIndentation:
270
270
  SupportedStyles:
271
271
  - outdent
272
272
  - indent
273
- # By default, the indentation width from Layout/IndentationWidth is used
274
- # But it can be overridden by setting this parameter
273
+ # By default the indentation width from `Layout/IndentationWidth` is used,
274
+ # but it can be overridden by setting this parameter.
275
275
  IndentationWidth: ~
276
276
 
277
277
  Layout/ArgumentAlignment:
@@ -299,8 +299,8 @@ Layout/ArgumentAlignment:
299
299
  SupportedStyles:
300
300
  - with_first_argument
301
301
  - with_fixed_indentation
302
- # By default, the indentation width from Layout/IndentationWidth is used
303
- # But it can be overridden by setting this parameter
302
+ # By default the indentation width from `Layout/IndentationWidth` is used,
303
+ # but it can be overridden by setting this parameter.
304
304
  IndentationWidth: ~
305
305
 
306
306
  Layout/ArrayAlignment:
@@ -328,8 +328,8 @@ Layout/ArrayAlignment:
328
328
  SupportedStyles:
329
329
  - with_first_element
330
330
  - with_fixed_indentation
331
- # By default, the indentation width from Layout/IndentationWidth is used
332
- # But it can be overridden by setting this parameter
331
+ # By default the indentation width from `Layout/IndentationWidth` is used,
332
+ # but it can be overridden by setting this parameter.
333
333
  IndentationWidth: ~
334
334
 
335
335
  Layout/AssignmentIndentation:
@@ -339,8 +339,8 @@ Layout/AssignmentIndentation:
339
339
  Enabled: true
340
340
  VersionAdded: '0.49'
341
341
  VersionChanged: '0.77'
342
- # By default, the indentation width from `Layout/IndentationWidth` is used
343
- # But it can be overridden by setting this parameter
342
+ # By default the indentation width from `Layout/IndentationWidth` is used,
343
+ # but it can be overridden by setting this parameter.
344
344
  IndentationWidth: ~
345
345
 
346
346
  Layout/BeginEndAlignment:
@@ -377,18 +377,19 @@ Layout/BlockEndNewline:
377
377
  VersionAdded: '0.49'
378
378
 
379
379
  Layout/CaseIndentation:
380
- Description: 'Indentation of when in a case/when/[else/]end.'
380
+ Description: 'Indentation of when in a case/(when|in)/[else/]end.'
381
381
  StyleGuide: '#indent-when-to-case'
382
382
  Enabled: true
383
383
  VersionAdded: '0.49'
384
+ VersionChanged: '1.16'
384
385
  EnforcedStyle: case
385
386
  SupportedStyles:
386
387
  - case
387
388
  - end
388
389
  IndentOneStep: false
389
- # By default, the indentation width from `Layout/IndentationWidth` is used.
390
- # But it can be overridden by setting this parameter.
391
- # This only matters if `IndentOneStep` is `true`
390
+ # By default the indentation width from `Layout/IndentationWidth` is used,
391
+ # but it can be overridden by setting this parameter.
392
+ # This only matters if `IndentOneStep` is `true`.
392
393
  IndentationWidth: ~
393
394
 
394
395
  Layout/ClassStructure:
@@ -665,8 +666,8 @@ Layout/FirstArgumentIndentation:
665
666
  # Same as `special_for_inner_method_call` except that the special rule only
666
667
  # applies if the outer method call encloses its arguments in parentheses.
667
668
  - special_for_inner_method_call_in_parentheses
668
- # By default, the indentation width from `Layout/IndentationWidth` is used
669
- # But it can be overridden by setting this parameter
669
+ # By default the indentation width from `Layout/IndentationWidth` is used,
670
+ # but it can be overridden by setting this parameter.
670
671
  IndentationWidth: ~
671
672
 
672
673
  Layout/FirstArrayElementIndentation:
@@ -692,8 +693,8 @@ Layout/FirstArrayElementIndentation:
692
693
  - special_inside_parentheses
693
694
  - consistent
694
695
  - align_brackets
695
- # By default, the indentation width from `Layout/IndentationWidth` is used
696
- # But it can be overridden by setting this parameter
696
+ # By default the indentation width from `Layout/IndentationWidth` is used,
697
+ # but it can be overridden by setting this parameter.
697
698
  IndentationWidth: ~
698
699
 
699
700
  Layout/FirstArrayElementLineBreak:
@@ -724,8 +725,8 @@ Layout/FirstHashElementIndentation:
724
725
  - special_inside_parentheses
725
726
  - consistent
726
727
  - align_braces
727
- # By default, the indentation width from `Layout/IndentationWidth` is used
728
- # But it can be overridden by setting this parameter
728
+ # By default the indentation width from `Layout/IndentationWidth` is used,
729
+ # but it can be overridden by setting this parameter.
729
730
  IndentationWidth: ~
730
731
 
731
732
  Layout/FirstHashElementLineBreak:
@@ -760,8 +761,8 @@ Layout/FirstParameterIndentation:
760
761
  SupportedStyles:
761
762
  - consistent
762
763
  - align_parentheses
763
- # By default, the indentation width from `Layout/IndentationWidth` is used
764
- # But it can be overridden by setting this parameter
764
+ # By default the indentation width from `Layout/IndentationWidth` is used,
765
+ # but it can be overridden by setting this parameter.
765
766
  IndentationWidth: ~
766
767
 
767
768
  Layout/HashAlignment:
@@ -771,7 +772,7 @@ Layout/HashAlignment:
771
772
  Enabled: true
772
773
  AllowMultipleStyles: true
773
774
  VersionAdded: '0.49'
774
- VersionChanged: '0.77'
775
+ VersionChanged: '1.16'
775
776
  # Alignment of entries using hash rocket as separator. Valid values are:
776
777
  #
777
778
  # key - left alignment of keys
@@ -882,8 +883,8 @@ Layout/IndentationStyle:
882
883
  Enabled: true
883
884
  VersionAdded: '0.49'
884
885
  VersionChanged: '0.82'
885
- # By default, the indentation width from Layout/IndentationWidth is used
886
- # But it can be overridden by setting this parameter
886
+ # By default the indentation width from `Layout/IndentationWidth` is used,
887
+ # but it can be overridden by setting this parameter.
887
888
  # It is used during auto-correction to determine how many spaces should
888
889
  # replace each tab.
889
890
  IndentationWidth: ~
@@ -922,6 +923,20 @@ Layout/LeadingEmptyLines:
922
923
  VersionAdded: '0.57'
923
924
  VersionChanged: '0.77'
924
925
 
926
+ Layout/LineEndStringConcatenationIndentation:
927
+ Description: >-
928
+ Checks the indentation of the next line after a line that
929
+ ends with a string literal and a backslash.
930
+ Enabled: pending
931
+ VersionAdded: '1.18'
932
+ EnforcedStyle: aligned
933
+ SupportedStyles:
934
+ - aligned
935
+ - indented
936
+ # By default the indentation width from `Layout/IndentationWidth` is used,
937
+ # but it can be overridden by setting this parameter.
938
+ IndentationWidth: ~
939
+
925
940
  Layout/LineLength:
926
941
  Description: 'Checks that line length does not exceed the configured limit.'
927
942
  StyleGuide: '#max-line-length'
@@ -1052,8 +1067,8 @@ Layout/MultilineMethodCallIndentation:
1052
1067
  - aligned
1053
1068
  - indented
1054
1069
  - indented_relative_to_receiver
1055
- # By default, the indentation width from Layout/IndentationWidth is used
1056
- # But it can be overridden by setting this parameter
1070
+ # By default the indentation width from `Layout/IndentationWidth` is used,
1071
+ # but it can be overridden by setting this parameter.
1057
1072
  IndentationWidth: ~
1058
1073
 
1059
1074
  Layout/MultilineMethodDefinitionBraceLayout:
@@ -1082,8 +1097,8 @@ Layout/MultilineOperationIndentation:
1082
1097
  SupportedStyles:
1083
1098
  - aligned
1084
1099
  - indented
1085
- # By default, the indentation width from `Layout/IndentationWidth` is used
1086
- # But it can be overridden by setting this parameter
1100
+ # By default the indentation width from `Layout/IndentationWidth` is used,
1101
+ # but it can be overridden by setting this parameter.
1087
1102
  IndentationWidth: ~
1088
1103
 
1089
1104
  Layout/ParameterAlignment:
@@ -1111,8 +1126,8 @@ Layout/ParameterAlignment:
1111
1126
  SupportedStyles:
1112
1127
  - with_first_parameter
1113
1128
  - with_fixed_indentation
1114
- # By default, the indentation width from Layout/IndentationWidth is used
1115
- # But it can be overridden by setting this parameter
1129
+ # By default the indentation width from `Layout/IndentationWidth` is used,
1130
+ # but it can be overridden by setting this parameter.
1116
1131
  IndentationWidth: ~
1117
1132
 
1118
1133
  Layout/RedundantLineBreak:
@@ -1645,6 +1660,12 @@ Lint/EmptyFile:
1645
1660
  AllowComments: true
1646
1661
  VersionAdded: '0.90'
1647
1662
 
1663
+ Lint/EmptyInPattern:
1664
+ Description: 'Checks for the presence of `in` pattern branches without a body.'
1665
+ Enabled: pending
1666
+ AllowComments: true
1667
+ VersionAdded: '1.16'
1668
+
1648
1669
  Lint/EmptyInterpolation:
1649
1670
  Description: 'Checks for empty string interpolation.'
1650
1671
  Enabled: true
@@ -1788,7 +1809,7 @@ Lint/MissingCopEnableDirective:
1788
1809
  Lint/MissingSuper:
1789
1810
  Description: >-
1790
1811
  This cop checks for the presence of constructors and lifecycle callbacks
1791
- without calls to `super`'.
1812
+ without calls to `super`.
1792
1813
  Enabled: true
1793
1814
  VersionAdded: '0.89'
1794
1815
  VersionChanged: '1.4'
@@ -2092,6 +2113,7 @@ Lint/SymbolConversion:
2092
2113
  Description: 'Checks for unnecessary symbol conversions.'
2093
2114
  Enabled: pending
2094
2115
  VersionAdded: '1.9'
2116
+ VersionChanged: '1.16'
2095
2117
  EnforcedStyle: strict
2096
2118
  SupportedStyles:
2097
2119
  - strict
@@ -2512,6 +2534,31 @@ Naming/HeredocDelimiterNaming:
2512
2534
  ForbiddenDelimiters:
2513
2535
  - !ruby/regexp '/(^|\s)(EO[A-Z]{1}|END)(\s|$)/'
2514
2536
 
2537
+ Naming/InclusiveLanguage:
2538
+ Description: 'Recommend the use of inclusive language instead of problematic terms.'
2539
+ Enabled: pending
2540
+ VersionAdded: '1.18'
2541
+ CheckIdentifiers: true
2542
+ CheckConstants: true
2543
+ CheckVariables: true
2544
+ CheckStrings: false
2545
+ CheckSymbols: true
2546
+ CheckComments: true
2547
+ CheckFilepaths: true
2548
+ FlaggedTerms:
2549
+ whitelist:
2550
+ Regex: !ruby/regexp '/white[-_\s]?list/'
2551
+ Suggestions:
2552
+ - allowlist
2553
+ - permit
2554
+ blacklist:
2555
+ Regex: !ruby/regexp '/black[-_\s]?list/'
2556
+ Suggestions:
2557
+ - denylist
2558
+ - block
2559
+ slave:
2560
+ Suggestions: ['replica', 'secondary', 'follower']
2561
+
2515
2562
  Naming/MemoizedInstanceVariableName:
2516
2563
  Description: >-
2517
2564
  Memoized method name should match memo instance variable name.
@@ -3103,6 +3150,7 @@ Style/CommentAnnotation:
3103
3150
  - HACK
3104
3151
  - REVIEW
3105
3152
  - NOTE
3153
+ RequireColon: true
3106
3154
 
3107
3155
  Style/CommentedKeyword:
3108
3156
  Description: 'Do not place comments on the same line as certain keywords.'
@@ -3490,8 +3538,10 @@ Style/HashEachMethods:
3490
3538
  Description: 'Use Hash#each_key and Hash#each_value.'
3491
3539
  StyleGuide: '#hash-each'
3492
3540
  Enabled: true
3493
- VersionAdded: '0.80'
3494
3541
  Safe: false
3542
+ VersionAdded: '0.80'
3543
+ VersionChanged: '1.16'
3544
+ AllowedReceivers: []
3495
3545
 
3496
3546
  Style/HashExcept:
3497
3547
  Description: >-
@@ -3554,6 +3604,7 @@ Style/IdenticalConditionalBranches:
3554
3604
  out of the conditional.
3555
3605
  Enabled: true
3556
3606
  VersionAdded: '0.36'
3607
+ VersionChanged: '1.16'
3557
3608
 
3558
3609
  Style/IfInsideElse:
3559
3610
  Description: 'Finds if nodes inside else, which can be converted to elsif.'
@@ -3600,6 +3651,12 @@ Style/ImplicitRuntimeError:
3600
3651
  Enabled: false
3601
3652
  VersionAdded: '0.41'
3602
3653
 
3654
+ Style/InPatternThen:
3655
+ Description: 'Checks for `in;` uses in `case` expressions.'
3656
+ StyleGuide: '#no-in-pattern-semicolons'
3657
+ Enabled: pending
3658
+ VersionAdded: '1.16'
3659
+
3603
3660
  Style/InfiniteLoop:
3604
3661
  Description: >-
3605
3662
  Use Kernel#loop for infinite loops.
@@ -3828,6 +3885,12 @@ Style/MultilineIfThen:
3828
3885
  VersionAdded: '0.9'
3829
3886
  VersionChanged: '0.26'
3830
3887
 
3888
+ Style/MultilineInPatternThen:
3889
+ Description: 'Do not use `then` for multi-line `in` statement.'
3890
+ StyleGuide: '#no-then'
3891
+ Enabled: pending
3892
+ VersionAdded: '1.16'
3893
+
3831
3894
  Style/MultilineMemoization:
3832
3895
  Description: 'Wrap multiline memoizations in a `begin` and `end` block.'
3833
3896
  Enabled: true
@@ -4186,6 +4249,16 @@ Style/Proc:
4186
4249
  VersionAdded: '0.9'
4187
4250
  VersionChanged: '0.18'
4188
4251
 
4252
+ Style/QuotedSymbols:
4253
+ Description: 'Use a consistent style for quoted symbols.'
4254
+ Enabled: pending
4255
+ VersionAdded: '1.16'
4256
+ EnforcedStyle: same_as_string_literals
4257
+ SupportedStyles:
4258
+ - same_as_string_literals
4259
+ - single_quotes
4260
+ - double_quotes
4261
+
4189
4262
  Style/RaiseArgs:
4190
4263
  Description: 'Checks the arguments passed to raise/fail.'
4191
4264
  StyleGuide: '#exception-class-messages'
@@ -4543,7 +4616,8 @@ Style/StringConcatenation:
4543
4616
  Enabled: true
4544
4617
  Safe: false
4545
4618
  VersionAdded: '0.89'
4546
- VersionChanged: '1.6'
4619
+ VersionChanged: '1.18'
4620
+ Mode: aggressive
4547
4621
 
4548
4622
  Style/StringHashKeys:
4549
4623
  Description: 'Prefer symbols instead of strings as hash keys.'
data/lib/cookstyle.rb CHANGED
@@ -46,7 +46,7 @@ require_relative 'rubocop/chef/cookbook_only'
46
46
  require_relative 'rubocop/cop/target_chef_version'
47
47
 
48
48
  # Chef Infra specific cops
49
- Dir.glob(__dir__ + '/rubocop/cop/chef/**/*.rb') do |file|
49
+ Dir.glob(__dir__ + '/rubocop/cop/**/*.rb') do |file|
50
50
  next if File.directory?(file)
51
51
 
52
52
  require_relative file # not actually relative but require_relative is faster
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  module Cookstyle
3
- VERSION = "7.13.0" # rubocop: disable Style/StringLiterals
4
- RUBOCOP_VERSION = '1.15.0'
3
+ VERSION = "7.15.2" # rubocop: disable Style/StringLiterals
4
+ RUBOCOP_VERSION = '1.18.4'
5
5
  end
@@ -0,0 +1,53 @@
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 Policyfile source of `:community` has been replaced with `:supermarket`
23
+ #
24
+ # @example
25
+ #
26
+ # #### incorrect
27
+ # default_source :community
28
+ #
29
+ # #### correct
30
+ # default_source :supermarket
31
+ #
32
+ class PolicyfileCommunitySource < Base
33
+ extend AutoCorrector
34
+
35
+ MSG = 'The Policyfile source of `:community` has been replaced with `:supermarket`.'
36
+ RESTRICT_ON_SEND = [:default_source].freeze
37
+
38
+ def_node_matcher :community_source?, <<-PATTERN
39
+ (send nil? :default_source (:sym :community))
40
+ PATTERN
41
+
42
+ def on_send(node)
43
+ community_source?(node) do
44
+ add_offense(node, message: MSG, severity: :warning) do |corrector|
45
+ corrector.replace(node, 'default_source :supermarket')
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,53 @@
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 InSpec
21
+ module Deprecations
22
+ # The InSpec inputs `default` option has been replaced with the `value` option.
23
+ #
24
+ # @example
25
+ #
26
+ # #### incorrect
27
+ # login_defs_umask = input('login_defs_umask', default: '077', description: 'Default umask to set in login.defs')
28
+ #
29
+ # #### correct
30
+ # login_defs_umask = input('login_defs_umask', value: '077', description: 'Default umask to set in login.defs')
31
+ #
32
+ class AttributeDefault < Base
33
+ extend AutoCorrector
34
+
35
+ MSG = 'The InSpec inputs `default` option has been replaced with the `value` option.'
36
+ RESTRICT_ON_SEND = [:attribute, :input].freeze
37
+
38
+ def_node_matcher :default?, <<-PATTERN
39
+ (send nil? {:attribute :input} _ (hash <(pair $(sym :default) ...) ...>) )
40
+ PATTERN
41
+
42
+ def on_send(node)
43
+ default?(node) do |n|
44
+ add_offense(n, message: MSG, severity: :warning) do |corrector|
45
+ corrector.replace(n, 'value')
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,47 @@
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 InSpec
21
+ module Deprecations
22
+ # InSpec attributes have been renamed to inputs. Use the `input` method not the deprecation `attribute` method to access these values.
23
+ #
24
+ # @example
25
+ #
26
+ # #### incorrect
27
+ # login_defs_umask = attribute('login_defs_umask', value: '077', description: 'Default umask to set in login.defs')
28
+ #
29
+ # #### correct
30
+ # login_defs_umask = input('login_defs_umask', value: '077', description: 'Default umask to set in login.defs')
31
+ #
32
+ class AttributeHelper < Base
33
+ extend AutoCorrector
34
+
35
+ MSG = 'InSpec attributes have been renamed to inputs. Use the `input` method not the deprecation `attribute` method to access these values.'
36
+ RESTRICT_ON_SEND = [:attribute].freeze
37
+
38
+ def on_send(node)
39
+ add_offense(node, message: MSG, severity: :warning) do |corrector|
40
+ corrector.replace(node.loc.expression, node.loc.expression.source.gsub(/^attribute/, 'input'))
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ 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.13.0
4
+ version: 7.15.2
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-05-27 00:00:00.000000000 Z
12
+ date: 2021-07-24 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.15.0
20
+ version: 1.18.4
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.15.0
27
+ version: 1.18.4
28
28
  description:
29
29
  email:
30
30
  - thom@chef.io
@@ -134,6 +134,7 @@ files:
134
134
  - lib/rubocop/cop/chef/deprecation/partial_search_class_usage.rb
135
135
  - lib/rubocop/cop/chef/deprecation/partial_search_helper_usage.rb
136
136
  - lib/rubocop/cop/chef/deprecation/poise_archive.rb
137
+ - lib/rubocop/cop/chef/deprecation/policyfile_community_source.rb
137
138
  - lib/rubocop/cop/chef/deprecation/powershell_cookbook_helpers.rb
138
139
  - lib/rubocop/cop/chef/deprecation/require_recipe.rb
139
140
  - lib/rubocop/cop/chef/deprecation/resource_overrides_provides_method.rb
@@ -275,6 +276,8 @@ files:
275
276
  - lib/rubocop/cop/chef/style/unnecessary_os_check.rb
276
277
  - lib/rubocop/cop/chef/style/unnecessary_platform_case_statement.rb
277
278
  - lib/rubocop/cop/chef/style/use_platform_helpers.rb
279
+ - lib/rubocop/cop/inspec/deprecation/attribute_default.rb
280
+ - lib/rubocop/cop/inspec/deprecation/attribute_helper.rb
278
281
  - lib/rubocop/cop/target_chef_version.rb
279
282
  - lib/rubocop/monkey_patches/base.rb
280
283
  - lib/rubocop/monkey_patches/config.rb