rubocop 1.68.0 → 1.69.1
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/README.md +1 -1
- data/config/default.yml +41 -6
- data/lib/rubocop/cop/base.rb +1 -1
- data/lib/rubocop/cop/bundler/gem_filename.rb +0 -1
- data/lib/rubocop/cop/bundler/insecure_protocol_source.rb +0 -1
- data/lib/rubocop/cop/correctors/for_to_each_corrector.rb +1 -1
- data/lib/rubocop/cop/gemspec/deprecated_attribute_assignment.rb +1 -2
- data/lib/rubocop/cop/gemspec/required_ruby_version.rb +0 -2
- data/lib/rubocop/cop/generator.rb +6 -0
- data/lib/rubocop/cop/internal_affairs/location_line_equality_comparison.rb +3 -4
- data/lib/rubocop/cop/internal_affairs/numblock_handler.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/operator_keyword.rb +46 -0
- data/lib/rubocop/cop/internal_affairs/style_detected_api_use.rb +0 -2
- data/lib/rubocop/cop/internal_affairs.rb +1 -0
- data/lib/rubocop/cop/layout/argument_alignment.rb +1 -2
- data/lib/rubocop/cop/layout/array_alignment.rb +1 -1
- data/lib/rubocop/cop/layout/begin_end_alignment.rb +0 -1
- data/lib/rubocop/cop/layout/block_alignment.rb +1 -2
- data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +1 -1
- data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +2 -3
- data/lib/rubocop/cop/layout/empty_lines_around_exception_handling_keywords.rb +3 -4
- data/lib/rubocop/cop/layout/empty_lines_around_method_body.rb +3 -1
- data/lib/rubocop/cop/layout/indentation_width.rb +7 -7
- data/lib/rubocop/cop/layout/leading_comment_space.rb +15 -0
- data/lib/rubocop/cop/layout/line_length.rb +118 -4
- data/lib/rubocop/cop/layout/multiline_method_call_brace_layout.rb +1 -1
- data/lib/rubocop/cop/layout/multiline_method_definition_brace_layout.rb +1 -1
- data/lib/rubocop/cop/layout/multiline_operation_indentation.rb +2 -3
- data/lib/rubocop/cop/layout/parameter_alignment.rb +3 -4
- data/lib/rubocop/cop/layout/redundant_line_break.rb +3 -35
- data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +3 -2
- data/lib/rubocop/cop/layout/space_around_keyword.rb +1 -1
- data/lib/rubocop/cop/layout/space_around_operators.rb +16 -17
- data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +6 -0
- data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +4 -0
- data/lib/rubocop/cop/layout/space_inside_string_interpolation.rb +0 -1
- data/lib/rubocop/cop/lint/binary_operator_with_identical_operands.rb +10 -12
- data/lib/rubocop/cop/lint/circular_argument_reference.rb +6 -0
- data/lib/rubocop/cop/lint/deprecated_open_ssl_constant.rb +2 -1
- data/lib/rubocop/cop/lint/empty_ensure.rb +1 -1
- data/lib/rubocop/cop/lint/empty_file.rb +0 -2
- data/lib/rubocop/cop/lint/ensure_return.rb +1 -1
- data/lib/rubocop/cop/lint/float_comparison.rb +14 -6
- data/lib/rubocop/cop/lint/float_out_of_range.rb +1 -3
- data/lib/rubocop/cop/lint/hash_new_with_keyword_arguments_as_default.rb +55 -0
- data/lib/rubocop/cop/lint/interpolation_check.rb +9 -0
- data/lib/rubocop/cop/lint/it_without_arguments_in_block.rb +3 -0
- data/lib/rubocop/cop/lint/literal_as_condition.rb +1 -0
- data/lib/rubocop/cop/lint/literal_assignment_in_condition.rb +1 -1
- data/lib/rubocop/cop/lint/mixed_case_range.rb +2 -5
- data/lib/rubocop/cop/lint/nested_method_definition.rb +1 -1
- data/lib/rubocop/cop/lint/no_return_in_begin_end_blocks.rb +2 -2
- data/lib/rubocop/cop/lint/non_atomic_file_operation.rb +1 -1
- data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +3 -3
- data/lib/rubocop/cop/lint/number_conversion.rb +0 -1
- data/lib/rubocop/cop/lint/numbered_parameter_assignment.rb +1 -2
- data/lib/rubocop/cop/lint/numeric_operation_with_constant_result.rb +106 -0
- data/lib/rubocop/cop/lint/or_assignment_to_constant.rb +1 -2
- data/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +1 -1
- data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +1 -1
- data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +12 -7
- data/lib/rubocop/cop/lint/redundant_splat_expansion.rb +8 -7
- data/lib/rubocop/cop/lint/refinement_import_methods.rb +1 -1
- data/lib/rubocop/cop/lint/regexp_as_condition.rb +0 -1
- data/lib/rubocop/cop/lint/rescue_type.rb +3 -7
- data/lib/rubocop/cop/lint/safe_navigation_consistency.rb +2 -0
- data/lib/rubocop/cop/lint/self_assignment.rb +8 -10
- data/lib/rubocop/cop/lint/shadowed_exception.rb +1 -1
- data/lib/rubocop/cop/lint/unescaped_bracket_in_regexp.rb +3 -0
- data/lib/rubocop/cop/lint/unreachable_code.rb +51 -2
- data/lib/rubocop/cop/lint/unused_method_argument.rb +18 -2
- data/lib/rubocop/cop/lint/useless_defined.rb +55 -0
- data/lib/rubocop/cop/lint/useless_else_without_rescue.rb +4 -0
- data/lib/rubocop/cop/lint/useless_rescue.rb +1 -1
- data/lib/rubocop/cop/lint/useless_setter_call.rb +14 -25
- data/lib/rubocop/cop/lint/void.rb +3 -2
- data/lib/rubocop/cop/metrics/class_length.rb +7 -7
- data/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb +1 -1
- data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +2 -3
- data/lib/rubocop/cop/mixin/check_assignment.rb +4 -12
- data/lib/rubocop/cop/mixin/check_single_line_suitability.rb +49 -0
- data/lib/rubocop/cop/mixin/dig_help.rb +27 -0
- data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +5 -9
- data/lib/rubocop/cop/mixin/range_help.rb +0 -1
- data/lib/rubocop/cop/mixin/target_ruby_version.rb +17 -1
- data/lib/rubocop/cop/naming/accessor_method_name.rb +6 -6
- data/lib/rubocop/cop/naming/constant_name.rb +6 -7
- data/lib/rubocop/cop/naming/file_name.rb +0 -2
- data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +11 -12
- data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +3 -11
- data/lib/rubocop/cop/naming/variable_name.rb +3 -4
- data/lib/rubocop/cop/naming/variable_number.rb +2 -3
- data/lib/rubocop/cop/security/compound_hash.rb +1 -0
- data/lib/rubocop/cop/security/yaml_load.rb +3 -2
- data/lib/rubocop/cop/style/access_modifier_declarations.rb +54 -25
- data/lib/rubocop/cop/style/ambiguous_endless_method_definition.rb +1 -1
- data/lib/rubocop/cop/style/array_intersect.rb +5 -4
- data/lib/rubocop/cop/style/bitwise_predicate.rb +1 -1
- data/lib/rubocop/cop/style/block_delimiters.rb +10 -2
- data/lib/rubocop/cop/style/case_like_if.rb +8 -11
- data/lib/rubocop/cop/style/commented_keyword.rb +11 -1
- data/lib/rubocop/cop/style/conditional_assignment.rb +19 -21
- data/lib/rubocop/cop/style/constant_visibility.rb +3 -12
- data/lib/rubocop/cop/style/dig_chain.rb +89 -0
- data/lib/rubocop/cop/style/fetch_env_var.rb +1 -0
- data/lib/rubocop/cop/style/file_null.rb +73 -0
- data/lib/rubocop/cop/style/file_touch.rb +75 -0
- data/lib/rubocop/cop/style/for.rb +0 -1
- data/lib/rubocop/cop/style/global_vars.rb +1 -3
- data/lib/rubocop/cop/style/guard_clause.rb +1 -1
- data/lib/rubocop/cop/style/hash_conversion.rb +1 -2
- data/lib/rubocop/cop/style/hash_except.rb +19 -7
- data/lib/rubocop/cop/style/if_inside_else.rb +0 -1
- data/lib/rubocop/cop/style/if_with_boolean_literal_branches.rb +1 -2
- data/lib/rubocop/cop/style/if_with_semicolon.rb +14 -5
- data/lib/rubocop/cop/style/inverse_methods.rb +0 -1
- data/lib/rubocop/cop/style/keyword_arguments_merging.rb +2 -2
- data/lib/rubocop/cop/style/lambda_call.rb +3 -2
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +1 -1
- data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +7 -11
- data/lib/rubocop/cop/style/missing_respond_to_missing.rb +33 -3
- data/lib/rubocop/cop/style/multiline_memoization.rb +1 -1
- data/lib/rubocop/cop/style/mutable_constant.rb +4 -5
- data/lib/rubocop/cop/style/negated_if_else_condition.rb +6 -4
- data/lib/rubocop/cop/style/nested_ternary_operator.rb +5 -4
- data/lib/rubocop/cop/style/not.rb +1 -1
- data/lib/rubocop/cop/style/object_then.rb +1 -0
- data/lib/rubocop/cop/style/one_line_conditional.rb +25 -4
- data/lib/rubocop/cop/style/operator_method_call.rb +5 -6
- data/lib/rubocop/cop/style/or_assignment.rb +3 -6
- data/lib/rubocop/cop/style/parallel_assignment.rb +8 -13
- data/lib/rubocop/cop/style/raise_args.rb +1 -1
- data/lib/rubocop/cop/style/redundant_argument.rb +3 -1
- data/lib/rubocop/cop/style/redundant_assignment.rb +1 -1
- data/lib/rubocop/cop/style/redundant_condition.rb +36 -21
- data/lib/rubocop/cop/style/redundant_line_continuation.rb +7 -6
- data/lib/rubocop/cop/style/redundant_parentheses.rb +2 -2
- data/lib/rubocop/cop/style/redundant_regexp_argument.rb +1 -0
- data/lib/rubocop/cop/style/redundant_return.rb +2 -2
- data/lib/rubocop/cop/style/redundant_self.rb +8 -15
- data/lib/rubocop/cop/style/redundant_self_assignment.rb +7 -5
- data/lib/rubocop/cop/style/redundant_self_assignment_branch.rb +4 -4
- data/lib/rubocop/cop/style/redundant_sort.rb +1 -1
- data/lib/rubocop/cop/style/rescue_modifier.rb +2 -3
- data/lib/rubocop/cop/style/safe_navigation.rb +1 -1
- data/lib/rubocop/cop/style/select_by_regexp.rb +1 -1
- data/lib/rubocop/cop/style/self_assignment.rb +11 -17
- data/lib/rubocop/cop/style/signal_exception.rb +2 -3
- data/lib/rubocop/cop/style/single_argument_dig.rb +9 -5
- data/lib/rubocop/cop/style/single_line_do_end_block.rb +13 -3
- data/lib/rubocop/cop/style/sole_nested_conditional.rb +2 -3
- data/lib/rubocop/cop/style/special_global_vars.rb +1 -1
- data/lib/rubocop/cop/style/string_concatenation.rb +13 -12
- data/lib/rubocop/cop/style/swap_values.rb +4 -15
- data/lib/rubocop/cop/style/trailing_underscore_variable.rb +4 -4
- data/lib/rubocop/cop/style/variable_interpolation.rb +1 -2
- data/lib/rubocop/cop/variable_force.rb +4 -10
- data/lib/rubocop/cops_documentation_generator.rb +9 -1
- data/lib/rubocop/version.rb +1 -1
- data/lib/rubocop.rb +8 -0
- metadata +23 -14
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 8ab30572529c057731f5ebd7548808a1aa9f588f75a45ec0d41ecec2dbbc8015
         | 
| 4 | 
            +
              data.tar.gz: 9beff10b3b9361a9ffc58c0da4920c9c7c7d1caa09e813ea96c46cd7f01683a4
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: a1fdca8813de85e849ba3ff5266c589b74986984192247fc53c541c81475ae672788a663444070fc5428cbfd1024de7cccc9ac7924fe0dab8e138069b3f6b8f7
         | 
| 7 | 
            +
              data.tar.gz: 7896834ccaa34e897da918b457b7ab2c738e21b474536144ddbaf71af2d5ae1e829fdeb699701323f6c67d85cb7b2fb1adcc21f3fde1683cb6273387cd390ba2
         | 
    
        data/README.md
    CHANGED
    
    | @@ -52,7 +52,7 @@ To prevent an unwanted RuboCop update you might want to use a conservative versi | |
| 52 52 | 
             
            in your `Gemfile`:
         | 
| 53 53 |  | 
| 54 54 | 
             
            ```rb
         | 
| 55 | 
            -
            gem 'rubocop', '~> 1. | 
| 55 | 
            +
            gem 'rubocop', '~> 1.69', require: false
         | 
| 56 56 | 
             
            ```
         | 
| 57 57 |  | 
| 58 58 | 
             
            See [our versioning policy](https://docs.rubocop.org/rubocop/versioning.html) for further details.
         | 
    
        data/config/default.yml
    CHANGED
    
    | @@ -1086,11 +1086,11 @@ Layout/LineLength: | |
| 1086 1086 | 
             
              StyleGuide: '#max-line-length'
         | 
| 1087 1087 | 
             
              Enabled: true
         | 
| 1088 1088 | 
             
              VersionAdded: '0.25'
         | 
| 1089 | 
            -
              VersionChanged: '1. | 
| 1089 | 
            +
              VersionChanged: '1.69'
         | 
| 1090 1090 | 
             
              Max: 120
         | 
| 1091 | 
            +
              AllowHeredoc: true
         | 
| 1091 1092 | 
             
              # To make it possible to copy or click on URIs in the code, we allow lines
         | 
| 1092 1093 | 
             
              # containing a URI to be longer than Max.
         | 
| 1093 | 
            -
              AllowHeredoc: true
         | 
| 1094 1094 | 
             
              AllowURI: true
         | 
| 1095 1095 | 
             
              URISchemes:
         | 
| 1096 1096 | 
             
                - http
         | 
| @@ -1102,6 +1102,8 @@ Layout/LineLength: | |
| 1102 1102 | 
             
              # elements. Strings will be converted to Regexp objects. A line that matches
         | 
| 1103 1103 | 
             
              # any regular expression listed in this option will be ignored by LineLength.
         | 
| 1104 1104 | 
             
              AllowedPatterns: []
         | 
| 1105 | 
            +
              # If SplitStrings is true, long strings will be split using continuations
         | 
| 1106 | 
            +
              SplitStrings: false
         | 
| 1105 1107 |  | 
| 1106 1108 | 
             
            Layout/MultilineArrayBraceLayout:
         | 
| 1107 1109 | 
             
              Description: >-
         | 
| @@ -1499,7 +1501,6 @@ Layout/SpaceInsideHashLiteralBraces: | |
| 1499 1501 | 
             
                - space
         | 
| 1500 1502 | 
             
                - no_space
         | 
| 1501 1503 |  | 
| 1502 | 
            -
             | 
| 1503 1504 | 
             
            Layout/SpaceInsideParens:
         | 
| 1504 1505 | 
             
              Description: 'No spaces after ( or before ).'
         | 
| 1505 1506 | 
             
              StyleGuide: '#spaces-braces'
         | 
| @@ -1634,7 +1635,7 @@ Lint/BinaryOperatorWithIdenticalOperands: | |
| 1634 1635 | 
             
              Enabled: true
         | 
| 1635 1636 | 
             
              Safe: false
         | 
| 1636 1637 | 
             
              VersionAdded: '0.89'
         | 
| 1637 | 
            -
              VersionChanged: '1. | 
| 1638 | 
            +
              VersionChanged: '1.69'
         | 
| 1638 1639 |  | 
| 1639 1640 | 
             
            Lint/BooleanSymbol:
         | 
| 1640 1641 | 
             
              Description: 'Check for `:true` and `:false` symbols.'
         | 
| @@ -1956,6 +1957,11 @@ Lint/HashCompareByIdentity: | |
| 1956 1957 | 
             
              Safe: false
         | 
| 1957 1958 | 
             
              VersionAdded: '0.93'
         | 
| 1958 1959 |  | 
| 1960 | 
            +
            Lint/HashNewWithKeywordArgumentsAsDefault:
         | 
| 1961 | 
            +
              Description: 'Checks for the deprecated use of keyword arguments for hash default in `Hash.new`.'
         | 
| 1962 | 
            +
              Enabled: pending
         | 
| 1963 | 
            +
              VersionAdded: '1.69'
         | 
| 1964 | 
            +
             | 
| 1959 1965 | 
             
            Lint/HeredocMethodCallPosition:
         | 
| 1960 1966 | 
             
              Description: >-
         | 
| 1961 1967 | 
             
                             Checks for the ordering of a method call where
         | 
| @@ -2146,6 +2152,11 @@ Lint/NumberedParameterAssignment: | |
| 2146 2152 | 
             
              Enabled: pending
         | 
| 2147 2153 | 
             
              VersionAdded: '1.9'
         | 
| 2148 2154 |  | 
| 2155 | 
            +
            Lint/NumericOperationWithConstantResult:
         | 
| 2156 | 
            +
              Description: 'Checks for numeric operations with constant results.'
         | 
| 2157 | 
            +
              Enabled: pending
         | 
| 2158 | 
            +
              VersionAdded: '1.69'
         | 
| 2159 | 
            +
             | 
| 2149 2160 | 
             
            Lint/OrAssignmentToConstant:
         | 
| 2150 2161 | 
             
              Description: 'Checks unintended or-assignment to constant.'
         | 
| 2151 2162 | 
             
              Enabled: pending
         | 
| @@ -2377,7 +2388,6 @@ Lint/ShadowedArgument: | |
| 2377 2388 | 
             
              VersionAdded: '0.52'
         | 
| 2378 2389 | 
             
              IgnoreImplicitReferences: false
         | 
| 2379 2390 |  | 
| 2380 | 
            -
             | 
| 2381 2391 | 
             
            Lint/ShadowedException:
         | 
| 2382 2392 | 
             
              Description: >-
         | 
| 2383 2393 | 
             
                              Avoid rescuing a higher level exception
         | 
| @@ -2521,10 +2531,12 @@ Lint/UnusedMethodArgument: | |
| 2521 2531 | 
             
              Enabled: true
         | 
| 2522 2532 | 
             
              AutoCorrect: contextual
         | 
| 2523 2533 | 
             
              VersionAdded: '0.21'
         | 
| 2524 | 
            -
              VersionChanged: '1. | 
| 2534 | 
            +
              VersionChanged: '1.69'
         | 
| 2525 2535 | 
             
              AllowUnusedKeywordArguments: false
         | 
| 2526 2536 | 
             
              IgnoreEmptyMethods: true
         | 
| 2527 2537 | 
             
              IgnoreNotImplementedMethods: true
         | 
| 2538 | 
            +
              NotImplementedExceptions:
         | 
| 2539 | 
            +
                - NotImplementedError
         | 
| 2528 2540 |  | 
| 2529 2541 | 
             
            Lint/UriEscapeUnescape:
         | 
| 2530 2542 | 
             
              Description: >-
         | 
| @@ -2559,6 +2571,11 @@ Lint/UselessAssignment: | |
| 2559 2571 | 
             
              VersionAdded: '0.11'
         | 
| 2560 2572 | 
             
              VersionChanged: '1.66'
         | 
| 2561 2573 |  | 
| 2574 | 
            +
            Lint/UselessDefined:
         | 
| 2575 | 
            +
              Description: 'Checks for calls to `defined?` with strings and symbols. The result of such a call will always be truthy.'
         | 
| 2576 | 
            +
              Enabled: pending
         | 
| 2577 | 
            +
              VersionAdded: '1.69'
         | 
| 2578 | 
            +
             | 
| 2562 2579 | 
             
            Lint/UselessElseWithoutRescue:
         | 
| 2563 2580 | 
             
              Description: 'Checks for useless `else` in `begin..end` without `rescue`.'
         | 
| 2564 2581 | 
             
              Enabled: true
         | 
| @@ -3698,6 +3715,12 @@ Style/DefWithParentheses: | |
| 3698 3715 | 
             
              VersionAdded: '0.9'
         | 
| 3699 3716 | 
             
              VersionChanged: '0.12'
         | 
| 3700 3717 |  | 
| 3718 | 
            +
            Style/DigChain:
         | 
| 3719 | 
            +
              Description: 'Use `dig` with multiple parameters instead of chaining multiple calls.'
         | 
| 3720 | 
            +
              Enabled: pending
         | 
| 3721 | 
            +
              Safe: false
         | 
| 3722 | 
            +
              VersionAdded: '1.69'
         | 
| 3723 | 
            +
             | 
| 3701 3724 | 
             
            Style/Dir:
         | 
| 3702 3725 | 
             
              Description: >-
         | 
| 3703 3726 | 
             
                             Use the `__dir__` method to retrieve the canonicalized
         | 
| @@ -3924,12 +3947,24 @@ Style/FileEmpty: | |
| 3924 3947 | 
             
              Safe: false
         | 
| 3925 3948 | 
             
              VersionAdded: '1.48'
         | 
| 3926 3949 |  | 
| 3950 | 
            +
            Style/FileNull:
         | 
| 3951 | 
            +
              Description: 'Use `File::NULL` instead of hardcoding "dev/null".'
         | 
| 3952 | 
            +
              Enabled: pending
         | 
| 3953 | 
            +
              SafeAutoCorrect: false
         | 
| 3954 | 
            +
              VersionAdded: '1.69'
         | 
| 3955 | 
            +
             | 
| 3927 3956 | 
             
            Style/FileRead:
         | 
| 3928 3957 | 
             
              Description: 'Favor `File.(bin)read` convenience methods.'
         | 
| 3929 3958 | 
             
              StyleGuide: '#file-read'
         | 
| 3930 3959 | 
             
              Enabled: pending
         | 
| 3931 3960 | 
             
              VersionAdded: '1.24'
         | 
| 3932 3961 |  | 
| 3962 | 
            +
            Style/FileTouch:
         | 
| 3963 | 
            +
              Description: 'Favor `FileUtils.touch` for touching files.'
         | 
| 3964 | 
            +
              Enabled: pending
         | 
| 3965 | 
            +
              VersionAdded: '1.69'
         | 
| 3966 | 
            +
              SafeAutoCorrect: false
         | 
| 3967 | 
            +
             | 
| 3933 3968 | 
             
            Style/FileWrite:
         | 
| 3934 3969 | 
             
              Description: 'Favor `File.(bin)write` convenience methods.'
         | 
| 3935 3970 | 
             
              StyleGuide: '#file-write'
         | 
    
        data/lib/rubocop/cop/base.rb
    CHANGED
    
    | @@ -60,7 +60,7 @@ module RuboCop | |
| 60 60 | 
             
                    []
         | 
| 61 61 | 
             
                  end
         | 
| 62 62 |  | 
| 63 | 
            -
                  # Returns  | 
| 63 | 
            +
                  # Returns a url to view this cops documentation online.
         | 
| 64 64 | 
             
                  # Requires 'DocumentationBaseURL' to be set for your department.
         | 
| 65 65 | 
             
                  # Will follow the convention of RuboCops own documentation structure,
         | 
| 66 66 | 
             
                  # overwrite this method to accommodate your custom layout.
         | 
| @@ -27,7 +27,6 @@ module RuboCop | |
| 27 27 | 
             
                  #   Project contains gems.rb and gems.locked files
         | 
| 28 28 | 
             
                  class GemFilename < Base
         | 
| 29 29 | 
             
                    include ConfigurableEnforcedStyle
         | 
| 30 | 
            -
                    include RangeHelp
         | 
| 31 30 |  | 
| 32 31 | 
             
                    MSG_GEMFILE_REQUIRED = '`gems.rb` file was found but `Gemfile` is required ' \
         | 
| 33 32 | 
             
                                           '(file path: %<file_path>s).'
         | 
| @@ -39,7 +39,7 @@ module RuboCop | |
| 39 39 | 
             
                  def requires_parentheses?
         | 
| 40 40 | 
             
                    return true if collection_node.send_type? && collection_node.operator_method?
         | 
| 41 41 |  | 
| 42 | 
            -
                    collection_node.range_type? || collection_node. | 
| 42 | 
            +
                    collection_node.range_type? || collection_node.operator_keyword?
         | 
| 43 43 | 
             
                  end
         | 
| 44 44 |  | 
| 45 45 | 
             
                  def end_range
         | 
| @@ -53,8 +53,6 @@ module RuboCop | |
| 53 53 | 
             
                  #     spec.required_ruby_version = '~> 2.5'
         | 
| 54 54 | 
             
                  #   end
         | 
| 55 55 | 
             
                  class RequiredRubyVersion < Base
         | 
| 56 | 
            -
                    include RangeHelp
         | 
| 57 | 
            -
             | 
| 58 56 | 
             
                    RESTRICT_ON_SEND = %i[required_ruby_version=].freeze
         | 
| 59 57 | 
             
                    NOT_EQUAL_MSG = '`required_ruby_version` and `TargetRubyVersion` ' \
         | 
| 60 58 | 
             
                                    '(%<target_ruby_version>s, which may be specified in ' \
         | 
| @@ -71,11 +71,17 @@ module RuboCop | |
| 71 71 | 
             
                              (send nil? :bad_method ...)
         | 
| 72 72 | 
             
                            PATTERN
         | 
| 73 73 |  | 
| 74 | 
            +
                            # Called on every `send` node (method call) while walking the AST.
         | 
| 75 | 
            +
                            # TODO: remove this method if inspecting `send` nodes is unneeded for your cop.
         | 
| 76 | 
            +
                            # By default, this is aliased to `on_csend` as well to handle method calls
         | 
| 77 | 
            +
                            # with safe navigation, remove the alias if this is unnecessary.
         | 
| 78 | 
            +
                            # If kept, ensure your tests cover safe navigation as well!
         | 
| 74 79 | 
             
                            def on_send(node)
         | 
| 75 80 | 
             
                              return unless bad_method?(node)
         | 
| 76 81 |  | 
| 77 82 | 
             
                              add_offense(node)
         | 
| 78 83 | 
             
                            end
         | 
| 84 | 
            +
                            alias on_csend on_send
         | 
| 79 85 | 
             
                          end
         | 
| 80 86 | 
             
                        end
         | 
| 81 87 | 
             
                      end
         | 
| @@ -19,6 +19,7 @@ module RuboCop | |
| 19 19 | 
             
                    extend AutoCorrector
         | 
| 20 20 |  | 
| 21 21 | 
             
                    MSG = 'Use `%<preferred>s`.'
         | 
| 22 | 
            +
                    RESTRICT_ON_SEND = [:==].freeze
         | 
| 22 23 |  | 
| 23 24 | 
             
                    # @!method line_send(node)
         | 
| 24 25 | 
             
                    def_node_matcher :line_send, <<~PATTERN
         | 
| @@ -36,10 +37,8 @@ module RuboCop | |
| 36 37 | 
             
                    def on_send(node)
         | 
| 37 38 | 
             
                      return unless location_line_equality_comparison?(node)
         | 
| 38 39 |  | 
| 39 | 
            -
                       | 
| 40 | 
            -
             | 
| 41 | 
            -
                      lhs_receiver = extract_receiver(lhs)
         | 
| 42 | 
            -
                      rhs_receiver = extract_receiver(rhs)
         | 
| 40 | 
            +
                      lhs_receiver = extract_receiver(node.receiver)
         | 
| 41 | 
            +
                      rhs_receiver = extract_receiver(node.first_argument)
         | 
| 43 42 | 
             
                      preferred = "same_line?(#{lhs_receiver}, #{rhs_receiver})"
         | 
| 44 43 |  | 
| 45 44 | 
             
                      add_offense(node, message: format(MSG, preferred: preferred)) do |corrector|
         | 
| @@ -3,7 +3,7 @@ | |
| 3 3 | 
             
            module RuboCop
         | 
| 4 4 | 
             
              module Cop
         | 
| 5 5 | 
             
                module InternalAffairs
         | 
| 6 | 
            -
                  # Checks for missing `numblock handlers. The blocks with numbered
         | 
| 6 | 
            +
                  # Checks for missing `numblock` handlers. The blocks with numbered
         | 
| 7 7 | 
             
                  # arguments introduced in Ruby 2.7 are parsed with a node type of
         | 
| 8 8 | 
             
                  # `numblock` instead of block. Cops that define `block` handlers
         | 
| 9 9 | 
             
                  # need to define `numblock` handlers or disable this cope for them.
         | 
| @@ -0,0 +1,46 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module RuboCop
         | 
| 4 | 
            +
              module Cop
         | 
| 5 | 
            +
                module InternalAffairs
         | 
| 6 | 
            +
                  # Enforces the use of `node.operator_keyword?` instead of `node.and_type? || node.or_type?`.
         | 
| 7 | 
            +
                  #
         | 
| 8 | 
            +
                  # @example
         | 
| 9 | 
            +
                  #   # bad
         | 
| 10 | 
            +
                  #   node.and_type? || node.or_type?
         | 
| 11 | 
            +
                  #   node.or_type? || node.and_type?
         | 
| 12 | 
            +
                  #
         | 
| 13 | 
            +
                  #   # good
         | 
| 14 | 
            +
                  #   node.operator_keyword?
         | 
| 15 | 
            +
                  #
         | 
| 16 | 
            +
                  class OperatorKeyword < Base
         | 
| 17 | 
            +
                    extend AutoCorrector
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                    MSG = 'Use `%<prefer>s`.'
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                    # @!method and_or_type(node)
         | 
| 22 | 
            +
                    def_node_matcher :and_or_type, <<~PATTERN
         | 
| 23 | 
            +
                      {
         | 
| 24 | 
            +
                        (or $(send _node :and_type?) $(send _node :or_type?))
         | 
| 25 | 
            +
                        (or $(send _node :or_type?) $(send _node :and_type?))
         | 
| 26 | 
            +
                        (or
         | 
| 27 | 
            +
                          (or _ $(send _node :and_type?)) $(send _node :or_type?))
         | 
| 28 | 
            +
                        (or
         | 
| 29 | 
            +
                          (or _ $(send _node :or_type?)) $(send _node :and_type?))
         | 
| 30 | 
            +
                      }
         | 
| 31 | 
            +
                    PATTERN
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                    def on_or(node)
         | 
| 34 | 
            +
                      return unless (lhs, rhs = and_or_type(node))
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                      offense = lhs.receiver.source_range.join(rhs.source_range.end)
         | 
| 37 | 
            +
                      prefer = "#{lhs.receiver.source}.operator_keyword?"
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                      add_offense(offense, message: format(MSG, prefer: prefer)) do |corrector|
         | 
| 40 | 
            +
                        corrector.replace(offense, prefer)
         | 
| 41 | 
            +
                      end
         | 
| 42 | 
            +
                    end
         | 
| 43 | 
            +
                  end
         | 
| 44 | 
            +
                end
         | 
| 45 | 
            +
              end
         | 
| 46 | 
            +
            end
         | 
| @@ -17,6 +17,7 @@ require_relative 'internal_affairs/node_matcher_directive' | |
| 17 17 | 
             
            require_relative 'internal_affairs/node_type_predicate'
         | 
| 18 18 | 
             
            require_relative 'internal_affairs/numblock_handler'
         | 
| 19 19 | 
             
            require_relative 'internal_affairs/offense_location_keyword'
         | 
| 20 | 
            +
            require_relative 'internal_affairs/operator_keyword'
         | 
| 20 21 | 
             
            require_relative 'internal_affairs/processed_source_buffer_name'
         | 
| 21 22 | 
             
            require_relative 'internal_affairs/redundant_context_config_parameter'
         | 
| 22 23 | 
             
            require_relative 'internal_affairs/redundant_described_class_as_subject'
         | 
| @@ -3,8 +3,7 @@ | |
| 3 3 | 
             
            module RuboCop
         | 
| 4 4 | 
             
              module Cop
         | 
| 5 5 | 
             
                module Layout
         | 
| 6 | 
            -
                  #  | 
| 7 | 
            -
                  # definition are aligned.
         | 
| 6 | 
            +
                  # Check that the arguments on a multi-line method definition are aligned.
         | 
| 8 7 | 
             
                  #
         | 
| 9 8 | 
             
                  # @example EnforcedStyle: with_first_argument (default)
         | 
| 10 9 | 
             
                  #   # good
         | 
| @@ -127,7 +127,6 @@ module RuboCop | |
| 127 127 | 
             
                                         start_loc,
         | 
| 128 128 | 
             
                                         end_loc,
         | 
| 129 129 | 
             
                                         do_source_line_column)
         | 
| 130 | 
            -
             | 
| 131 130 | 
             
                      error_source_line_column = if style == :start_of_block
         | 
| 132 131 | 
             
                                                   do_source_line_column
         | 
| 133 132 | 
             
                                                 else
         | 
| @@ -189,7 +188,7 @@ module RuboCop | |
| 189 188 | 
             
                    # In offense message, we want to show the assignment LHS rather than
         | 
| 190 189 | 
             
                    # the entire assignment.
         | 
| 191 190 | 
             
                    def find_lhs_node(node)
         | 
| 192 | 
            -
                      node | 
| 191 | 
            +
                      node = node.lhs while node.op_asgn_type? || node.masgn_type?
         | 
| 193 192 | 
             
                      node
         | 
| 194 193 | 
             
                    end
         | 
| 195 194 |  | 
| @@ -200,7 +200,7 @@ module RuboCop | |
| 200 200 | 
             
                      parent = node.parent
         | 
| 201 201 | 
             
                      return false unless parent
         | 
| 202 202 |  | 
| 203 | 
            -
                      parent.begin_type? &&  | 
| 203 | 
            +
                      parent.begin_type? && same_line?(node, node.right_sibling)
         | 
| 204 204 | 
             
                    end
         | 
| 205 205 |  | 
| 206 206 | 
             
                    # SimpleCov excludes code from the coverage report by wrapping it in `# :nocov:`:
         | 
| @@ -84,9 +84,8 @@ module RuboCop | |
| 84 84 |  | 
| 85 85 | 
             
                    alias on_numblock on_block
         | 
| 86 86 |  | 
| 87 | 
            -
                    def on_send(node) | 
| 88 | 
            -
                      return unless node.bare_access_modifier? &&
         | 
| 89 | 
            -
                                    !(node.parent&.block_type? || node.parent&.numblock_type?)
         | 
| 87 | 
            +
                    def on_send(node)
         | 
| 88 | 
            +
                      return unless node.bare_access_modifier? && !node.block_literal?
         | 
| 90 89 | 
             
                      return if expected_empty_lines?(node)
         | 
| 91 90 |  | 
| 92 91 | 
             
                      message = message(node)
         | 
| @@ -72,8 +72,7 @@ module RuboCop | |
| 72 72 | 
             
                    alias on_numblock on_def
         | 
| 73 73 |  | 
| 74 74 | 
             
                    def on_kwbegin(node)
         | 
| 75 | 
            -
                       | 
| 76 | 
            -
                      check_body(body, node.loc.line)
         | 
| 75 | 
            +
                      check_body(node.children.first, node.loc.line)
         | 
| 77 76 | 
             
                    end
         | 
| 78 77 |  | 
| 79 78 | 
             
                    private
         | 
| @@ -128,10 +127,10 @@ module RuboCop | |
| 128 127 | 
             
                    end
         | 
| 129 128 |  | 
| 130 129 | 
             
                    def keyword_locations_in_ensure(node)
         | 
| 131 | 
            -
                       | 
| 130 | 
            +
                      rescue_body_without_ensure = node.children.first
         | 
| 132 131 | 
             
                      [
         | 
| 133 132 | 
             
                        node.loc.keyword,
         | 
| 134 | 
            -
                        *keyword_locations( | 
| 133 | 
            +
                        *keyword_locations(rescue_body_without_ensure)
         | 
| 135 134 | 
             
                      ]
         | 
| 136 135 | 
             
                    end
         | 
| 137 136 | 
             
                  end
         | 
| @@ -58,16 +58,17 @@ module RuboCop | |
| 58 58 | 
             
                    PATTERN
         | 
| 59 59 |  | 
| 60 60 | 
             
                    def on_rescue(node)
         | 
| 61 | 
            -
                       | 
| 62 | 
            -
                      check_indentation(node.loc.else, else_node)
         | 
| 61 | 
            +
                      check_indentation(node.loc.else, node.else_branch)
         | 
| 63 62 | 
             
                    end
         | 
| 64 63 |  | 
| 65 | 
            -
                    def  | 
| 64 | 
            +
                    def on_resbody(node)
         | 
| 66 65 | 
             
                      check_indentation(node.loc.keyword, node.body)
         | 
| 67 66 | 
             
                    end
         | 
| 67 | 
            +
                    alias on_for on_resbody
         | 
| 68 68 |  | 
| 69 | 
            -
                     | 
| 70 | 
            -
             | 
| 69 | 
            +
                    def on_ensure(node)
         | 
| 70 | 
            +
                      check_indentation(node.loc.keyword, node.branch)
         | 
| 71 | 
            +
                    end
         | 
| 71 72 |  | 
| 72 73 | 
             
                    def on_kwbegin(node)
         | 
| 73 74 | 
             
                      # Check indentation against end keyword but only if it's first on its
         | 
| @@ -325,8 +326,7 @@ module RuboCop | |
| 325 326 | 
             
                      if body_node.rescue_type?
         | 
| 326 327 | 
             
                        check_rescue?(body_node)
         | 
| 327 328 | 
             
                      elsif body_node.ensure_type?
         | 
| 328 | 
            -
                        block_body, = *body_node
         | 
| 329 | 
            -
             | 
| 329 | 
            +
                        block_body, = *body_node # rubocop:disable InternalAffairs/NodeDestructuring
         | 
| 330 330 | 
             
                        if block_body&.rescue_type?
         | 
| 331 331 | 
             
                          check_rescue?(block_body)
         | 
| 332 332 | 
             
                        else
         | 
| @@ -96,6 +96,7 @@ module RuboCop | |
| 96 96 | 
             
                      processed_source.comments.each do |comment|
         | 
| 97 97 | 
             
                        next unless /\A(?!#\+\+|#--)(#+[^#\s=])/.match?(comment.text)
         | 
| 98 98 | 
             
                        next if comment.loc.line == 1 && allowed_on_first_line?(comment)
         | 
| 99 | 
            +
                        next if shebang_continuation?(comment)
         | 
| 99 100 | 
             
                        next if doxygen_comment_style?(comment)
         | 
| 100 101 | 
             
                        next if gemfile_ruby_comment?(comment)
         | 
| 101 102 | 
             
                        next if rbs_inline_annotation?(comment)
         | 
| @@ -123,6 +124,20 @@ module RuboCop | |
| 123 124 | 
             
                      comment.text.start_with?('#!')
         | 
| 124 125 | 
             
                    end
         | 
| 125 126 |  | 
| 127 | 
            +
                    def shebang_continuation?(comment)
         | 
| 128 | 
            +
                      return false unless shebang?(comment)
         | 
| 129 | 
            +
                      return true if comment.loc.line == 1
         | 
| 130 | 
            +
             | 
| 131 | 
            +
                      previous_line_comment = processed_source.comment_at_line(comment.loc.line - 1)
         | 
| 132 | 
            +
                      return false unless previous_line_comment
         | 
| 133 | 
            +
             | 
| 134 | 
            +
                      # If the comment is a shebang but not on the first line, check if the previous
         | 
| 135 | 
            +
                      # line has a shebang comment that wasn't marked as an offense; if so, this comment
         | 
| 136 | 
            +
                      # continues the shebang and is acceptable.
         | 
| 137 | 
            +
                      shebang?(previous_line_comment) &&
         | 
| 138 | 
            +
                        !current_offense_locations.include?(previous_line_comment.source_range)
         | 
| 139 | 
            +
                    end
         | 
| 140 | 
            +
             | 
| 126 141 | 
             
                    def rackup_options?(comment)
         | 
| 127 142 | 
             
                      comment.text.start_with?('#\\')
         | 
| 128 143 | 
             
                    end
         |