cookstyle 7.12.3 → 7.15.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d6b4ac76f05be60a51f678d80bb34d68d4396560b2887214a0a3dd7ac6cd038f
4
- data.tar.gz: 74a95cd52549baf8086aa14e3579370d917b8db198deafdc6ced6c28071b3956
3
+ metadata.gz: 9e7636105260988af89327c7e9c5dc27b668fd307fed9000cfe2749780358a23
4
+ data.tar.gz: 13c4a79ce3721f3f9116ef7f440b8d207cb1c2b0f2d34f9999305cfa0dc68eea
5
5
  SHA512:
6
- metadata.gz: 105f70150e5c66d01b6e157b7f07660a3bf4c755dbb7eed18709fca10b911b54c14fbfff2a2cd41d04ce11b649525b742a469f5f3631ee6c13eaa9f7fa1dc90b
7
- data.tar.gz: fb7ffae6e230fa1f26f68626cd9adf4f8d265aee2feeec5fed68c963fde79bbce1022fa973e6bc2cccfbb07e396e4784d81ba0747778915eb3c288ea7e20f19b
6
+ metadata.gz: bc5b985e7d9355b6e8d7029e590e019649ccbca37c41510cc9a57fc46c533af38e1cb0e022bc412dfcc0f3039a6a6da32f793cac9b496bfea70f937a5cbe7113
7
+ data.tar.gz: 826b7a3f355935d55ef2fb6636a815f2bebfe35b1ecb9a43038e2d164dff6d9f7d35c39ebc72961ea85c90e02b3d5312e052986213914d45d855f4e1857f08ef
data/config/cookstyle.yml CHANGED
@@ -3,8 +3,8 @@ AllCops:
3
3
  TargetRubyVersion: 2.5
4
4
  TargetChefVersion: ~
5
5
  Exclude:
6
- - '/**/files/**/*'
7
- - '/**/vendor/**/*'
6
+ - '**/files/**/*'
7
+ - '**/vendor/**/*'
8
8
  - Guardfile
9
9
 
10
10
  ###############################
@@ -1205,6 +1205,16 @@ Chef/Deprecations/ResourceWithoutUnifiedTrue:
1205
1205
  VersionAdded: '7.12.0'
1206
1206
  Include:
1207
1207
  - '**/resources/*.rb'
1208
+ Exclude:
1209
+ - '**/spec/**/*.rb'
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'
1208
1218
 
1209
1219
  ###############################
1210
1220
  # Chef/Modernize: Cleaning up legacy code and using new built-in resources
@@ -2078,6 +2088,27 @@ Chef/Effortless/Berksfile:
2078
2088
  Include:
2079
2089
  - '**/Berksfile'
2080
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
+
2081
2112
  #### The base rubocop 0.37 enabled.yml file we started with ####
2082
2113
 
2083
2114
  Layout/AccessModifierIndentation:
@@ -275,6 +275,8 @@ Lint/EmptyExpression:
275
275
  Enabled: false
276
276
  Lint/EmptyFile:
277
277
  Enabled: false
278
+ Lint/EmptyInPattern:
279
+ Enabled: false
278
280
  Lint/EmptyInterpolation:
279
281
  Enabled: false
280
282
  Lint/EmptyWhen:
@@ -667,6 +669,8 @@ Style/IfWithSemicolon:
667
669
  Enabled: false
668
670
  Style/ImplicitRuntimeError:
669
671
  Enabled: false
672
+ Style/InPatternThen:
673
+ Enabled: false
670
674
  Style/InfiniteLoop:
671
675
  Enabled: false
672
676
  Style/InverseMethods:
@@ -687,6 +691,8 @@ Style/MethodCallWithoutArgsParentheses:
687
691
  Enabled: false
688
692
  Style/MethodCallWithArgsParentheses:
689
693
  Enabled: false
694
+ Style/MultilineInPatternThen:
695
+ Enabled: false
690
696
  Style/RedundantAssignment:
691
697
  Enabled: false
692
698
  Style/RedundantFetchBlock:
@@ -787,6 +793,8 @@ Style/PreferredHashMethods:
787
793
  Enabled: false
788
794
  Style/Proc:
789
795
  Enabled: false
796
+ Style/QuotedSymbols:
797
+ Enabled: false
790
798
  Style/RaiseArgs:
791
799
  Enabled: false
792
800
  Style/RandomWithOffset:
@@ -883,6 +891,8 @@ Style/SymbolProc:
883
891
  Enabled: false
884
892
  Style/TernaryParentheses:
885
893
  Enabled: false
894
+ Style/TopLevelMethodDefinition:
895
+ Enabled: false
886
896
  Style/TrailingBodyOnClass:
887
897
  Enabled: false
888
898
  Style/TrailingBodyOnMethodDefinition:
data/config/upstream.yml CHANGED
@@ -377,10 +377,11 @@ 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
@@ -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
@@ -1612,7 +1613,7 @@ Lint/EmptyBlock:
1612
1613
  Description: 'This cop checks for blocks without a body.'
1613
1614
  Enabled: pending
1614
1615
  VersionAdded: '1.1'
1615
- VersionChanged: '1.3'
1616
+ VersionChanged: '1.15'
1616
1617
  AllowComments: true
1617
1618
  AllowEmptyLambdas: true
1618
1619
 
@@ -1645,6 +1646,12 @@ Lint/EmptyFile:
1645
1646
  AllowComments: true
1646
1647
  VersionAdded: '0.90'
1647
1648
 
1649
+ Lint/EmptyInPattern:
1650
+ Description: 'Checks for the presence of `in` pattern branches without a body.'
1651
+ Enabled: pending
1652
+ AllowComments: true
1653
+ VersionAdded: '1.16'
1654
+
1648
1655
  Lint/EmptyInterpolation:
1649
1656
  Description: 'Checks for empty string interpolation.'
1650
1657
  Enabled: true
@@ -2092,6 +2099,7 @@ Lint/SymbolConversion:
2092
2099
  Description: 'Checks for unnecessary symbol conversions.'
2093
2100
  Enabled: pending
2094
2101
  VersionAdded: '1.9'
2102
+ VersionChanged: '1.16'
2095
2103
  EnforcedStyle: strict
2096
2104
  SupportedStyles:
2097
2105
  - strict
@@ -3480,6 +3488,7 @@ Style/HashAsLastArrayItem:
3480
3488
 
3481
3489
  Style/HashConversion:
3482
3490
  Description: 'Avoid Hash[] in favor of ary.to_h or literal hashes.'
3491
+ StyleGuide: '#avoid-hash-constructor'
3483
3492
  Enabled: pending
3484
3493
  VersionAdded: '1.10'
3485
3494
  VersionChanged: '1.11'
@@ -3489,8 +3498,10 @@ Style/HashEachMethods:
3489
3498
  Description: 'Use Hash#each_key and Hash#each_value.'
3490
3499
  StyleGuide: '#hash-each'
3491
3500
  Enabled: true
3492
- VersionAdded: '0.80'
3493
3501
  Safe: false
3502
+ VersionAdded: '0.80'
3503
+ VersionChanged: '1.16'
3504
+ AllowedReceivers: []
3494
3505
 
3495
3506
  Style/HashExcept:
3496
3507
  Description: >-
@@ -3553,6 +3564,7 @@ Style/IdenticalConditionalBranches:
3553
3564
  out of the conditional.
3554
3565
  Enabled: true
3555
3566
  VersionAdded: '0.36'
3567
+ VersionChanged: '1.16'
3556
3568
 
3557
3569
  Style/IfInsideElse:
3558
3570
  Description: 'Finds if nodes inside else, which can be converted to elsif.'
@@ -3599,6 +3611,12 @@ Style/ImplicitRuntimeError:
3599
3611
  Enabled: false
3600
3612
  VersionAdded: '0.41'
3601
3613
 
3614
+ Style/InPatternThen:
3615
+ Description: 'Checks for `in;` uses in `case` expressions.'
3616
+ StyleGuide: '#no-in-pattern-semicolons'
3617
+ Enabled: pending
3618
+ VersionAdded: '1.16'
3619
+
3602
3620
  Style/InfiniteLoop:
3603
3621
  Description: >-
3604
3622
  Use Kernel#loop for infinite loops.
@@ -3827,6 +3845,12 @@ Style/MultilineIfThen:
3827
3845
  VersionAdded: '0.9'
3828
3846
  VersionChanged: '0.26'
3829
3847
 
3848
+ Style/MultilineInPatternThen:
3849
+ Description: 'Do not use `then` for multi-line `in` statement.'
3850
+ StyleGuide: '#no-then'
3851
+ Enabled: pending
3852
+ VersionAdded: '1.16'
3853
+
3830
3854
  Style/MultilineMemoization:
3831
3855
  Description: 'Wrap multiline memoizations in a `begin` and `end` block.'
3832
3856
  Enabled: true
@@ -3998,6 +4022,7 @@ Style/NilLambda:
3998
4022
  Description: 'Prefer `-> {}` to `-> { nil }`.'
3999
4023
  Enabled: pending
4000
4024
  VersionAdded: '1.3'
4025
+ VersionChanged: '1.15'
4001
4026
 
4002
4027
  Style/NonNilCheck:
4003
4028
  Description: 'Checks for redundant nil checks.'
@@ -4184,6 +4209,16 @@ Style/Proc:
4184
4209
  VersionAdded: '0.9'
4185
4210
  VersionChanged: '0.18'
4186
4211
 
4212
+ Style/QuotedSymbols:
4213
+ Description: 'Use a consistent style for quoted symbols.'
4214
+ Enabled: pending
4215
+ VersionAdded: '1.16'
4216
+ EnforcedStyle: same_as_string_literals
4217
+ SupportedStyles:
4218
+ - same_as_string_literals
4219
+ - single_quotes
4220
+ - double_quotes
4221
+
4187
4222
  Style/RaiseArgs:
4188
4223
  Description: 'Checks the arguments passed to raise/fail.'
4189
4224
  StyleGuide: '#exception-class-messages'
@@ -4651,6 +4686,12 @@ Style/TernaryParentheses:
4651
4686
  - require_parentheses_when_complex
4652
4687
  AllowSafeAssignment: true
4653
4688
 
4689
+ Style/TopLevelMethodDefinition:
4690
+ Description: 'This cop looks for top-level method definitions.'
4691
+ StyleGuide: '#top-level-methods'
4692
+ Enabled: false
4693
+ VersionAdded: '1.15'
4694
+
4654
4695
  Style/TrailingBodyOnClass:
4655
4696
  Description: 'Class body goes below class statement.'
4656
4697
  Enabled: true
@@ -4737,7 +4778,7 @@ Style/TrivialAccessors:
4737
4778
  StyleGuide: '#attr_family'
4738
4779
  Enabled: true
4739
4780
  VersionAdded: '0.9'
4740
- VersionChanged: '0.77'
4781
+ VersionChanged: '1.15'
4741
4782
  # When set to `false` the cop will suggest the use of accessor methods
4742
4783
  # in situations like:
4743
4784
  #
@@ -4756,7 +4797,7 @@ Style/TrivialAccessors:
4756
4797
  # on_exception :restart
4757
4798
  #
4758
4799
  # Commonly used in DSLs
4759
- AllowDSLWriters: false
4800
+ AllowDSLWriters: true
4760
4801
  IgnoreClassMethods: false
4761
4802
  AllowedMethods:
4762
4803
  - to_ary
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.12.3" # rubocop: disable Style/StringLiterals
4
- RUBOCOP_VERSION = '1.14.0'
3
+ VERSION = "7.15.0" # rubocop: disable Style/StringLiterals
4
+ RUBOCOP_VERSION = '1.17.0'
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
@@ -32,12 +32,12 @@ module RuboCop
32
32
  # action :create
33
33
  # end
34
34
  #
35
- # #### correct
36
- # windows_uac 'Set Windows UAC settings' do
37
- # enable_uac false
38
- # prompt_on_secure_desktop true
39
- # consent_behavior_admins :no_prompt
40
- # end
35
+ # #### correct
36
+ # windows_uac 'Set Windows UAC settings' do
37
+ # enable_uac false
38
+ # prompt_on_secure_desktop true
39
+ # consent_behavior_admins :no_prompt
40
+ # end
41
41
  #
42
42
  class WindowsRegistryUAC < Base
43
43
  include RuboCop::Chef::CookbookHelpers
@@ -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.12.3
4
+ version: 7.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thom May
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-05-16 00:00:00.000000000 Z
12
+ date: 2021-07-02 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.14.0
20
+ version: 1.17.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.14.0
27
+ version: 1.17.0
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