cookstyle 7.13.0 → 7.14.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 +4 -4
- data/config/cookstyle.yml +21 -0
- data/config/disable_all.yml +8 -0
- data/config/upstream.yml +36 -3
- data/lib/cookstyle.rb +1 -1
- data/lib/cookstyle/version.rb +2 -2
- data/lib/rubocop/cop/inspec/deprecation/attribute_default.rb +53 -0
- data/lib/rubocop/cop/inspec/deprecation/attribute_helper.rb +47 -0
- metadata +6 -4
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 2fb8828f5ea858d36d8aece2ac5de3e469e04fcd86301ebb2fa86aeffd2ec9bc
         | 
| 4 | 
            +
              data.tar.gz: 4b1101bab8a823c1a161478dbb1503e9c7cca0d340a33c07aecef0f6c15efdff
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 7308b900c24d494ec617f001a3b83ee3f9491fb38de29ee7491c67c3c58605ba21c43c81419567ddd5b150674221c243ceec1faa075ab3744c2e426097f09624
         | 
| 7 | 
            +
              data.tar.gz: 3ba724acde273762b7073740e84f19b8d439d20f73ec73e237fd4cefc5dc7c65d84d7b4d62992d56aedca825e924f32063e6557811401f0e0740de6dc4b80e5f
         | 
    
        data/config/cookstyle.yml
    CHANGED
    
    | @@ -2080,6 +2080,27 @@ Chef/Effortless/Berksfile: | |
| 2080 2080 | 
             
              Include:
         | 
| 2081 2081 | 
             
                - '**/Berksfile'
         | 
| 2082 2082 |  | 
| 2083 | 
            +
            #### InSpec cops
         | 
| 2084 | 
            +
             | 
| 2085 | 
            +
            InSpec/Deprecations:
         | 
| 2086 | 
            +
              StyleGuideBaseURL: https://docs.chef.io/workstation/cookstyle/
         | 
| 2087 | 
            +
             | 
| 2088 | 
            +
            InSpec/Deprecations/AttributeHelper:
         | 
| 2089 | 
            +
              Description: InSpec attributes have been renamed to inputs. Use the `input` method not the deprecation `attribute` method to access these values.
         | 
| 2090 | 
            +
              StyleGuide: 'inspec_deprecations_attributehelper'
         | 
| 2091 | 
            +
              Enabled: true
         | 
| 2092 | 
            +
              VersionAdded: '7.14.0'
         | 
| 2093 | 
            +
              Include:
         | 
| 2094 | 
            +
                - '**/controls/*.rb'
         | 
| 2095 | 
            +
             | 
| 2096 | 
            +
            InSpec/Deprecations/AttributeDefault:
         | 
| 2097 | 
            +
              Description: The InSpec inputs `default` option has been replaced with the `value` option.
         | 
| 2098 | 
            +
              StyleGuide: 'inspec_deprecations_attributedefaults'
         | 
| 2099 | 
            +
              Enabled: true
         | 
| 2100 | 
            +
              VersionAdded: '7.14.0'
         | 
| 2101 | 
            +
              Include:
         | 
| 2102 | 
            +
                - '**/controls/*.rb'
         | 
| 2103 | 
            +
             | 
| 2083 2104 | 
             
            #### The base rubocop 0.37 enabled.yml file we started with ####
         | 
| 2084 2105 |  | 
| 2085 2106 | 
             
            Layout/AccessModifierIndentation:
         | 
    
        data/config/disable_all.yml
    CHANGED
    
    | @@ -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:
         | 
    
        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: ' | 
| 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
         | 
| @@ -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
         | 
| @@ -3490,8 +3498,10 @@ Style/HashEachMethods: | |
| 3490 3498 | 
             
              Description: 'Use Hash#each_key and Hash#each_value.'
         | 
| 3491 3499 | 
             
              StyleGuide: '#hash-each'
         | 
| 3492 3500 | 
             
              Enabled: true
         | 
| 3493 | 
            -
              VersionAdded: '0.80'
         | 
| 3494 3501 | 
             
              Safe: false
         | 
| 3502 | 
            +
              VersionAdded: '0.80'
         | 
| 3503 | 
            +
              VersionChanged: '1.16'
         | 
| 3504 | 
            +
              AllowedReceivers: []
         | 
| 3495 3505 |  | 
| 3496 3506 | 
             
            Style/HashExcept:
         | 
| 3497 3507 | 
             
              Description: >-
         | 
| @@ -3554,6 +3564,7 @@ Style/IdenticalConditionalBranches: | |
| 3554 3564 | 
             
                             out of the conditional.
         | 
| 3555 3565 | 
             
              Enabled: true
         | 
| 3556 3566 | 
             
              VersionAdded: '0.36'
         | 
| 3567 | 
            +
              VersionChanged: '1.16'
         | 
| 3557 3568 |  | 
| 3558 3569 | 
             
            Style/IfInsideElse:
         | 
| 3559 3570 | 
             
              Description: 'Finds if nodes inside else, which can be converted to elsif.'
         | 
| @@ -3600,6 +3611,12 @@ Style/ImplicitRuntimeError: | |
| 3600 3611 | 
             
              Enabled: false
         | 
| 3601 3612 | 
             
              VersionAdded: '0.41'
         | 
| 3602 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 | 
            +
             | 
| 3603 3620 | 
             
            Style/InfiniteLoop:
         | 
| 3604 3621 | 
             
              Description: >-
         | 
| 3605 3622 | 
             
                             Use Kernel#loop for infinite loops.
         | 
| @@ -3828,6 +3845,12 @@ Style/MultilineIfThen: | |
| 3828 3845 | 
             
              VersionAdded: '0.9'
         | 
| 3829 3846 | 
             
              VersionChanged: '0.26'
         | 
| 3830 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 | 
            +
             | 
| 3831 3854 | 
             
            Style/MultilineMemoization:
         | 
| 3832 3855 | 
             
              Description: 'Wrap multiline memoizations in a `begin` and `end` block.'
         | 
| 3833 3856 | 
             
              Enabled: true
         | 
| @@ -4186,6 +4209,16 @@ Style/Proc: | |
| 4186 4209 | 
             
              VersionAdded: '0.9'
         | 
| 4187 4210 | 
             
              VersionChanged: '0.18'
         | 
| 4188 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 | 
            +
             | 
| 4189 4222 | 
             
            Style/RaiseArgs:
         | 
| 4190 4223 | 
             
              Description: 'Checks the arguments passed to raise/fail.'
         | 
| 4191 4224 | 
             
              StyleGuide: '#exception-class-messages'
         | 
    
        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 | 
| 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
         | 
    
        data/lib/cookstyle/version.rb
    CHANGED
    
    
| @@ -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. | 
| 4 | 
            +
              version: 7.14.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- | 
| 12 | 
            +
            date: 2021-06-23 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.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. | 
| 27 | 
            +
                    version: 1.17.0
         | 
| 28 28 | 
             
            description: 
         | 
| 29 29 | 
             
            email:
         | 
| 30 30 | 
             
            - thom@chef.io
         | 
| @@ -275,6 +275,8 @@ files: | |
| 275 275 | 
             
            - lib/rubocop/cop/chef/style/unnecessary_os_check.rb
         | 
| 276 276 | 
             
            - lib/rubocop/cop/chef/style/unnecessary_platform_case_statement.rb
         | 
| 277 277 | 
             
            - lib/rubocop/cop/chef/style/use_platform_helpers.rb
         | 
| 278 | 
            +
            - lib/rubocop/cop/inspec/deprecation/attribute_default.rb
         | 
| 279 | 
            +
            - lib/rubocop/cop/inspec/deprecation/attribute_helper.rb
         | 
| 278 280 | 
             
            - lib/rubocop/cop/target_chef_version.rb
         | 
| 279 281 | 
             
            - lib/rubocop/monkey_patches/base.rb
         | 
| 280 282 | 
             
            - lib/rubocop/monkey_patches/config.rb
         |