rubocop 1.88.2 → 1.90.0
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/default.yml +139 -16
- data/exe/rubocop +1 -1
- data/lib/rubocop/cached_data.rb +7 -2
- data/lib/rubocop/cli/command/execute_runner.rb +31 -0
- data/lib/rubocop/cli.rb +2 -4
- data/lib/rubocop/comment_config/directive_range.rb +32 -0
- data/lib/rubocop/comment_config/disable_next.rb +97 -0
- data/lib/rubocop/comment_config.rb +81 -49
- data/lib/rubocop/config.rb +76 -5
- data/lib/rubocop/config_loader.rb +1 -2
- data/lib/rubocop/config_loader_resolver.rb +1 -2
- data/lib/rubocop/config_validator.rb +39 -3
- data/lib/rubocop/cop/autocorrect_logic.rb +8 -0
- data/lib/rubocop/cop/badge.rb +8 -0
- data/lib/rubocop/cop/base.rb +40 -6
- data/lib/rubocop/cop/bundler.rb +19 -0
- data/lib/rubocop/cop/corrector.rb +4 -4
- data/lib/rubocop/cop/correctors/alignment_corrector.rb +55 -5
- data/lib/rubocop/cop/gemspec.rb +22 -0
- data/lib/rubocop/cop/generator/registration_injector.rb +188 -0
- data/lib/rubocop/cop/generator.rb +4 -0
- data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +1 -2
- data/lib/rubocop/cop/internal_affairs/node_pattern_groups/ast_walker.rb +1 -2
- data/lib/rubocop/cop/layout/block_alignment.rb +1 -2
- data/lib/rubocop/cop/layout/class_structure.rb +108 -26
- data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +1 -2
- data/lib/rubocop/cop/layout/empty_line_after_magic_comment.rb +63 -5
- data/lib/rubocop/cop/layout/end_alignment.rb +1 -2
- data/lib/rubocop/cop/layout/extra_spacing.rb +105 -3
- data/lib/rubocop/cop/layout/first_argument_indentation.rb +21 -1
- data/lib/rubocop/cop/layout/first_array_element_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/indentation_width.rb +3 -1
- data/lib/rubocop/cop/layout/leading_comment_space.rb +27 -0
- data/lib/rubocop/cop/layout/line_continuation_spacing.rb +1 -2
- data/lib/rubocop/cop/layout/line_length.rb +84 -12
- data/lib/rubocop/cop/layout/multiline_assignment_layout.rb +1 -2
- data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +12 -2
- data/lib/rubocop/cop/layout/redundant_line_break.rb +77 -0
- data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +1 -2
- data/lib/rubocop/cop/layout/space_around_operators.rb +7 -0
- data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +31 -34
- data/lib/rubocop/cop/layout.rb +114 -0
- data/lib/rubocop/cop/lazy_loader.rb +41 -0
- data/lib/rubocop/cop/lint/ambiguous_assignment.rb +9 -7
- data/lib/rubocop/cop/lint/ambiguous_block_association.rb +71 -0
- data/lib/rubocop/cop/lint/ambiguous_range.rb +1 -2
- data/lib/rubocop/cop/lint/argument_mismatch.rb +89 -0
- data/lib/rubocop/cop/lint/constant_reassignment.rb +18 -21
- data/lib/rubocop/cop/lint/constant_resolution.rb +25 -0
- data/lib/rubocop/cop/lint/cop_directive_syntax.rb +84 -8
- data/lib/rubocop/cop/lint/deprecated_reference.rb +194 -0
- data/lib/rubocop/cop/lint/duplicate_methods.rb +300 -22
- data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +1 -2
- data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +1 -2
- data/lib/rubocop/cop/lint/inherit_exception.rb +53 -7
- data/lib/rubocop/cop/lint/interpolation_check.rb +1 -2
- data/lib/rubocop/cop/lint/literal_as_condition.rb +8 -6
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +4 -7
- data/lib/rubocop/cop/lint/missing_cop_enable_directive.rb +25 -12
- data/lib/rubocop/cop/lint/missing_super.rb +31 -1
- data/lib/rubocop/cop/lint/name_typo.rb +270 -0
- data/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +15 -4
- data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +98 -19
- data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +47 -7
- data/lib/rubocop/cop/lint/redundant_require_statement.rb +1 -2
- data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +1 -2
- data/lib/rubocop/cop/lint/redundant_splat_expansion.rb +1 -2
- data/lib/rubocop/cop/lint/redundant_type_conversion.rb +1 -2
- data/lib/rubocop/cop/lint/redundant_with_index.rb +1 -2
- data/lib/rubocop/cop/lint/safe_navigation_chain.rb +8 -2
- data/lib/rubocop/cop/lint/safe_navigation_consistency.rb +2 -4
- data/lib/rubocop/cop/lint/super_argument_mismatch.rb +179 -0
- data/lib/rubocop/cop/lint/suppressed_exception_in_number_conversion.rb +1 -2
- data/lib/rubocop/cop/lint/to_enum_arguments.rb +38 -3
- data/lib/rubocop/cop/lint/unreachable_code.rb +1 -2
- data/lib/rubocop/cop/lint/unused_private_method.rb +234 -0
- data/lib/rubocop/cop/lint/useless_access_modifier.rb +1 -2
- data/lib/rubocop/cop/lint/useless_assignment.rb +1 -2
- data/lib/rubocop/cop/lint/useless_constant_scoping.rb +36 -0
- data/lib/rubocop/cop/lint/useless_method_definition.rb +1 -1
- data/lib/rubocop/cop/lint/useless_rescue.rb +1 -2
- data/lib/rubocop/cop/lint/useless_ruby2_keywords.rb +2 -0
- data/lib/rubocop/cop/lint/utils/nil_receiver_checker.rb +61 -7
- data/lib/rubocop/cop/lint/void.rb +18 -8
- data/lib/rubocop/cop/lint.rb +178 -0
- data/lib/rubocop/cop/metrics/perceived_complexity.rb +1 -2
- data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +1 -1
- data/lib/rubocop/cop/metrics.rb +31 -0
- data/lib/rubocop/cop/migration/department_name.rb +1 -6
- data/lib/rubocop/cop/migration.rb +13 -0
- data/lib/rubocop/cop/mixin/check_line_breakable.rb +23 -5
- data/lib/rubocop/cop/mixin/comments_help.rb +1 -2
- data/lib/rubocop/cop/mixin/configurable_enforced_style.rb +1 -2
- data/lib/rubocop/cop/mixin/endless_method_rewriter.rb +13 -5
- data/lib/rubocop/cop/mixin/hash_alignment_styles.rb +23 -6
- data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +1 -2
- data/lib/rubocop/cop/mixin/hash_subset.rb +1 -2
- data/lib/rubocop/cop/mixin/indexed_method_arity.rb +94 -0
- data/lib/rubocop/cop/mixin/line_length_help.rb +7 -1
- data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +51 -6
- data/lib/rubocop/cop/mixin/project_index_help.rb +140 -0
- data/lib/rubocop/cop/mixin/range_help.rb +1 -2
- data/lib/rubocop/cop/mixin/reparsed_equivalence.rb +171 -0
- data/lib/rubocop/cop/mixin/statement_modifier.rb +46 -4
- data/lib/rubocop/cop/mixin/trailing_comma.rb +2 -4
- data/lib/rubocop/cop/mixin.rb +82 -77
- data/lib/rubocop/cop/naming/accessor_method_name.rb +24 -0
- data/lib/rubocop/cop/naming/binary_operator_parameter_name.rb +16 -0
- data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +2 -4
- data/lib/rubocop/cop/naming/method_name.rb +5 -2
- data/lib/rubocop/cop/naming/predicate_prefix.rb +33 -5
- data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +1 -2
- data/lib/rubocop/cop/naming/variable_number.rb +3 -1
- data/lib/rubocop/cop/naming.rb +31 -0
- data/lib/rubocop/cop/offense.rb +37 -10
- data/lib/rubocop/cop/registry.rb +180 -46
- data/lib/rubocop/cop/security.rb +19 -0
- data/lib/rubocop/cop/style/accessor_grouping.rb +1 -2
- data/lib/rubocop/cop/style/arguments_forwarding.rb +3 -6
- data/lib/rubocop/cop/style/array_first_last.rb +1 -2
- data/lib/rubocop/cop/style/array_intersect.rb +24 -5
- data/lib/rubocop/cop/style/bitwise_predicate.rb +1 -2
- data/lib/rubocop/cop/style/block_delimiters.rb +3 -6
- data/lib/rubocop/cop/style/case_like_if.rb +2 -4
- data/lib/rubocop/cop/style/class_and_module_children.rb +79 -20
- data/lib/rubocop/cop/style/combinable_loops.rb +1 -2
- data/lib/rubocop/cop/style/concat_array_literals.rb +1 -2
- data/lib/rubocop/cop/style/conditional_assignment.rb +23 -2
- data/lib/rubocop/cop/style/constant_visibility.rb +1 -2
- data/lib/rubocop/cop/style/copyright.rb +5 -1
- data/lib/rubocop/cop/style/directive_scope.rb +171 -0
- data/lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb +76 -12
- data/lib/rubocop/cop/style/documentation.rb +47 -0
- data/lib/rubocop/cop/style/empty_case_condition.rb +1 -2
- data/lib/rubocop/cop/style/endless_method.rb +0 -10
- data/lib/rubocop/cop/style/format_string_token.rb +1 -2
- data/lib/rubocop/cop/style/guard_clause.rb +1 -2
- data/lib/rubocop/cop/style/hash_each_methods.rb +1 -2
- data/lib/rubocop/cop/style/hash_syntax.rb +1 -2
- data/lib/rubocop/cop/style/identical_conditional_branches.rb +2 -4
- data/lib/rubocop/cop/style/if_inside_else.rb +1 -2
- data/lib/rubocop/cop/style/if_unless_modifier.rb +8 -50
- data/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb +1 -2
- data/lib/rubocop/cop/style/lambda.rb +4 -0
- data/lib/rubocop/cop/style/map_to_hash.rb +1 -2
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +22 -7
- data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +1 -2
- data/lib/rubocop/cop/style/missing_respond_to_missing.rb +30 -0
- data/lib/rubocop/cop/style/multiline_if_then.rb +7 -1
- data/lib/rubocop/cop/style/multiline_method_signature.rb +1 -2
- data/lib/rubocop/cop/style/multiple_comparison.rb +33 -22
- data/lib/rubocop/cop/style/mutable_constant.rb +5 -0
- data/lib/rubocop/cop/style/negated_if_else_condition.rb +1 -2
- data/lib/rubocop/cop/style/negative_array_index.rb +3 -3
- data/lib/rubocop/cop/style/nil_comparison.rb +1 -2
- data/lib/rubocop/cop/style/operator_method_call.rb +1 -2
- data/lib/rubocop/cop/style/parallel_assignment.rb +1 -2
- data/lib/rubocop/cop/style/redundant_assignment.rb +12 -2
- data/lib/rubocop/cop/style/redundant_condition.rb +2 -4
- data/lib/rubocop/cop/style/redundant_constant_base.rb +37 -1
- data/lib/rubocop/cop/style/redundant_double_splat_hash_braces.rb +1 -2
- data/lib/rubocop/cop/style/redundant_each.rb +1 -2
- data/lib/rubocop/cop/style/redundant_file_extension_in_require.rb +9 -0
- data/lib/rubocop/cop/style/redundant_format.rb +14 -7
- data/lib/rubocop/cop/style/redundant_line_continuation.rb +78 -135
- data/lib/rubocop/cop/style/redundant_parentheses.rb +65 -67
- data/lib/rubocop/cop/style/redundant_regexp_argument.rb +1 -2
- data/lib/rubocop/cop/style/redundant_return.rb +1 -2
- data/lib/rubocop/cop/style/redundant_self_assignment.rb +1 -2
- data/lib/rubocop/cop/style/redundant_string_escape.rb +1 -2
- data/lib/rubocop/cop/style/rescue_modifier.rb +1 -2
- data/lib/rubocop/cop/style/safe_navigation.rb +11 -2
- data/lib/rubocop/cop/style/sample.rb +11 -6
- data/lib/rubocop/cop/style/select_by_regexp.rb +1 -2
- data/lib/rubocop/cop/style/semicolon.rb +2 -4
- data/lib/rubocop/cop/style/single_line_do_end_block.rb +1 -2
- data/lib/rubocop/cop/style/sole_nested_conditional.rb +21 -5
- data/lib/rubocop/cop/style/stabby_lambda_parentheses.rb +2 -0
- data/lib/rubocop/cop/style/static_class.rb +21 -0
- data/lib/rubocop/cop/style/string_concatenation.rb +18 -5
- data/lib/rubocop/cop/style/super_arguments.rb +1 -2
- data/lib/rubocop/cop/style/symbol_proc.rb +1 -2
- data/lib/rubocop/cop/style/time_now.rb +41 -0
- data/lib/rubocop/cop/style/yoda_condition.rb +1 -2
- data/lib/rubocop/cop/style.rb +312 -0
- data/lib/rubocop/cop/team.rb +59 -6
- data/lib/rubocop/cop/util.rb +2 -4
- data/lib/rubocop/cop/variable_force/variable.rb +19 -8
- data/lib/rubocop/cops_documentation_generator.rb +4 -7
- data/lib/rubocop/directive_comment.rb +39 -3
- data/lib/rubocop/feature_loader.rb +0 -6
- data/lib/rubocop/formatter/emacs_style_formatter.rb +3 -1
- data/lib/rubocop/formatter/html_formatter.rb +2 -4
- data/lib/rubocop/formatter/json_formatter.rb +11 -6
- data/lib/rubocop/formatter/junit_formatter.rb +26 -9
- data/lib/rubocop/formatter/offense_count_formatter.rb +1 -2
- data/lib/rubocop/formatter/simple_text_formatter.rb +4 -3
- data/lib/rubocop/formatter/tap_formatter.rb +3 -1
- data/lib/rubocop/formatter/worst_offenders_formatter.rb +1 -2
- data/lib/rubocop/lockfile.rb +18 -0
- data/lib/rubocop/lsp/diagnostic.rb +4 -8
- data/lib/rubocop/lsp/routes.rb +89 -22
- data/lib/rubocop/lsp/runtime.rb +4 -0
- data/lib/rubocop/lsp/server.rb +4 -0
- data/lib/rubocop/lsp/stdin_runner.rb +20 -0
- data/lib/rubocop/mcp/server.rb +1 -2
- data/lib/rubocop/options.rb +10 -6
- data/lib/rubocop/path_util.rb +1 -2
- data/lib/rubocop/pending_cops_reporter.rb +1 -6
- data/lib/rubocop/plugin/configuration_integrator.rb +6 -3
- data/lib/rubocop/project_index_loader.rb +16 -0
- data/lib/rubocop/rake_task.rb +1 -2
- data/lib/rubocop/result_cache.rb +6 -4
- data/lib/rubocop/rspec/expect_offense.rb +2 -4
- data/lib/rubocop/rspec/shared_contexts.rb +16 -2
- data/lib/rubocop/runner.rb +71 -43
- data/lib/rubocop/server/cache.rb +11 -7
- data/lib/rubocop/server/cli.rb +2 -4
- data/lib/rubocop/server.rb +14 -0
- data/lib/rubocop/target_finder.rb +4 -1
- data/lib/rubocop/target_ruby.rb +1 -1
- data/lib/rubocop/todo_audit.rb +111 -0
- data/lib/rubocop/version.rb +3 -5
- data/lib/rubocop.rb +20 -626
- data/lib/ruby_lsp/rubocop/addon.rb +1 -2
- metadata +28 -5
data/lib/rubocop/cop/mixin.rb
CHANGED
|
@@ -5,82 +5,87 @@ module RuboCop
|
|
|
5
5
|
# Autoloads mixin modules included by cops. Mixins are autoloaded to reduce the number of
|
|
6
6
|
# requires because they're used only when the relevant cop class is loaded.
|
|
7
7
|
|
|
8
|
-
autoload :ArrayMinSize,
|
|
9
|
-
autoload :ArraySyntax,
|
|
10
|
-
autoload :Alignment,
|
|
11
|
-
autoload :AllowedIdentifiers,
|
|
12
|
-
autoload :AllowedMethods,
|
|
13
|
-
autoload :AllowedPattern,
|
|
14
|
-
autoload :AllowedReceivers,
|
|
15
|
-
autoload :ForbiddenIdentifiers,
|
|
16
|
-
autoload :ForbiddenPattern,
|
|
17
|
-
autoload :AutoCorrector,
|
|
18
|
-
autoload :CheckAssignment,
|
|
19
|
-
autoload :CheckLineBreakable,
|
|
20
|
-
autoload :CheckSingleLineSuitability,
|
|
21
|
-
autoload :ConfigurableMax,
|
|
22
|
-
autoload :CodeLength,
|
|
23
|
-
autoload :ConfigurableEnforcedStyle,
|
|
24
|
-
autoload :ConfigurableFormatting,
|
|
25
|
-
autoload :ConfigurableNaming,
|
|
26
|
-
autoload :ConfigurableNumbering,
|
|
27
|
-
autoload :DigHelp,
|
|
28
|
-
autoload :DocumentationComment,
|
|
29
|
-
autoload :Duplication,
|
|
30
|
-
autoload :RangeHelp,
|
|
31
|
-
autoload :ProjectIndexHelp,
|
|
32
|
-
autoload :AnnotationComment,
|
|
33
|
-
autoload :EmptyParameter,
|
|
34
|
-
autoload :EndKeywordAlignment,
|
|
35
|
-
autoload :EndlessMethodRewriter,
|
|
36
|
-
autoload :EnforceSuperclass,
|
|
37
|
-
autoload :FirstElementLineBreak,
|
|
38
|
-
autoload :FrozenStringLiteral,
|
|
39
|
-
autoload :GemDeclaration,
|
|
40
|
-
autoload :GemspecHelp,
|
|
41
|
-
autoload :HashAlignmentStyles,
|
|
42
|
-
autoload :HashSubset,
|
|
43
|
-
autoload :HashTransformMethod,
|
|
44
|
-
|
|
45
|
-
autoload :
|
|
46
|
-
autoload :
|
|
47
|
-
autoload :
|
|
48
|
-
autoload :
|
|
49
|
-
autoload :
|
|
50
|
-
autoload :
|
|
51
|
-
autoload :
|
|
52
|
-
autoload :
|
|
53
|
-
autoload :
|
|
54
|
-
autoload :
|
|
55
|
-
autoload :
|
|
56
|
-
autoload :
|
|
57
|
-
autoload :
|
|
58
|
-
autoload :
|
|
59
|
-
autoload :
|
|
60
|
-
autoload :
|
|
61
|
-
autoload :
|
|
62
|
-
autoload :
|
|
63
|
-
autoload :
|
|
64
|
-
autoload :
|
|
65
|
-
autoload :
|
|
66
|
-
autoload :
|
|
67
|
-
autoload :
|
|
68
|
-
autoload :
|
|
69
|
-
autoload :
|
|
70
|
-
autoload :
|
|
71
|
-
autoload :
|
|
72
|
-
autoload :
|
|
73
|
-
autoload :
|
|
74
|
-
autoload :
|
|
75
|
-
autoload :
|
|
76
|
-
autoload :
|
|
77
|
-
autoload :
|
|
78
|
-
autoload :
|
|
79
|
-
autoload :
|
|
80
|
-
autoload :
|
|
81
|
-
autoload :
|
|
82
|
-
autoload :
|
|
83
|
-
autoload :
|
|
84
|
-
autoload :
|
|
8
|
+
autoload :ArrayMinSize, "#{__dir__}/mixin/array_min_size"
|
|
9
|
+
autoload :ArraySyntax, "#{__dir__}/mixin/array_syntax"
|
|
10
|
+
autoload :Alignment, "#{__dir__}/mixin/alignment"
|
|
11
|
+
autoload :AllowedIdentifiers, "#{__dir__}/mixin/allowed_identifiers"
|
|
12
|
+
autoload :AllowedMethods, "#{__dir__}/mixin/allowed_methods"
|
|
13
|
+
autoload :AllowedPattern, "#{__dir__}/mixin/allowed_pattern"
|
|
14
|
+
autoload :AllowedReceivers, "#{__dir__}/mixin/allowed_receivers"
|
|
15
|
+
autoload :ForbiddenIdentifiers, "#{__dir__}/mixin/forbidden_identifiers"
|
|
16
|
+
autoload :ForbiddenPattern, "#{__dir__}/mixin/forbidden_pattern"
|
|
17
|
+
autoload :AutoCorrector, "#{__dir__}/mixin/auto_corrector" # rubocop:todo Naming/InclusiveLanguage
|
|
18
|
+
autoload :CheckAssignment, "#{__dir__}/mixin/check_assignment"
|
|
19
|
+
autoload :CheckLineBreakable, "#{__dir__}/mixin/check_line_breakable"
|
|
20
|
+
autoload :CheckSingleLineSuitability, "#{__dir__}/mixin/check_single_line_suitability"
|
|
21
|
+
autoload :ConfigurableMax, "#{__dir__}/mixin/configurable_max"
|
|
22
|
+
autoload :CodeLength, "#{__dir__}/mixin/code_length"
|
|
23
|
+
autoload :ConfigurableEnforcedStyle, "#{__dir__}/mixin/configurable_enforced_style"
|
|
24
|
+
autoload :ConfigurableFormatting, "#{__dir__}/mixin/configurable_formatting"
|
|
25
|
+
autoload :ConfigurableNaming, "#{__dir__}/mixin/configurable_naming"
|
|
26
|
+
autoload :ConfigurableNumbering, "#{__dir__}/mixin/configurable_numbering"
|
|
27
|
+
autoload :DigHelp, "#{__dir__}/mixin/dig_help"
|
|
28
|
+
autoload :DocumentationComment, "#{__dir__}/mixin/documentation_comment"
|
|
29
|
+
autoload :Duplication, "#{__dir__}/mixin/duplication"
|
|
30
|
+
autoload :RangeHelp, "#{__dir__}/mixin/range_help"
|
|
31
|
+
autoload :ProjectIndexHelp, "#{__dir__}/mixin/project_index_help"
|
|
32
|
+
autoload :AnnotationComment, "#{__dir__}/mixin/annotation_comment"
|
|
33
|
+
autoload :EmptyParameter, "#{__dir__}/mixin/empty_parameter"
|
|
34
|
+
autoload :EndKeywordAlignment, "#{__dir__}/mixin/end_keyword_alignment"
|
|
35
|
+
autoload :EndlessMethodRewriter, "#{__dir__}/mixin/endless_method_rewriter"
|
|
36
|
+
autoload :EnforceSuperclass, "#{__dir__}/mixin/enforce_superclass"
|
|
37
|
+
autoload :FirstElementLineBreak, "#{__dir__}/mixin/first_element_line_break"
|
|
38
|
+
autoload :FrozenStringLiteral, "#{__dir__}/mixin/frozen_string_literal"
|
|
39
|
+
autoload :GemDeclaration, "#{__dir__}/mixin/gem_declaration"
|
|
40
|
+
autoload :GemspecHelp, "#{__dir__}/mixin/gemspec_help"
|
|
41
|
+
autoload :HashAlignmentStyles, "#{__dir__}/mixin/hash_alignment_styles"
|
|
42
|
+
autoload :HashSubset, "#{__dir__}/mixin/hash_subset"
|
|
43
|
+
autoload :HashTransformMethod, "#{__dir__}/mixin/hash_transform_method"
|
|
44
|
+
# Deprecated aliases of `AllowedMethods` and `AllowedPattern`, defined in those files.
|
|
45
|
+
autoload :IgnoredMethods, "#{__dir__}/mixin/allowed_methods"
|
|
46
|
+
autoload :IgnoredPattern, "#{__dir__}/mixin/allowed_pattern"
|
|
47
|
+
autoload :IndexedMethodArity, "#{__dir__}/mixin/indexed_method_arity"
|
|
48
|
+
autoload :IntegerNode, "#{__dir__}/mixin/integer_node"
|
|
49
|
+
autoload :Interpolation, "#{__dir__}/mixin/interpolation"
|
|
50
|
+
autoload :LineLengthHelp, "#{__dir__}/mixin/line_length_help"
|
|
51
|
+
autoload :MatchRange, "#{__dir__}/mixin/match_range"
|
|
52
|
+
autoload :HashShorthandSyntax, "#{__dir__}/mixin/hash_shorthand_syntax"
|
|
53
|
+
autoload :MethodComplexity, "#{__dir__}/mixin/method_complexity"
|
|
54
|
+
autoload :MethodPreference, "#{__dir__}/mixin/method_preference"
|
|
55
|
+
autoload :MinBodyLength, "#{__dir__}/mixin/min_body_length"
|
|
56
|
+
autoload :MinBranchesCount, "#{__dir__}/mixin/min_branches_count"
|
|
57
|
+
autoload :MultilineElementIndentation, "#{__dir__}/mixin/multiline_element_indentation"
|
|
58
|
+
autoload :MultilineElementLineBreaks, "#{__dir__}/mixin/multiline_element_line_breaks"
|
|
59
|
+
autoload :MultilineExpressionIndentation, "#{__dir__}/mixin/multiline_expression_indentation"
|
|
60
|
+
autoload :MultilineLiteralBraceLayout, "#{__dir__}/mixin/multiline_literal_brace_layout"
|
|
61
|
+
autoload :NegativeConditional, "#{__dir__}/mixin/negative_conditional"
|
|
62
|
+
autoload :Heredoc, "#{__dir__}/mixin/heredoc"
|
|
63
|
+
autoload :NilMethods, "#{__dir__}/mixin/nil_methods"
|
|
64
|
+
autoload :OnNormalIfUnless, "#{__dir__}/mixin/on_normal_if_unless"
|
|
65
|
+
autoload :OrderedGemNode, "#{__dir__}/mixin/ordered_gem_node"
|
|
66
|
+
autoload :Parentheses, "#{__dir__}/mixin/parentheses"
|
|
67
|
+
autoload :PercentArray, "#{__dir__}/mixin/percent_array"
|
|
68
|
+
autoload :PercentLiteral, "#{__dir__}/mixin/percent_literal"
|
|
69
|
+
autoload :PrecedingFollowingAlignment, "#{__dir__}/mixin/preceding_following_alignment"
|
|
70
|
+
autoload :PreferredDelimiters, "#{__dir__}/mixin/preferred_delimiters"
|
|
71
|
+
autoload :RationalLiteral, "#{__dir__}/mixin/rational_literal"
|
|
72
|
+
autoload :ReparsedEquivalence, "#{__dir__}/mixin/reparsed_equivalence"
|
|
73
|
+
autoload :RequireLibrary, "#{__dir__}/mixin/require_library"
|
|
74
|
+
autoload :RescueNode, "#{__dir__}/mixin/rescue_node"
|
|
75
|
+
autoload :SafeAssignment, "#{__dir__}/mixin/safe_assignment"
|
|
76
|
+
autoload :SpaceAfterPunctuation, "#{__dir__}/mixin/space_after_punctuation"
|
|
77
|
+
autoload :SpaceBeforePunctuation, "#{__dir__}/mixin/space_before_punctuation"
|
|
78
|
+
autoload :SurroundingSpace, "#{__dir__}/mixin/surrounding_space"
|
|
79
|
+
autoload :StatementModifier, "#{__dir__}/mixin/statement_modifier"
|
|
80
|
+
autoload :StringHelp, "#{__dir__}/mixin/string_help"
|
|
81
|
+
autoload :StringLiteralsHelp, "#{__dir__}/mixin/string_literals_help"
|
|
82
|
+
autoload :SymbolHelp, "#{__dir__}/mixin/symbol_help"
|
|
83
|
+
autoload :TargetRubyVersion, "#{__dir__}/mixin/target_ruby_version"
|
|
84
|
+
autoload :TrailingBody, "#{__dir__}/mixin/trailing_body"
|
|
85
|
+
autoload :TrailingComma, "#{__dir__}/mixin/trailing_comma"
|
|
86
|
+
autoload :UncommunicativeName, "#{__dir__}/mixin/uncommunicative_name"
|
|
87
|
+
autoload :VisibilityHelp, "#{__dir__}/mixin/visibility_help"
|
|
88
|
+
autoload :CommentsHelp, "#{__dir__}/mixin/comments_help"
|
|
89
|
+
autoload :DefNode, "#{__dir__}/mixin/def_node"
|
|
85
90
|
end
|
|
86
91
|
end
|
|
@@ -11,6 +11,11 @@ module RuboCop
|
|
|
11
11
|
# Getters (`get_attribute`) must have no arguments to be registered,
|
|
12
12
|
# and setters (`set_attribute(value)`) must have exactly one.
|
|
13
13
|
#
|
|
14
|
+
# When `AllCops/UseProjectIndex` is enabled and the `rubydex` gem is
|
|
15
|
+
# installed, methods that override a method defined by an ancestor
|
|
16
|
+
# elsewhere in the project are not reported, since renaming an override
|
|
17
|
+
# breaks the inherited contract.
|
|
18
|
+
#
|
|
14
19
|
# @example
|
|
15
20
|
# # bad
|
|
16
21
|
# def set_attribute(value)
|
|
@@ -36,12 +41,15 @@ module RuboCop
|
|
|
36
41
|
# def set_value
|
|
37
42
|
# end
|
|
38
43
|
class AccessorMethodName < Base
|
|
44
|
+
include ProjectIndexHelp
|
|
45
|
+
|
|
39
46
|
MSG_READER = 'Do not prefix reader method names with `get_`.'
|
|
40
47
|
MSG_WRITER = 'Do not prefix writer method names with `set_`.'
|
|
41
48
|
|
|
42
49
|
def on_def(node)
|
|
43
50
|
return unless proper_attribute_name?(node)
|
|
44
51
|
return unless bad_reader_name?(node) || bad_writer_name?(node)
|
|
52
|
+
return if overrides_inherited_method?(node)
|
|
45
53
|
|
|
46
54
|
message = message(node)
|
|
47
55
|
|
|
@@ -72,6 +80,22 @@ module RuboCop
|
|
|
72
80
|
node.arguments.one? &&
|
|
73
81
|
node.first_argument.arg_type?
|
|
74
82
|
end
|
|
83
|
+
|
|
84
|
+
# When `AllCops/UseProjectIndex` is enabled, methods that override a
|
|
85
|
+
# method defined by an ancestor elsewhere in the project are not
|
|
86
|
+
# reported: renaming an override breaks the inherited contract.
|
|
87
|
+
def overrides_inherited_method?(node)
|
|
88
|
+
return false unless project_index
|
|
89
|
+
return false unless (namespace_node = node.each_ancestor(:class, :module).first)
|
|
90
|
+
|
|
91
|
+
declaration = resolve_constant_in_index(namespace_node.identifier)
|
|
92
|
+
return false unless declaration.is_a?(Rubydex::Namespace)
|
|
93
|
+
|
|
94
|
+
scope = node.defs_type? ? indexed_singleton_of(declaration) : declaration
|
|
95
|
+
!scope.nil? && inherited_index_member?(scope, "#{node.method_name}()")
|
|
96
|
+
rescue StandardError
|
|
97
|
+
false
|
|
98
|
+
end
|
|
75
99
|
end
|
|
76
100
|
end
|
|
77
101
|
end
|
|
@@ -33,6 +33,7 @@ module RuboCop
|
|
|
33
33
|
node.each_descendant(:lvar, :lvasgn) do |lvar|
|
|
34
34
|
lvar_location = lvar.loc.name
|
|
35
35
|
next unless lvar_location.source == arg.source
|
|
36
|
+
next if shadowed?(lvar, arg.source, node)
|
|
36
37
|
|
|
37
38
|
corrector.replace(lvar_location, 'other')
|
|
38
39
|
end
|
|
@@ -47,6 +48,21 @@ module RuboCop
|
|
|
47
48
|
|
|
48
49
|
!/\A[[:word:]]/.match?(name) || OP_LIKE_METHODS.include?(name)
|
|
49
50
|
end
|
|
51
|
+
|
|
52
|
+
# A reference is shadowed when an enclosing block within the method redeclares the
|
|
53
|
+
# parameter name (as a block parameter or block-local). Such a reference points to
|
|
54
|
+
# the block's variable, not the operator's parameter, so it must not be renamed.
|
|
55
|
+
def shadowed?(node, name, def_node)
|
|
56
|
+
node.each_ancestor(:block).any? do |block|
|
|
57
|
+
def_node.source_range.contains?(block.source_range) && redeclares?(block, name)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def redeclares?(block, name)
|
|
62
|
+
block.arguments.any? do |argument|
|
|
63
|
+
argument.respond_to?(:name) && argument.name.to_s == name
|
|
64
|
+
end
|
|
65
|
+
end
|
|
50
66
|
end
|
|
51
67
|
end
|
|
52
68
|
end
|
|
@@ -167,7 +167,7 @@ module RuboCop
|
|
|
167
167
|
PATTERN
|
|
168
168
|
|
|
169
169
|
# rubocop:disable Metrics/AbcSize
|
|
170
|
-
# rubocop:disable Metrics/MethodLength
|
|
170
|
+
# rubocop:disable-next Metrics/MethodLength
|
|
171
171
|
def on_or_asgn(node)
|
|
172
172
|
lhs = node.lhs
|
|
173
173
|
return unless lhs.ivasgn_type?
|
|
@@ -192,7 +192,6 @@ module RuboCop
|
|
|
192
192
|
corrector.replace(lhs.loc.name, "@#{suggested_var}")
|
|
193
193
|
end
|
|
194
194
|
end
|
|
195
|
-
# rubocop:enable Metrics/MethodLength
|
|
196
195
|
# rubocop:enable Metrics/AbcSize
|
|
197
196
|
|
|
198
197
|
# @!method defined_memoized?(node, ivar)
|
|
@@ -203,7 +202,7 @@ module RuboCop
|
|
|
203
202
|
$(ivasgn %1 _))
|
|
204
203
|
PATTERN
|
|
205
204
|
|
|
206
|
-
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
205
|
+
# rubocop:disable-next Metrics/AbcSize, Metrics/MethodLength
|
|
207
206
|
def on_defined?(node)
|
|
208
207
|
arg = node.first_argument
|
|
209
208
|
return false unless arg.ivar_type?
|
|
@@ -233,7 +232,6 @@ module RuboCop
|
|
|
233
232
|
end
|
|
234
233
|
end
|
|
235
234
|
end
|
|
236
|
-
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
|
237
235
|
|
|
238
236
|
private
|
|
239
237
|
|
|
@@ -105,6 +105,10 @@ module RuboCop
|
|
|
105
105
|
|
|
106
106
|
MSG = 'Use %<style>s for method names.'
|
|
107
107
|
MSG_FORBIDDEN = '`%<identifier>s` is forbidden, use another method name instead.'
|
|
108
|
+
RESTRICT_ON_SEND = %i[
|
|
109
|
+
define_method define_singleton_method new define alias_method
|
|
110
|
+
attr attr_reader attr_writer attr_accessor
|
|
111
|
+
].freeze
|
|
108
112
|
|
|
109
113
|
OPERATOR_METHODS = %i[| ^ & <=> == === =~ > >= < <= << >> + - * /
|
|
110
114
|
% ** ~ +@ -@ !@ ~@ [] []= ! != !~ `].to_set.freeze
|
|
@@ -209,7 +213,7 @@ module RuboCop
|
|
|
209
213
|
forbidden_identifier?(name) || forbidden_pattern?(name)
|
|
210
214
|
end
|
|
211
215
|
|
|
212
|
-
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
|
216
|
+
# rubocop:disable-next Metrics/MethodLength, Metrics/AbcSize
|
|
213
217
|
def register_forbidden_name(node)
|
|
214
218
|
if node.any_def_type?
|
|
215
219
|
name_node = node.loc.name
|
|
@@ -227,7 +231,6 @@ module RuboCop
|
|
|
227
231
|
message = format(MSG_FORBIDDEN, identifier: method_name)
|
|
228
232
|
add_offense(name_node, message: message)
|
|
229
233
|
end
|
|
230
|
-
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
|
231
234
|
|
|
232
235
|
def attr_name(name_item)
|
|
233
236
|
sym_name(name_item) || str_name(name_item)
|
|
@@ -21,6 +21,11 @@ module RuboCop
|
|
|
21
21
|
# offenses if the method has a Sorbet `sig` with a return type of
|
|
22
22
|
# `T::Boolean`. Dynamic methods are not supported with this configuration.
|
|
23
23
|
#
|
|
24
|
+
# When `AllCops/UseProjectIndex` is enabled and the `rubydex` gem is
|
|
25
|
+
# installed, methods that override a method defined by an ancestor
|
|
26
|
+
# elsewhere in the project are not reported, since renaming an override
|
|
27
|
+
# breaks the inherited contract.
|
|
28
|
+
#
|
|
24
29
|
# @example NamePrefix: ['is_', 'has_', 'have_'] (default)
|
|
25
30
|
# # bad
|
|
26
31
|
# def is_even(value)
|
|
@@ -101,6 +106,7 @@ module RuboCop
|
|
|
101
106
|
# def_node_matcher(:even?) { |value| }
|
|
102
107
|
#
|
|
103
108
|
class PredicatePrefix < Base
|
|
109
|
+
include ProjectIndexHelp
|
|
104
110
|
include AllowedMethods
|
|
105
111
|
|
|
106
112
|
# @!method dynamic_method_define(node)
|
|
@@ -124,18 +130,24 @@ module RuboCop
|
|
|
124
130
|
end
|
|
125
131
|
|
|
126
132
|
def on_def(node)
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
next if allowed_method_name?(method_name, prefix)
|
|
131
|
-
next if use_sorbet_sigs? && !sorbet_sig?(node, return_type: 'T::Boolean')
|
|
133
|
+
method_name = node.method_name.to_s
|
|
134
|
+
offending_prefixes = offending_prefixes_for(node, method_name)
|
|
135
|
+
return if offending_prefixes.empty? || overrides_inherited_method?(node)
|
|
132
136
|
|
|
137
|
+
offending_prefixes.each do |prefix|
|
|
133
138
|
add_offense(
|
|
134
139
|
node.loc.name,
|
|
135
140
|
message: message(method_name, expected_name(method_name, prefix))
|
|
136
141
|
)
|
|
137
142
|
end
|
|
138
143
|
end
|
|
144
|
+
|
|
145
|
+
def offending_prefixes_for(node, method_name)
|
|
146
|
+
predicate_prefixes.reject do |prefix|
|
|
147
|
+
allowed_method_name?(method_name, prefix) ||
|
|
148
|
+
(use_sorbet_sigs? && !sorbet_sig?(node, return_type: 'T::Boolean'))
|
|
149
|
+
end
|
|
150
|
+
end
|
|
139
151
|
alias on_defs on_def
|
|
140
152
|
|
|
141
153
|
def validate_config
|
|
@@ -198,6 +210,22 @@ module RuboCop
|
|
|
198
210
|
def method_definition_macro?(macro_name)
|
|
199
211
|
cop_config['MethodDefinitionMacros'].include?(macro_name.to_s)
|
|
200
212
|
end
|
|
213
|
+
|
|
214
|
+
# When `AllCops/UseProjectIndex` is enabled, methods that override a
|
|
215
|
+
# method defined by an ancestor elsewhere in the project are not
|
|
216
|
+
# reported: renaming an override breaks the inherited contract.
|
|
217
|
+
def overrides_inherited_method?(node)
|
|
218
|
+
return false unless project_index
|
|
219
|
+
return false unless (namespace_node = node.each_ancestor(:class, :module).first)
|
|
220
|
+
|
|
221
|
+
declaration = resolve_constant_in_index(namespace_node.identifier)
|
|
222
|
+
return false unless declaration.is_a?(Rubydex::Namespace)
|
|
223
|
+
|
|
224
|
+
scope = node.defs_type? ? indexed_singleton_of(declaration) : declaration
|
|
225
|
+
!scope.nil? && inherited_index_member?(scope, "#{node.method_name}()")
|
|
226
|
+
rescue StandardError
|
|
227
|
+
false
|
|
228
|
+
end
|
|
201
229
|
end
|
|
202
230
|
end
|
|
203
231
|
end
|
|
@@ -118,7 +118,7 @@ module RuboCop
|
|
|
118
118
|
|
|
119
119
|
# Returns the reassignment node once the exception variable is reassigned (a truthy
|
|
120
120
|
# signal to stop correcting later references), or `nil` when no reassignment is found.
|
|
121
|
-
# rubocop:disable Metrics/MethodLength
|
|
121
|
+
# rubocop:disable-next Metrics/MethodLength
|
|
122
122
|
def correct_node(corrector, node, offending_name, preferred_name)
|
|
123
123
|
return unless node
|
|
124
124
|
|
|
@@ -141,7 +141,6 @@ module RuboCop
|
|
|
141
141
|
end
|
|
142
142
|
nil
|
|
143
143
|
end
|
|
144
|
-
# rubocop:enable Metrics/MethodLength
|
|
145
144
|
|
|
146
145
|
# If the exception variable is reassigned, that assignment needs to be corrected.
|
|
147
146
|
# Further `lvar` nodes will not be corrected though since they now refer to a
|
|
@@ -132,7 +132,9 @@ module RuboCop
|
|
|
132
132
|
|
|
133
133
|
def on_sym(node)
|
|
134
134
|
@node = node
|
|
135
|
-
|
|
135
|
+
|
|
136
|
+
# Prism parses a quoted empty hash key (`{ "": value }`) as an empty symbol node.
|
|
137
|
+
return if node.value.empty? || allowed_identifier?(node.value)
|
|
136
138
|
|
|
137
139
|
check_name(node, node.value, node) if cop_config['CheckSymbols']
|
|
138
140
|
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RuboCop
|
|
4
|
+
module Cop
|
|
5
|
+
# Cops for the `Naming` department. The department's cops are registered for lazy loading
|
|
6
|
+
# and their files are loaded on demand.
|
|
7
|
+
module Naming
|
|
8
|
+
extend LazyLoader
|
|
9
|
+
|
|
10
|
+
register_cop :AccessorMethodName, "#{__dir__}/naming/accessor_method_name"
|
|
11
|
+
register_cop :AsciiIdentifiers, "#{__dir__}/naming/ascii_identifiers"
|
|
12
|
+
register_cop :BlockForwarding, "#{__dir__}/naming/block_forwarding"
|
|
13
|
+
register_cop :BlockParameterName, "#{__dir__}/naming/block_parameter_name"
|
|
14
|
+
register_cop :ClassAndModuleCamelCase, "#{__dir__}/naming/class_and_module_camel_case"
|
|
15
|
+
register_cop :ConstantName, "#{__dir__}/naming/constant_name"
|
|
16
|
+
register_cop :FileName, "#{__dir__}/naming/file_name"
|
|
17
|
+
register_cop :HeredocDelimiterCase, "#{__dir__}/naming/heredoc_delimiter_case"
|
|
18
|
+
register_cop :HeredocDelimiterNaming, "#{__dir__}/naming/heredoc_delimiter_naming"
|
|
19
|
+
register_cop :InclusiveLanguage, "#{__dir__}/naming/inclusive_language"
|
|
20
|
+
register_cop :MemoizedInstanceVariableName, "#{__dir__}/naming/memoized_instance_variable_name"
|
|
21
|
+
register_cop :MethodName, "#{__dir__}/naming/method_name"
|
|
22
|
+
register_cop :MethodParameterName, "#{__dir__}/naming/method_parameter_name"
|
|
23
|
+
register_cop :BinaryOperatorParameterName, "#{__dir__}/naming/binary_operator_parameter_name"
|
|
24
|
+
register_cop :PredicateMethod, "#{__dir__}/naming/predicate_method"
|
|
25
|
+
register_cop :PredicatePrefix, "#{__dir__}/naming/predicate_prefix"
|
|
26
|
+
register_cop :RescuedExceptionsVariableName, "#{__dir__}/naming/rescued_exceptions_variable_name"
|
|
27
|
+
register_cop :VariableName, "#{__dir__}/naming/variable_name"
|
|
28
|
+
register_cop :VariableNumber, "#{__dir__}/naming/variable_number"
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
data/lib/rubocop/cop/offense.rb
CHANGED
|
@@ -86,24 +86,43 @@ module RuboCop
|
|
|
86
86
|
|
|
87
87
|
NO_LOCATION = PseudoSourceRange.new(1, 0, '', 0, 0).freeze
|
|
88
88
|
|
|
89
|
+
# @api public
|
|
90
|
+
#
|
|
91
|
+
# @!attribute [r] justification
|
|
92
|
+
#
|
|
93
|
+
# @return [String, nil]
|
|
94
|
+
# the reason given on the directive that suppressed this offense
|
|
95
|
+
# (the text after `--`), or `nil` when the offense is not suppressed
|
|
96
|
+
# or the directive carries no reason
|
|
97
|
+
attr_reader :justification
|
|
98
|
+
|
|
89
99
|
# @api private
|
|
90
100
|
def initialize(severity, location, message, cop_name, # rubocop:disable Metrics/ParameterLists
|
|
91
|
-
status = :uncorrected, corrector = nil)
|
|
101
|
+
status = :uncorrected, corrector = nil, justification: nil)
|
|
92
102
|
@severity = RuboCop::Cop::Severity.new(severity)
|
|
93
103
|
@location = location
|
|
104
|
+
|
|
105
|
+
# Pre-compute the position eagerly because the offense is frozen and
|
|
106
|
+
# `location.line` / `location.column` are expensive to compute; sorting
|
|
107
|
+
# many offenses calls them repeatedly through `#<=>`.
|
|
108
|
+
@line = location.line
|
|
109
|
+
@column = location.column
|
|
94
110
|
@message = message.freeze
|
|
95
111
|
@cop_name = cop_name.freeze
|
|
96
112
|
@status = status
|
|
97
113
|
@corrector = corrector
|
|
114
|
+
@justification = justification.freeze
|
|
98
115
|
freeze
|
|
99
116
|
end
|
|
100
117
|
|
|
101
118
|
def marshal_dump
|
|
102
|
-
[@severity, @location, @message, @cop_name, @status]
|
|
119
|
+
[@severity, @location, @message, @cop_name, @status, @justification]
|
|
103
120
|
end
|
|
104
121
|
|
|
105
122
|
def marshal_load(array)
|
|
106
|
-
@severity, @location, @message, @cop_name, @status = array
|
|
123
|
+
@severity, @location, @message, @cop_name, @status, @justification = array
|
|
124
|
+
@line = @location.line
|
|
125
|
+
@column = @location.column
|
|
107
126
|
end
|
|
108
127
|
|
|
109
128
|
# @api public
|
|
@@ -113,8 +132,10 @@ module RuboCop
|
|
|
113
132
|
# @return [Boolean]
|
|
114
133
|
# whether this offense can be automatically corrected via autocorrect.
|
|
115
134
|
# This includes todo comments, for example when requested with `--disable-uncorrectable`.
|
|
135
|
+
# An offense suppressed by a directive comment is not correctable -
|
|
136
|
+
# autocorrect will not touch it.
|
|
116
137
|
def correctable?
|
|
117
|
-
@status != :unsupported
|
|
138
|
+
@status != :unsupported && @status != :disabled
|
|
118
139
|
end
|
|
119
140
|
|
|
120
141
|
# @api public
|
|
@@ -167,14 +188,10 @@ module RuboCop
|
|
|
167
188
|
end
|
|
168
189
|
|
|
169
190
|
# @api private
|
|
170
|
-
|
|
171
|
-
location.line
|
|
172
|
-
end
|
|
191
|
+
attr_reader :line
|
|
173
192
|
|
|
174
193
|
# @api private
|
|
175
|
-
|
|
176
|
-
location.column
|
|
177
|
-
end
|
|
194
|
+
attr_reader :column
|
|
178
195
|
|
|
179
196
|
# @api private
|
|
180
197
|
def source_line
|
|
@@ -219,6 +236,16 @@ module RuboCop
|
|
|
219
236
|
column + 1
|
|
220
237
|
end
|
|
221
238
|
|
|
239
|
+
# @api private
|
|
240
|
+
#
|
|
241
|
+
# The minimum value of `real_column` is 1, so the minimum value of
|
|
242
|
+
# `real_last_column` is also 1. A non-zero `last_column` is used as is,
|
|
243
|
+
# because the 0-based end-exclusive column is the same as the 1-based
|
|
244
|
+
# column of the last character.
|
|
245
|
+
def real_last_column
|
|
246
|
+
last_column.zero? ? 1 : last_column
|
|
247
|
+
end
|
|
248
|
+
|
|
222
249
|
# @api public
|
|
223
250
|
#
|
|
224
251
|
# @return [Boolean]
|