rubocop 1.45.1 → 1.50.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/config/default.yml +46 -15
- data/lib/rubocop/cli/command/auto_generate_config.rb +7 -0
- data/lib/rubocop/cli/command/execute_runner.rb +7 -2
- data/lib/rubocop/cli.rb +6 -6
- data/lib/rubocop/comment_config.rb +19 -0
- data/lib/rubocop/config.rb +3 -3
- data/lib/rubocop/config_loader.rb +8 -8
- data/lib/rubocop/cop/autocorrect_logic.rb +29 -13
- data/lib/rubocop/cop/base.rb +1 -1
- data/lib/rubocop/cop/bundler/gem_comment.rb +1 -1
- data/lib/rubocop/cop/cop.rb +2 -2
- data/lib/rubocop/cop/corrector.rb +1 -1
- data/lib/rubocop/cop/correctors/alignment_corrector.rb +2 -2
- data/lib/rubocop/cop/correctors/each_to_for_corrector.rb +3 -3
- data/lib/rubocop/cop/correctors/for_to_each_corrector.rb +3 -3
- data/lib/rubocop/cop/correctors/line_break_corrector.rb +1 -1
- data/lib/rubocop/cop/correctors/multiline_literal_brace_corrector.rb +2 -2
- data/lib/rubocop/cop/correctors/ordered_gem_corrector.rb +1 -1
- data/lib/rubocop/cop/correctors/parentheses_corrector.rb +1 -1
- data/lib/rubocop/cop/correctors/percent_literal_corrector.rb +2 -2
- data/lib/rubocop/cop/gemspec/dependency_version.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/cop_description.rb +5 -5
- data/lib/rubocop/cop/internal_affairs/example_heredoc_delimiter.rb +3 -3
- data/lib/rubocop/cop/internal_affairs/inherit_deprecated_cop_class.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/location_expression.rb +37 -0
- data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/node_type_predicate.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/processed_source_buffer_name.rb +42 -0
- data/lib/rubocop/cop/internal_affairs/redundant_location_argument.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/redundant_message_argument.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/redundant_source_range.rb +66 -0
- data/lib/rubocop/cop/internal_affairs.rb +3 -0
- data/lib/rubocop/cop/layout/block_end_newline.rb +7 -21
- data/lib/rubocop/cop/layout/class_structure.rb +6 -3
- data/lib/rubocop/cop/layout/closing_heredoc_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/empty_comment.rb +3 -3
- data/lib/rubocop/cop/layout/empty_line_between_defs.rb +1 -1
- data/lib/rubocop/cop/layout/empty_lines.rb +1 -1
- data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +2 -0
- data/lib/rubocop/cop/layout/end_alignment.rb +9 -1
- data/lib/rubocop/cop/layout/extra_spacing.rb +6 -1
- data/lib/rubocop/cop/layout/first_argument_indentation.rb +7 -2
- data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +8 -2
- data/lib/rubocop/cop/layout/heredoc_indentation.rb +2 -2
- data/lib/rubocop/cop/layout/initial_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/leading_comment_space.rb +1 -1
- data/lib/rubocop/cop/layout/line_continuation_leading_space.rb +1 -3
- data/lib/rubocop/cop/layout/line_continuation_spacing.rb +11 -7
- data/lib/rubocop/cop/layout/redundant_line_break.rb +6 -7
- data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +2 -2
- data/lib/rubocop/cop/layout/space_before_first_arg.rb +1 -1
- data/lib/rubocop/cop/layout/space_in_lambda_literal.rb +2 -2
- data/lib/rubocop/cop/layout/space_inside_block_braces.rb +1 -1
- data/lib/rubocop/cop/layout/space_inside_parens.rb +2 -2
- data/lib/rubocop/cop/layout/space_inside_percent_literal_delimiters.rb +1 -1
- data/lib/rubocop/cop/layout/trailing_whitespace.rb +1 -1
- data/lib/rubocop/cop/lint/constant_resolution.rb +1 -1
- data/lib/rubocop/cop/lint/debugger.rb +3 -0
- data/lib/rubocop/cop/lint/deprecated_class_methods.rb +4 -4
- data/lib/rubocop/cop/lint/deprecated_open_ssl_constant.rb +1 -1
- data/lib/rubocop/cop/lint/duplicate_match_pattern.rb +122 -0
- data/lib/rubocop/cop/lint/duplicate_methods.rb +2 -2
- data/lib/rubocop/cop/lint/duplicate_regexp_character_class_element.rb +1 -3
- data/lib/rubocop/cop/lint/else_layout.rb +1 -1
- data/lib/rubocop/cop/lint/empty_block.rb +1 -1
- data/lib/rubocop/cop/lint/empty_conditional_body.rb +4 -2
- data/lib/rubocop/cop/lint/empty_interpolation.rb +1 -1
- data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +1 -1
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +46 -4
- data/lib/rubocop/cop/lint/missing_super.rb +31 -2
- data/lib/rubocop/cop/lint/nested_method_definition.rb +3 -11
- data/lib/rubocop/cop/lint/or_assignment_to_constant.rb +2 -0
- data/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +6 -10
- data/lib/rubocop/cop/lint/percent_string_array.rb +1 -1
- data/lib/rubocop/cop/lint/percent_symbol_array.rb +1 -1
- data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +11 -5
- data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +5 -5
- data/lib/rubocop/cop/lint/redundant_require_statement.rb +1 -1
- data/lib/rubocop/cop/lint/redundant_splat_expansion.rb +1 -1
- data/lib/rubocop/cop/lint/redundant_string_coercion.rb +35 -15
- data/lib/rubocop/cop/lint/redundant_with_index.rb +1 -1
- data/lib/rubocop/cop/lint/redundant_with_object.rb +1 -1
- data/lib/rubocop/cop/lint/refinement_import_methods.rb +2 -1
- data/lib/rubocop/cop/lint/rescue_type.rb +3 -3
- data/lib/rubocop/cop/lint/safe_navigation_consistency.rb +1 -1
- data/lib/rubocop/cop/lint/script_permission.rb +1 -1
- data/lib/rubocop/cop/lint/shadowed_exception.rb +1 -1
- data/lib/rubocop/cop/lint/syntax.rb +4 -0
- data/lib/rubocop/cop/lint/to_enum_arguments.rb +13 -3
- data/lib/rubocop/cop/lint/unreachable_loop.rb +3 -3
- data/lib/rubocop/cop/lint/useless_access_modifier.rb +10 -10
- data/lib/rubocop/cop/lint/useless_method_definition.rb +10 -2
- data/lib/rubocop/cop/lint/useless_rescue.rb +6 -2
- data/lib/rubocop/cop/lint/useless_times.rb +1 -1
- data/lib/rubocop/cop/lint/void.rb +7 -3
- data/lib/rubocop/cop/metrics/block_nesting.rb +1 -1
- data/lib/rubocop/cop/metrics/class_length.rb +1 -0
- data/lib/rubocop/cop/metrics/collection_literal_length.rb +76 -0
- data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +3 -3
- data/lib/rubocop/cop/migration/department_name.rb +1 -1
- data/lib/rubocop/cop/mixin/annotation_comment.rb +1 -1
- data/lib/rubocop/cop/mixin/code_length.rb +1 -1
- data/lib/rubocop/cop/mixin/comments_help.rb +3 -3
- data/lib/rubocop/cop/mixin/documentation_comment.rb +1 -1
- data/lib/rubocop/cop/mixin/hash_alignment_styles.rb +1 -1
- data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +10 -5
- data/lib/rubocop/cop/mixin/hash_transform_method.rb +3 -3
- data/lib/rubocop/cop/mixin/min_branches_count.rb +40 -0
- data/lib/rubocop/cop/mixin/multiline_element_line_breaks.rb +0 -3
- data/lib/rubocop/cop/mixin/ordered_gem_node.rb +1 -1
- data/lib/rubocop/cop/mixin/range_help.rb +1 -6
- data/lib/rubocop/cop/mixin/statement_modifier.rb +3 -3
- data/lib/rubocop/cop/mixin/trailing_comma.rb +1 -1
- data/lib/rubocop/cop/naming/ascii_identifiers.rb +1 -1
- data/lib/rubocop/cop/naming/heredoc_delimiter_case.rb +1 -1
- data/lib/rubocop/cop/naming/inclusive_language.rb +23 -4
- data/lib/rubocop/cop/naming/method_name.rb +3 -3
- data/lib/rubocop/cop/naming/predicate_name.rb +1 -1
- data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +1 -1
- data/lib/rubocop/cop/registry.rb +3 -1
- data/lib/rubocop/cop/style/accessor_grouping.rb +39 -17
- data/lib/rubocop/cop/style/arguments_forwarding.rb +3 -3
- data/lib/rubocop/cop/style/array_intersect.rb +1 -1
- data/lib/rubocop/cop/style/ascii_comments.rb +1 -1
- data/lib/rubocop/cop/style/bisected_attr_accessor.rb +1 -1
- data/lib/rubocop/cop/style/block_comments.rb +1 -1
- data/lib/rubocop/cop/style/block_delimiters.rb +11 -2
- data/lib/rubocop/cop/style/case_like_if.rb +20 -3
- data/lib/rubocop/cop/style/class_and_module_children.rb +1 -1
- data/lib/rubocop/cop/style/class_equality_comparison.rb +42 -9
- data/lib/rubocop/cop/style/collection_compact.rb +1 -1
- data/lib/rubocop/cop/style/comment_annotation.rb +1 -1
- data/lib/rubocop/cop/style/commented_keyword.rb +2 -2
- data/lib/rubocop/cop/style/concat_array_literals.rb +10 -2
- data/lib/rubocop/cop/style/conditional_assignment.rb +6 -6
- data/lib/rubocop/cop/style/copyright.rb +1 -1
- data/lib/rubocop/cop/style/data_inheritance.rb +75 -0
- data/lib/rubocop/cop/style/dir_empty.rb +60 -0
- data/lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb +2 -2
- data/lib/rubocop/cop/style/document_dynamic_eval_definition.rb +2 -2
- data/lib/rubocop/cop/style/documentation.rb +10 -4
- data/lib/rubocop/cop/style/documentation_method.rb +4 -4
- data/lib/rubocop/cop/style/double_negation.rb +2 -2
- data/lib/rubocop/cop/style/each_with_object.rb +1 -1
- data/lib/rubocop/cop/style/empty_block_parameter.rb +1 -1
- data/lib/rubocop/cop/style/empty_lambda_parameter.rb +1 -1
- data/lib/rubocop/cop/style/eval_with_location.rb +4 -4
- data/lib/rubocop/cop/style/explicit_block_argument.rb +1 -1
- data/lib/rubocop/cop/style/file_empty.rb +71 -0
- data/lib/rubocop/cop/style/file_read.rb +1 -1
- data/lib/rubocop/cop/style/file_write.rb +1 -1
- data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +1 -1
- data/lib/rubocop/cop/style/guard_clause.rb +1 -1
- data/lib/rubocop/cop/style/hash_except.rb +4 -4
- data/lib/rubocop/cop/style/hash_like_case.rb +3 -9
- data/lib/rubocop/cop/style/hash_syntax.rb +5 -2
- data/lib/rubocop/cop/style/if_unless_modifier.rb +108 -15
- data/lib/rubocop/cop/style/if_with_boolean_literal_branches.rb +2 -0
- data/lib/rubocop/cop/style/inverse_methods.rb +5 -5
- data/lib/rubocop/cop/style/map_compact_with_conditional_block.rb +2 -2
- data/lib/rubocop/cop/style/map_to_hash.rb +4 -1
- data/lib/rubocop/cop/style/map_to_set.rb +4 -1
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +3 -7
- data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +44 -37
- data/lib/rubocop/cop/style/min_max.rb +3 -3
- data/lib/rubocop/cop/style/mixin_grouping.rb +4 -4
- data/lib/rubocop/cop/style/multiline_method_signature.rb +7 -4
- data/lib/rubocop/cop/style/multiline_ternary_operator.rb +1 -1
- data/lib/rubocop/cop/style/negated_if_else_condition.rb +12 -7
- data/lib/rubocop/cop/style/nil_lambda.rb +2 -2
- data/lib/rubocop/cop/style/parallel_assignment.rb +26 -18
- data/lib/rubocop/cop/style/percent_literal_delimiters.rb +2 -3
- data/lib/rubocop/cop/style/percent_q_literals.rb +1 -1
- data/lib/rubocop/cop/style/redundant_condition.rb +2 -2
- data/lib/rubocop/cop/style/redundant_double_splat_hash_braces.rb +2 -2
- data/lib/rubocop/cop/style/redundant_interpolation.rb +2 -2
- data/lib/rubocop/cop/style/redundant_line_continuation.rb +179 -0
- data/lib/rubocop/cop/style/redundant_parentheses.rb +2 -2
- data/lib/rubocop/cop/style/redundant_percent_q.rb +1 -1
- data/lib/rubocop/cop/style/redundant_regexp_character_class.rb +7 -8
- data/lib/rubocop/cop/style/redundant_regexp_escape.rb +11 -4
- data/lib/rubocop/cop/style/redundant_sort.rb +3 -3
- data/lib/rubocop/cop/style/redundant_string_escape.rb +3 -4
- data/lib/rubocop/cop/style/require_order.rb +1 -3
- data/lib/rubocop/cop/style/rescue_standard_error.rb +2 -2
- data/lib/rubocop/cop/style/safe_navigation.rb +2 -2
- data/lib/rubocop/cop/style/slicing_with_range.rb +1 -1
- data/lib/rubocop/cop/style/sole_nested_conditional.rb +3 -3
- data/lib/rubocop/cop/style/stderr_puts.rb +1 -1
- data/lib/rubocop/cop/style/struct_inheritance.rb +1 -1
- data/lib/rubocop/cop/style/trailing_body_on_class.rb +1 -0
- data/lib/rubocop/cop/style/trailing_underscore_variable.rb +1 -1
- data/lib/rubocop/cop/style/trivial_accessors.rb +1 -1
- data/lib/rubocop/cop/style/unless_logical_operators.rb +1 -0
- data/lib/rubocop/cop/style/unpack_first.rb +3 -3
- data/lib/rubocop/cop/style/word_array.rb +17 -5
- data/lib/rubocop/cop/style/yoda_condition.rb +1 -1
- data/lib/rubocop/cop/style/zero_length_predicate.rb +9 -5
- data/lib/rubocop/cop/team.rb +11 -8
- data/lib/rubocop/cop/util.rb +13 -4
- data/lib/rubocop/cop/variable_force/variable.rb +5 -3
- data/lib/rubocop/cops_documentation_generator.rb +10 -3
- data/lib/rubocop/directive_comment.rb +3 -3
- data/lib/rubocop/ext/comment.rb +18 -0
- data/lib/rubocop/ext/regexp_node.rb +1 -1
- data/lib/rubocop/ext/regexp_parser.rb +1 -1
- data/lib/rubocop/formatter/junit_formatter.rb +4 -1
- data/lib/rubocop/formatter/simple_text_formatter.rb +1 -1
- data/lib/rubocop/options.rb +4 -1
- data/lib/rubocop/result_cache.rb +1 -1
- data/lib/rubocop/rspec/cop_helper.rb +1 -1
- data/lib/rubocop/rspec/shared_contexts.rb +4 -0
- data/lib/rubocop/rspec/support.rb +1 -0
- data/lib/rubocop/server/cache.rb +1 -1
- data/lib/rubocop/server/core.rb +1 -1
- data/lib/rubocop/server/helper.rb +1 -1
- data/lib/rubocop/server/server_command/exec.rb +1 -1
- data/lib/rubocop/target_ruby.rb +1 -1
- data/lib/rubocop/version.rb +1 -1
- data/lib/rubocop.rb +8 -0
- metadata +20 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc74785ce6643999994c7595e6ab7b6508abc7ab33532032d09fb854808d3ab5
|
4
|
+
data.tar.gz: 3313880579d587260cae9f718b148160a597da1a239464c9ae86ce8a773065fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b4ea0d9447499f45e99d333c05f72edd634980d506717117cb35029ac2f185de08681c68ce40a2d319efe163b23a168e6c9a55f8178dbf25f847ecc7710cb04
|
7
|
+
data.tar.gz: e1c57df60ec75958f78eec411b0697496ea34b0a10626b3fa79453a64328162292cb621319557b0aac59fe88d447fa32a5e3fbcf1d4d4efcf9ef9388191a6fee
|
data/README.md
CHANGED
@@ -53,7 +53,7 @@ To prevent an unwanted RuboCop update you might want to use a conservative versi
|
|
53
53
|
in your `Gemfile`:
|
54
54
|
|
55
55
|
```rb
|
56
|
-
gem 'rubocop', '~> 1.
|
56
|
+
gem 'rubocop', '~> 1.50', require: false
|
57
57
|
```
|
58
58
|
|
59
59
|
See [our versioning policy](https://docs.rubocop.org/rubocop/versioning.html) for further details.
|
data/config/default.yml
CHANGED
@@ -153,6 +153,7 @@ AllCops:
|
|
153
153
|
rubocop-sequel: [sequel]
|
154
154
|
rubocop-rake: [rake]
|
155
155
|
rubocop-graphql: [graphql]
|
156
|
+
rubocop-capybara: [capybara]
|
156
157
|
# Enable/Disable checking the methods extended by Active Support.
|
157
158
|
ActiveSupportExtensionsEnabled: false
|
158
159
|
|
@@ -1015,8 +1016,6 @@ Layout/LineContinuationLeadingSpace:
|
|
1015
1016
|
Layout/LineContinuationSpacing:
|
1016
1017
|
Description: 'Checks the spacing in front of backslash in line continuations.'
|
1017
1018
|
Enabled: pending
|
1018
|
-
AutoCorrect: true
|
1019
|
-
SafeAutoCorrect: true
|
1020
1019
|
VersionAdded: '1.31'
|
1021
1020
|
EnforcedStyle: space
|
1022
1021
|
SupportedStyles:
|
@@ -1630,13 +1629,12 @@ Lint/Debugger:
|
|
1630
1629
|
Description: 'Check for debugger calls.'
|
1631
1630
|
Enabled: true
|
1632
1631
|
VersionAdded: '0.14'
|
1633
|
-
VersionChanged: '1.
|
1632
|
+
VersionChanged: '1.46'
|
1634
1633
|
DebuggerMethods:
|
1635
1634
|
# Groups are available so that a specific group can be disabled in
|
1636
1635
|
# a user's configuration, but are otherwise not significant.
|
1637
1636
|
Kernel:
|
1638
1637
|
- binding.irb
|
1639
|
-
- p
|
1640
1638
|
- Kernel.binding.irb
|
1641
1639
|
Byebug:
|
1642
1640
|
- byebug
|
@@ -1646,9 +1644,6 @@ Lint/Debugger:
|
|
1646
1644
|
Capybara:
|
1647
1645
|
- save_and_open_page
|
1648
1646
|
- save_and_open_screenshot
|
1649
|
-
PP:
|
1650
|
-
- PP.pp
|
1651
|
-
- pp
|
1652
1647
|
debug.rb:
|
1653
1648
|
- binding.b
|
1654
1649
|
- binding.break
|
@@ -1662,6 +1657,7 @@ Lint/Debugger:
|
|
1662
1657
|
- Kernel.binding.remote_pry
|
1663
1658
|
- Kernel.binding.pry_remote
|
1664
1659
|
- Pry.rescue
|
1660
|
+
- pry
|
1665
1661
|
Rails:
|
1666
1662
|
- debugger
|
1667
1663
|
- Kernel.debugger
|
@@ -1754,6 +1750,11 @@ Lint/DuplicateMagicComment:
|
|
1754
1750
|
Enabled: pending
|
1755
1751
|
VersionAdded: '1.37'
|
1756
1752
|
|
1753
|
+
Lint/DuplicateMatchPattern:
|
1754
|
+
Description: 'Do not repeat patterns in `in` keywords.'
|
1755
|
+
Enabled: pending
|
1756
|
+
VersionAdded: '1.50'
|
1757
|
+
|
1757
1758
|
Lint/DuplicateMethods:
|
1758
1759
|
Description: 'Check for duplicate method definitions.'
|
1759
1760
|
Enabled: true
|
@@ -2547,6 +2548,12 @@ Metrics/ClassLength:
|
|
2547
2548
|
Max: 100
|
2548
2549
|
CountAsOne: []
|
2549
2550
|
|
2551
|
+
Metrics/CollectionLiteralLength:
|
2552
|
+
Description: 'Checks for `Array` or `Hash` literals with many entries.'
|
2553
|
+
Enabled: pending
|
2554
|
+
VersionAdded: '1.47'
|
2555
|
+
LengthThreshold: 250
|
2556
|
+
|
2550
2557
|
# Avoid complex methods.
|
2551
2558
|
Metrics/CyclomaticComplexity:
|
2552
2559
|
Description: >-
|
@@ -2775,7 +2782,7 @@ Naming/InclusiveLanguage:
|
|
2775
2782
|
Description: 'Recommend the use of inclusive language instead of problematic terms.'
|
2776
2783
|
Enabled: false
|
2777
2784
|
VersionAdded: '1.18'
|
2778
|
-
VersionChanged: '1.
|
2785
|
+
VersionChanged: '1.49'
|
2779
2786
|
CheckIdentifiers: true
|
2780
2787
|
CheckConstants: true
|
2781
2788
|
CheckVariables: true
|
@@ -2927,6 +2934,7 @@ Naming/VariableNumber:
|
|
2927
2934
|
- rfc822 # Time#rfc822
|
2928
2935
|
- rfc2822 # Time#rfc2822
|
2929
2936
|
- rfc3339 # DateTime.rfc3339
|
2937
|
+
- x86_64 # Allowed by default as an underscore separated CPU architecture name
|
2930
2938
|
AllowedPatterns: []
|
2931
2939
|
|
2932
2940
|
#################### Security ##############################
|
@@ -3054,6 +3062,7 @@ Style/ArrayCoercion:
|
|
3054
3062
|
Style/ArrayIntersect:
|
3055
3063
|
Description: 'Use `array1.intersect?(array2)` instead of `(array1 & array2).any?`.'
|
3056
3064
|
Enabled: 'pending'
|
3065
|
+
Safe: false
|
3057
3066
|
VersionAdded: '1.40'
|
3058
3067
|
|
3059
3068
|
Style/ArrayJoin:
|
@@ -3256,6 +3265,9 @@ Style/CaseLikeIf:
|
|
3256
3265
|
Enabled: true
|
3257
3266
|
Safe: false
|
3258
3267
|
VersionAdded: '0.88'
|
3268
|
+
VersionChanged: '1.48'
|
3269
|
+
# `MinBranchesCount` defines the number of branches `if` needs to have to trigger this cop.
|
3270
|
+
MinBranchesCount: 3
|
3259
3271
|
|
3260
3272
|
Style/CharacterLiteral:
|
3261
3273
|
Description: 'Checks for uses of character literals.'
|
@@ -3268,7 +3280,7 @@ Style/ClassAndModuleChildren:
|
|
3268
3280
|
StyleGuide: '#namespace-definition'
|
3269
3281
|
# Moving from compact to nested children requires knowledge of whether the
|
3270
3282
|
# outer parent is a module or a class. Moving from nested to compact requires
|
3271
|
-
# verification that the outer parent is defined elsewhere.
|
3283
|
+
# verification that the outer parent is defined elsewhere. RuboCop does not
|
3272
3284
|
# have the knowledge to perform either operation safely and thus requires
|
3273
3285
|
# manual oversight.
|
3274
3286
|
SafeAutoCorrect: false
|
@@ -3499,6 +3511,12 @@ Style/Copyright:
|
|
3499
3511
|
Notice: '^Copyright (\(c\) )?2[0-9]{3} .+'
|
3500
3512
|
AutocorrectNotice: ''
|
3501
3513
|
|
3514
|
+
Style/DataInheritance:
|
3515
|
+
Description: 'Checks for inheritance from Data.define.'
|
3516
|
+
StyleGuide: '#no-extend-data-define'
|
3517
|
+
Enabled: pending
|
3518
|
+
VersionAdded: '1.49'
|
3519
|
+
|
3502
3520
|
Style/DateTime:
|
3503
3521
|
Description: 'Use Time over DateTime.'
|
3504
3522
|
StyleGuide: '#date-time'
|
@@ -3522,6 +3540,12 @@ Style/Dir:
|
|
3522
3540
|
Enabled: true
|
3523
3541
|
VersionAdded: '0.50'
|
3524
3542
|
|
3543
|
+
Style/DirEmpty:
|
3544
|
+
Description: >-
|
3545
|
+
Prefer to use `Dir.empty?('path/to/dir')` when checking if a directory is empty.
|
3546
|
+
Enabled: pending
|
3547
|
+
VersionAdded: '1.48'
|
3548
|
+
|
3525
3549
|
Style/DisableCopsWithinSourceCodeDirective:
|
3526
3550
|
Description: >-
|
3527
3551
|
Forbids disabling/enabling cops within source code.
|
@@ -3717,6 +3741,13 @@ Style/FetchEnvVar:
|
|
3717
3741
|
# Environment variables to be excluded from the inspection.
|
3718
3742
|
AllowedVars: []
|
3719
3743
|
|
3744
|
+
Style/FileEmpty:
|
3745
|
+
Description: >-
|
3746
|
+
Prefer to use `File.empty?('path/to/file')` when checking if a file is empty.
|
3747
|
+
Enabled: pending
|
3748
|
+
Safe: false
|
3749
|
+
VersionAdded: '1.48'
|
3750
|
+
|
3720
3751
|
Style/FileRead:
|
3721
3752
|
Description: 'Favor `File.(bin)read` convenience methods.'
|
3722
3753
|
StyleGuide: '#file-read'
|
@@ -4027,10 +4058,6 @@ Style/InverseMethods:
|
|
4027
4058
|
:=~: :!~
|
4028
4059
|
:<: :>=
|
4029
4060
|
:>: :<=
|
4030
|
-
# `ActiveSupport` defines some common inverse methods. They are listed below,
|
4031
|
-
# and not enabled by default.
|
4032
|
-
# :present?: :blank?,
|
4033
|
-
# :include?: :exclude?
|
4034
4061
|
# `InverseBlocks` are methods that are inverted by inverting the return
|
4035
4062
|
# of the block that is passed to the method
|
4036
4063
|
InverseBlocks:
|
@@ -4546,11 +4573,10 @@ Style/NumericPredicate:
|
|
4546
4573
|
Checks for the use of predicate- or comparison methods for
|
4547
4574
|
numeric comparisons.
|
4548
4575
|
StyleGuide: '#predicate-methods'
|
4549
|
-
Safe: false
|
4550
4576
|
# This will change to a new method call which isn't guaranteed to be on the
|
4551
4577
|
# object. Switching these methods has to be done with knowledge of the types
|
4552
4578
|
# of the variables which rubocop doesn't have.
|
4553
|
-
|
4579
|
+
Safe: false
|
4554
4580
|
Enabled: true
|
4555
4581
|
VersionAdded: '0.42'
|
4556
4582
|
VersionChanged: '0.59'
|
@@ -4859,6 +4885,11 @@ Style/RedundantInterpolation:
|
|
4859
4885
|
VersionAdded: '0.76'
|
4860
4886
|
VersionChanged: '1.30'
|
4861
4887
|
|
4888
|
+
Style/RedundantLineContinuation:
|
4889
|
+
Description: 'Check for redundant line continuation.'
|
4890
|
+
Enabled: pending
|
4891
|
+
VersionAdded: '1.49'
|
4892
|
+
|
4862
4893
|
Style/RedundantParentheses:
|
4863
4894
|
Description: "Checks for parentheses that seem not to serve any purpose."
|
4864
4895
|
Enabled: true
|
@@ -16,6 +16,7 @@ module RuboCop
|
|
16
16
|
|
17
17
|
PHASE_1_OVERRIDDEN = '(skipped because the default Layout/LineLength:Max is overridden)'
|
18
18
|
PHASE_1_DISABLED = '(skipped because Layout/LineLength is disabled)'
|
19
|
+
PHASE_1_SKIPPED = '(skipped because a list of cops is passed to the `--only` flag)'
|
19
20
|
|
20
21
|
def run
|
21
22
|
add_formatter
|
@@ -31,6 +32,8 @@ module RuboCop
|
|
31
32
|
skip_line_length_cop(PHASE_1_DISABLED)
|
32
33
|
elsif !same_max_line_length?(@config_store.for_pwd, ConfigLoader.default_configuration)
|
33
34
|
skip_line_length_cop(PHASE_1_OVERRIDDEN)
|
35
|
+
elsif options_has_only_flag?
|
36
|
+
skip_line_length_cop(PHASE_1_SKIPPED)
|
34
37
|
else
|
35
38
|
run_line_length_cop
|
36
39
|
end
|
@@ -57,6 +60,10 @@ module RuboCop
|
|
57
60
|
config.for_cop('Layout/LineLength')
|
58
61
|
end
|
59
62
|
|
63
|
+
def options_has_only_flag?
|
64
|
+
@options[:only]
|
65
|
+
end
|
66
|
+
|
60
67
|
# Do an initial run with only Layout/LineLength so that cops that
|
61
68
|
# depend on Layout/LineLength:Max get the correct value for that
|
62
69
|
# parameter.
|
@@ -76,13 +76,18 @@ module RuboCop
|
|
76
76
|
warn <<~WARNING
|
77
77
|
Errors are usually caused by RuboCop bugs.
|
78
78
|
Please, report your problems to RuboCop's issue tracker.
|
79
|
-
#{
|
80
|
-
|
79
|
+
#{bug_tracker_uri}
|
81
80
|
Mention the following information in the issue report:
|
82
81
|
#{RuboCop::Version.version(debug: true)}
|
83
82
|
WARNING
|
84
83
|
end
|
85
84
|
|
85
|
+
def bug_tracker_uri
|
86
|
+
return unless Gem.loaded_specs.key?('rubocop')
|
87
|
+
|
88
|
+
"#{Gem.loaded_specs['rubocop'].metadata['bug_tracker_uri']}\n"
|
89
|
+
end
|
90
|
+
|
86
91
|
def maybe_print_corrected_source
|
87
92
|
# Integration tools (like RubyMine) expect to have only the JSON result
|
88
93
|
# when specifying JSON format. Similar HTML and JUnit are targeted as well.
|
data/lib/rubocop/cli.rb
CHANGED
@@ -87,20 +87,20 @@ module RuboCop
|
|
87
87
|
|
88
88
|
tmp_dir = File.join(ConfigFinder.project_root, 'tmp')
|
89
89
|
FileUtils.mkdir_p(tmp_dir)
|
90
|
+
cpu_profile_file = File.join(tmp_dir, 'rubocop-stackprof.dump')
|
90
91
|
status = nil
|
91
92
|
|
92
|
-
StackProf.run(out:
|
93
|
+
StackProf.run(out: cpu_profile_file) do
|
93
94
|
status = yield
|
94
95
|
end
|
95
|
-
puts
|
96
|
+
puts "Profile report generated at #{cpu_profile_file}"
|
96
97
|
|
97
98
|
if with_memory
|
98
99
|
puts 'Building memory report...'
|
99
100
|
report = MemoryProfiler.stop
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
)
|
101
|
+
memory_profile_file = File.join(tmp_dir, 'rubocop-memory_profiler.txt')
|
102
|
+
report.pretty_print(to_file: memory_profile_file, scale_bytes: true)
|
103
|
+
puts "Memory report generated at #{memory_profile_file}"
|
104
104
|
end
|
105
105
|
status
|
106
106
|
end
|
@@ -11,6 +11,8 @@ module RuboCop
|
|
11
11
|
# This class provides an API compatible with RuboCop::DirectiveComment
|
12
12
|
# to be used for cops that are disabled in the config file
|
13
13
|
class ConfigDisabledCopDirectiveComment
|
14
|
+
include RuboCop::Ext::Comment
|
15
|
+
|
14
16
|
attr_reader :text, :loc, :line_number
|
15
17
|
|
16
18
|
Loc = Struct.new(:expression)
|
@@ -42,6 +44,10 @@ module RuboCop
|
|
42
44
|
disabled_line_ranges.none? { |range| range.include?(line_number) }
|
43
45
|
end
|
44
46
|
|
47
|
+
def cop_opted_in?(cop)
|
48
|
+
opt_in_cops.include?(cop.cop_name)
|
49
|
+
end
|
50
|
+
|
45
51
|
def cop_disabled_line_ranges
|
46
52
|
@cop_disabled_line_ranges ||= analyze
|
47
53
|
end
|
@@ -74,6 +80,19 @@ module RuboCop
|
|
74
80
|
extras
|
75
81
|
end
|
76
82
|
|
83
|
+
def opt_in_cops
|
84
|
+
@opt_in_cops ||= begin
|
85
|
+
cops = Set.new
|
86
|
+
each_directive do |directive|
|
87
|
+
next unless directive.enabled?
|
88
|
+
next if directive.all_cops?
|
89
|
+
|
90
|
+
cops.merge(directive.cop_names)
|
91
|
+
end
|
92
|
+
cops
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
77
96
|
def analyze # rubocop:todo Metrics/AbcSize
|
78
97
|
return {} if @no_directives
|
79
98
|
|
data/lib/rubocop/config.rb
CHANGED
@@ -29,7 +29,7 @@ module RuboCop
|
|
29
29
|
end
|
30
30
|
|
31
31
|
# rubocop:disable Metrics/AbcSize
|
32
|
-
def initialize(hash =
|
32
|
+
def initialize(hash = RuboCop::ConfigLoader.default_configuration, loaded_path = nil)
|
33
33
|
@loaded_path = loaded_path
|
34
34
|
@for_cop = Hash.new do |h, cop|
|
35
35
|
cop_name = cop.respond_to?(:cop_name) ? cop.cop_name : cop
|
@@ -304,8 +304,8 @@ module RuboCop
|
|
304
304
|
end
|
305
305
|
|
306
306
|
def enable_cop?(qualified_cop_name, cop_options)
|
307
|
-
# If the cop is explicitly enabled
|
308
|
-
return true if cop_options['Enabled'] == true
|
307
|
+
# If the cop is explicitly enabled or `Lint/Syntax`, the other checks can be skipped.
|
308
|
+
return true if cop_options['Enabled'] == true || qualified_cop_name == 'Lint/Syntax'
|
309
309
|
|
310
310
|
department = department_of(qualified_cop_name)
|
311
311
|
cop_enabled = cop_options.fetch('Enabled') { !for_all_cops['DisabledByDefault'] }
|
@@ -23,6 +23,14 @@ module RuboCop
|
|
23
23
|
class << self
|
24
24
|
include FileFinder
|
25
25
|
|
26
|
+
PENDING_BANNER = <<~BANNER
|
27
|
+
The following cops were added to RuboCop, but are not configured. Please set Enabled to either `true` or `false` in your `.rubocop.yml` file.
|
28
|
+
|
29
|
+
Please also note that you can opt-in to new cops by default by adding this to your config:
|
30
|
+
AllCops:
|
31
|
+
NewCops: enable
|
32
|
+
BANNER
|
33
|
+
|
26
34
|
attr_accessor :debug, :ignore_parent_exclusion, :disable_pending_cops, :enable_pending_cops,
|
27
35
|
:ignore_unrecognized_cops
|
28
36
|
attr_writer :default_configuration
|
@@ -165,14 +173,6 @@ module RuboCop
|
|
165
173
|
ConfigFinder.project_root
|
166
174
|
end
|
167
175
|
|
168
|
-
PENDING_BANNER = <<~BANNER
|
169
|
-
The following cops were added to RuboCop, but are not configured. Please set Enabled to either `true` or `false` in your `.rubocop.yml` file.
|
170
|
-
|
171
|
-
Please also note that you can opt-in to new cops by default by adding this to your config:
|
172
|
-
AllCops:
|
173
|
-
NewCops: enable
|
174
|
-
BANNER
|
175
|
-
|
176
176
|
def warn_on_pending_cops(pending_cops)
|
177
177
|
warn Rainbow(PENDING_BANNER).yellow
|
178
178
|
|
@@ -35,7 +35,7 @@ module RuboCop
|
|
35
35
|
return false if cop_config['AutoCorrect'] == false
|
36
36
|
|
37
37
|
# :safe_autocorrect is a derived option based on several command-line
|
38
|
-
# arguments - see
|
38
|
+
# arguments - see RuboCop::Options#add_autocorrection_options
|
39
39
|
return safe_autocorrect? if @options.fetch(:safe_autocorrect, false)
|
40
40
|
|
41
41
|
true
|
@@ -43,18 +43,24 @@ module RuboCop
|
|
43
43
|
|
44
44
|
private
|
45
45
|
|
46
|
-
def disable_offense(
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
def disable_offense(offense_range)
|
47
|
+
range = surrounding_heredoc(offense_range) || surrounding_percent_array(offense_range)
|
48
|
+
|
49
|
+
if range
|
50
|
+
disable_offense_before_and_after(range_by_lines(range))
|
51
|
+
else
|
52
|
+
disable_offense_with_eol_or_surround_comment(offense_range)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def disable_offense_with_eol_or_surround_comment(range)
|
57
|
+
eol_comment = " # rubocop:todo #{cop_name}"
|
58
|
+
needed_line_length = (range.source_line + eol_comment).length
|
59
|
+
|
60
|
+
if needed_line_length <= max_line_length
|
61
|
+
disable_offense_at_end_of_line(range_of_first_line(range), eol_comment)
|
50
62
|
else
|
51
|
-
|
52
|
-
needed_line_length = (range.source_line + eol_comment).length
|
53
|
-
if needed_line_length <= max_line_length
|
54
|
-
disable_offense_at_end_of_line(range_of_first_line(range), eol_comment)
|
55
|
-
else
|
56
|
-
disable_offense_before_and_after(range_by_lines(range))
|
57
|
-
end
|
63
|
+
disable_offense_before_and_after(range_by_lines(range))
|
58
64
|
end
|
59
65
|
end
|
60
66
|
|
@@ -65,10 +71,20 @@ module RuboCop
|
|
65
71
|
heredoc_nodes = processed_source.ast.each_descendant.select do |node|
|
66
72
|
node.respond_to?(:heredoc?) && node.heredoc?
|
67
73
|
end
|
68
|
-
heredoc_nodes.map { |node| node.
|
74
|
+
heredoc_nodes.map { |node| node.source_range.join(node.loc.heredoc_end) }
|
69
75
|
.find { |range| range.contains?(offense_range) }
|
70
76
|
end
|
71
77
|
|
78
|
+
def surrounding_percent_array(offense_range)
|
79
|
+
return nil if offense_range.empty?
|
80
|
+
|
81
|
+
percent_array = processed_source.ast.each_descendant.select do |node|
|
82
|
+
node.array_type? && node.percent_literal?
|
83
|
+
end
|
84
|
+
|
85
|
+
percent_array.map(&:source_range).find { |range| range.overlaps?(offense_range) }
|
86
|
+
end
|
87
|
+
|
72
88
|
def range_of_first_line(range)
|
73
89
|
begin_of_first_line = range.begin_pos - range.column
|
74
90
|
end_of_first_line = begin_of_first_line + range.source_line.length
|
data/lib/rubocop/cop/base.rb
CHANGED
@@ -124,7 +124,7 @@ module RuboCop
|
|
124
124
|
end
|
125
125
|
|
126
126
|
def preceding_comment?(node1, node2)
|
127
|
-
node1 && node2 && precede?(node2, node1) && comment_line?(node2.
|
127
|
+
node1 && node2 && precede?(node2, node1) && comment_line?(node2.source)
|
128
128
|
end
|
129
129
|
|
130
130
|
def ignored_gem?(node)
|
data/lib/rubocop/cop/cop.rb
CHANGED
@@ -138,10 +138,10 @@ module RuboCop
|
|
138
138
|
def correction_lambda
|
139
139
|
return unless support_autocorrect?
|
140
140
|
|
141
|
-
|
141
|
+
dedupe_on_node(@v0_argument) { autocorrect(@v0_argument) }
|
142
142
|
end
|
143
143
|
|
144
|
-
def
|
144
|
+
def dedupe_on_node(node)
|
145
145
|
@corrected_nodes ||= {}.compare_by_identity
|
146
146
|
yield unless @corrected_nodes.key?(node)
|
147
147
|
ensure
|
@@ -104,7 +104,7 @@ module RuboCop
|
|
104
104
|
def to_range(node_or_range)
|
105
105
|
range = case node_or_range
|
106
106
|
when ::RuboCop::AST::Node, ::Parser::Source::Comment
|
107
|
-
node_or_range.
|
107
|
+
node_or_range.source_range
|
108
108
|
when ::Parser::Source::Range
|
109
109
|
node_or_range
|
110
110
|
else
|
@@ -16,7 +16,7 @@ module RuboCop
|
|
16
16
|
return unless node
|
17
17
|
|
18
18
|
@processed_source = processed_source
|
19
|
-
expr = node.respond_to?(:loc) ? node.
|
19
|
+
expr = node.respond_to?(:loc) ? node.source_range : node
|
20
20
|
return if block_comment_within?(expr)
|
21
21
|
|
22
22
|
taboo_ranges = inside_string_ranges(node)
|
@@ -80,7 +80,7 @@ module RuboCop
|
|
80
80
|
|
81
81
|
def block_comment_within?(expr)
|
82
82
|
processed_source.comments.select(&:document?).any? do |c|
|
83
|
-
within?(c.
|
83
|
+
within?(c.source_range, expr)
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
@@ -35,15 +35,15 @@ module RuboCop
|
|
35
35
|
|
36
36
|
def offending_range
|
37
37
|
if block_node.arguments?
|
38
|
-
replacement_range(argument_node.
|
38
|
+
replacement_range(argument_node.source_range.end_pos)
|
39
39
|
else
|
40
40
|
replacement_range(block_node.loc.begin.end_pos)
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
def replacement_range(end_pos)
|
45
|
-
Parser::Source::Range.new(block_node.
|
46
|
-
block_node.
|
45
|
+
Parser::Source::Range.new(block_node.source_range.source_buffer,
|
46
|
+
block_node.source_range.begin_pos,
|
47
47
|
end_pos)
|
48
48
|
end
|
49
49
|
end
|
@@ -56,7 +56,7 @@ module RuboCop
|
|
56
56
|
if collection_node.begin_type?
|
57
57
|
collection_node.loc.end
|
58
58
|
else
|
59
|
-
collection_node.
|
59
|
+
collection_node.source_range
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
@@ -65,8 +65,8 @@ module RuboCop
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def replacement_range(end_pos)
|
68
|
-
Parser::Source::Range.new(for_node.
|
69
|
-
for_node.
|
68
|
+
Parser::Source::Range.new(for_node.source_range.source_buffer,
|
69
|
+
for_node.source_range.begin_pos,
|
70
70
|
end_pos)
|
71
71
|
end
|
72
72
|
end
|
@@ -35,7 +35,7 @@ module RuboCop
|
|
35
35
|
def move_comment(eol_comment:, node:, corrector:)
|
36
36
|
return unless eol_comment
|
37
37
|
|
38
|
-
text = eol_comment.
|
38
|
+
text = eol_comment.source
|
39
39
|
corrector.insert_before(node, "#{text}\n#{' ' * node.loc.keyword.column}")
|
40
40
|
corrector.remove(eol_comment)
|
41
41
|
end
|
@@ -52,7 +52,7 @@ module RuboCop
|
|
52
52
|
return unless (parent = node.parent)
|
53
53
|
return unless use_heredoc_argument_method_chain?(parent)
|
54
54
|
|
55
|
-
chained_method = range_between(parent.loc.dot.begin_pos, parent.
|
55
|
+
chained_method = range_between(parent.loc.dot.begin_pos, parent.source_range.end_pos)
|
56
56
|
|
57
57
|
corrector.remove(chained_method)
|
58
58
|
corrector.insert_after(end_range, chained_method.source)
|
@@ -80,7 +80,7 @@ module RuboCop
|
|
80
80
|
def select_content_to_be_inserted_after_last_element(corrector, node)
|
81
81
|
range = range_between(
|
82
82
|
node.loc.end.begin_pos,
|
83
|
-
range_by_whole_lines(node.
|
83
|
+
range_by_whole_lines(node.source_range).end.end_pos
|
84
84
|
)
|
85
85
|
|
86
86
|
remove_trailing_content_of_comment(corrector, range)
|
@@ -26,7 +26,7 @@ module RuboCop
|
|
26
26
|
def declaration_with_comment(node)
|
27
27
|
buffer = processed_source.buffer
|
28
28
|
begin_pos = range_by_whole_lines(get_source_range(node, comments_as_separators)).begin_pos
|
29
|
-
end_line = buffer.line_for_position(node.
|
29
|
+
end_line = buffer.line_for_position(node.source_range.end_pos)
|
30
30
|
end_pos = range_by_whole_lines(buffer.line_range(end_line),
|
31
31
|
include_final_newline: true).end_pos
|
32
32
|
|
@@ -66,10 +66,10 @@ module RuboCop
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
-
def line_breaks(node, source, previous_line_num, base_line_num,
|
69
|
+
def line_breaks(node, source, previous_line_num, base_line_num, node_index)
|
70
70
|
source_in_lines = source.split("\n")
|
71
71
|
if first_line?(node, previous_line_num)
|
72
|
-
|
72
|
+
node_index.zero? && node.first_line == base_line_num ? '' : ' '
|
73
73
|
else
|
74
74
|
process_lines(node, previous_line_num, base_line_num, source_in_lines)
|
75
75
|
end
|
@@ -24,7 +24,7 @@ module RuboCop
|
|
24
24
|
MSG = 'Description should be started with %<suggestion>s instead of `This cop ...`.'
|
25
25
|
|
26
26
|
SPECIAL_WORDS = %w[is can could should will would must may].freeze
|
27
|
-
COP_DESC_OFFENSE_REGEX =
|
27
|
+
COP_DESC_OFFENSE_REGEX =
|
28
28
|
/^\s+# This cop (?<special>#{SPECIAL_WORDS.join('|')})?\s*(?<word>.+?) .*/.freeze
|
29
29
|
REPLACEMENT_REGEX = /^\s+# This cop (#{SPECIAL_WORDS.join('|')})?\s*(.+?) /.freeze
|
30
30
|
|
@@ -59,9 +59,9 @@ module RuboCop
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def range(node, comment_line)
|
62
|
-
source_buffer = node.
|
62
|
+
source_buffer = node.source_range.source_buffer
|
63
63
|
|
64
|
-
begin_pos = node.
|
64
|
+
begin_pos = node.source_range.begin_pos
|
65
65
|
begin_pos += comment_index(node, comment_line)
|
66
66
|
end_pos = begin_pos + comment_body(comment_line).length
|
67
67
|
|
@@ -77,7 +77,7 @@ module RuboCop
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def first_comment_line(node)
|
80
|
-
node.
|
80
|
+
node.source.lines.find { |line| comment_line?(line) }
|
81
81
|
end
|
82
82
|
|
83
83
|
def comment_body(comment_line)
|
@@ -86,7 +86,7 @@ module RuboCop
|
|
86
86
|
|
87
87
|
def comment_index(node, comment_line)
|
88
88
|
body = comment_body(comment_line)
|
89
|
-
node.
|
89
|
+
node.source.index(body)
|
90
90
|
end
|
91
91
|
|
92
92
|
def relevant_file?(file)
|