rubocop 0.35.1 → 0.36.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rubocop might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +164 -0
- data/LICENSE.txt +1 -1
- data/README.md +72 -21
- data/bin/rubocop +1 -0
- data/config/default.yml +167 -18
- data/config/disabled.yml +19 -6
- data/config/enabled.yml +159 -14
- data/lib/rubocop.rb +67 -26
- data/lib/rubocop/ast_node.rb +488 -14
- data/lib/rubocop/ast_node/builder.rb +24 -0
- data/lib/rubocop/ast_node/sexp.rb +13 -0
- data/lib/rubocop/cached_data.rb +58 -0
- data/lib/rubocop/cli.rb +47 -10
- data/lib/rubocop/comment_config.rb +9 -2
- data/lib/rubocop/config.rb +99 -31
- data/lib/rubocop/config_loader.rb +23 -14
- data/lib/rubocop/config_store.rb +1 -0
- data/lib/rubocop/cop/autocorrect_logic.rb +2 -1
- data/lib/rubocop/cop/commissioner.rb +3 -5
- data/lib/rubocop/cop/cop.rb +23 -17
- data/lib/rubocop/cop/corrector.rb +25 -0
- data/lib/rubocop/cop/force.rb +1 -0
- data/lib/rubocop/cop/ignored_node.rb +3 -2
- data/lib/rubocop/cop/lint/ambiguous_operator.rb +2 -1
- data/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb +2 -1
- data/lib/rubocop/cop/lint/assignment_in_condition.rb +4 -3
- data/lib/rubocop/cop/lint/block_alignment.rb +29 -91
- data/lib/rubocop/cop/lint/circular_argument_reference.rb +2 -1
- data/lib/rubocop/cop/lint/condition_position.rb +2 -1
- data/lib/rubocop/cop/lint/debugger.rb +29 -12
- data/lib/rubocop/cop/lint/def_end_alignment.rb +16 -18
- data/lib/rubocop/cop/lint/deprecated_class_methods.rb +6 -6
- data/lib/rubocop/cop/lint/duplicate_methods.rb +98 -74
- data/lib/rubocop/cop/lint/duplicated_key.rb +3 -2
- data/lib/rubocop/cop/lint/each_with_object_argument.rb +3 -2
- data/lib/rubocop/cop/lint/else_layout.rb +2 -1
- data/lib/rubocop/cop/lint/empty_ensure.rb +2 -1
- data/lib/rubocop/cop/lint/empty_interpolation.rb +2 -1
- data/lib/rubocop/cop/lint/end_alignment.rb +77 -39
- data/lib/rubocop/cop/lint/end_in_method.rb +2 -1
- data/lib/rubocop/cop/lint/ensure_return.rb +2 -1
- data/lib/rubocop/cop/lint/eval.rb +2 -1
- data/lib/rubocop/cop/lint/float_out_of_range.rb +31 -0
- data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +14 -30
- data/lib/rubocop/cop/lint/handle_exceptions.rb +2 -1
- data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +85 -0
- data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +120 -0
- data/lib/rubocop/cop/lint/invalid_character_literal.rb +3 -1
- data/lib/rubocop/cop/lint/literal_in_condition.rb +6 -9
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +6 -9
- data/lib/rubocop/cop/lint/loop.rb +2 -1
- data/lib/rubocop/cop/lint/nested_method_definition.rb +19 -3
- data/lib/rubocop/cop/lint/next_without_accumulator.rb +38 -0
- data/lib/rubocop/cop/lint/non_local_exit_from_iterator.rb +5 -8
- data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +8 -6
- data/lib/rubocop/cop/lint/rand_one.rb +36 -0
- data/lib/rubocop/cop/lint/require_parentheses.rb +6 -5
- data/lib/rubocop/cop/lint/rescue_exception.rb +3 -2
- data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +2 -1
- data/lib/rubocop/cop/lint/string_conversion_in_interpolation.rb +6 -4
- data/lib/rubocop/cop/lint/syntax.rb +9 -5
- data/lib/rubocop/cop/lint/underscore_prefixed_variable_name.rb +3 -2
- data/lib/rubocop/cop/lint/unneeded_disable.rb +121 -18
- data/lib/rubocop/cop/lint/unreachable_code.rb +5 -4
- data/lib/rubocop/cop/lint/unused_block_argument.rb +9 -7
- data/lib/rubocop/cop/lint/unused_method_argument.rb +2 -1
- data/lib/rubocop/cop/lint/useless_access_modifier.rb +56 -29
- data/lib/rubocop/cop/lint/useless_assignment.rb +4 -16
- data/lib/rubocop/cop/lint/useless_comparison.rb +3 -2
- data/lib/rubocop/cop/lint/useless_else_without_rescue.rb +2 -1
- data/lib/rubocop/cop/lint/useless_setter_call.rb +14 -20
- data/lib/rubocop/cop/lint/void.rb +10 -11
- data/lib/rubocop/cop/metrics/abc_size.rb +3 -1
- data/lib/rubocop/cop/metrics/block_nesting.rb +2 -1
- data/lib/rubocop/cop/metrics/class_length.rb +1 -0
- data/lib/rubocop/cop/metrics/cyclomatic_complexity.rb +4 -2
- data/lib/rubocop/cop/metrics/line_length.rb +35 -13
- data/lib/rubocop/cop/metrics/method_length.rb +2 -1
- data/lib/rubocop/cop/metrics/module_length.rb +1 -0
- data/lib/rubocop/cop/metrics/parameter_lists.rb +2 -1
- data/lib/rubocop/cop/metrics/perceived_complexity.rb +4 -2
- data/lib/rubocop/cop/mixin/access_modifier_node.rb +3 -10
- data/lib/rubocop/cop/mixin/annotation_comment.rb +1 -0
- data/lib/rubocop/cop/mixin/array_hash_indentation.rb +80 -0
- data/lib/rubocop/cop/mixin/array_syntax.rb +2 -1
- data/lib/rubocop/cop/mixin/autocorrect_alignment.rb +14 -20
- data/lib/rubocop/cop/mixin/autocorrect_unless_changing_ast.rb +5 -4
- data/lib/rubocop/cop/mixin/check_assignment.rb +20 -15
- data/lib/rubocop/cop/mixin/classish_length.rb +1 -0
- data/lib/rubocop/cop/mixin/code_length.rb +1 -0
- data/lib/rubocop/cop/mixin/configurable_enforced_style.rb +17 -15
- data/lib/rubocop/cop/mixin/configurable_max.rb +1 -0
- data/lib/rubocop/cop/mixin/configurable_naming.rb +4 -0
- data/lib/rubocop/cop/mixin/empty_lines_around_body.rb +9 -4
- data/lib/rubocop/cop/mixin/end_keyword_alignment.rb +24 -16
- data/lib/rubocop/cop/mixin/first_element_line_break.rb +3 -2
- data/lib/rubocop/cop/mixin/hash_node.rb +15 -0
- data/lib/rubocop/cop/mixin/if_node.rb +1 -0
- data/lib/rubocop/cop/mixin/method_complexity.rb +1 -0
- data/lib/rubocop/cop/mixin/method_preference.rb +1 -0
- data/lib/rubocop/cop/mixin/min_body_length.rb +1 -0
- data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +177 -0
- data/lib/rubocop/cop/mixin/negative_conditional.rb +1 -0
- data/lib/rubocop/cop/mixin/on_method_def.rb +6 -5
- data/lib/rubocop/cop/mixin/on_normal_if_unless.rb +1 -0
- data/lib/rubocop/cop/mixin/parentheses.rb +22 -0
- data/lib/rubocop/cop/mixin/parser_diagnostic.rb +1 -0
- data/lib/rubocop/cop/mixin/percent_literal.rb +1 -0
- data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +79 -0
- data/lib/rubocop/cop/mixin/safe_assignment.rb +1 -0
- data/lib/rubocop/cop/mixin/space_after_punctuation.rb +2 -1
- data/lib/rubocop/cop/mixin/space_before_punctuation.rb +2 -1
- data/lib/rubocop/cop/mixin/space_inside.rb +2 -1
- data/lib/rubocop/cop/mixin/statement_modifier.rb +6 -5
- data/lib/rubocop/cop/mixin/string_help.rb +2 -9
- data/lib/rubocop/cop/mixin/string_literals_help.rb +13 -7
- data/lib/rubocop/cop/mixin/surrounding_space.rb +3 -2
- data/lib/rubocop/cop/mixin/trailing_comma.rb +134 -0
- data/lib/rubocop/cop/mixin/unused_argument.rb +1 -0
- data/lib/rubocop/cop/offense.rb +19 -14
- data/lib/rubocop/cop/performance/case_when_splat.rb +8 -8
- data/lib/rubocop/cop/performance/casecmp.rb +54 -0
- data/lib/rubocop/cop/performance/count.rb +10 -9
- data/lib/rubocop/cop/performance/detect.rb +6 -5
- data/lib/rubocop/cop/performance/double_start_end_with.rb +65 -0
- data/lib/rubocop/cop/performance/end_with.rb +55 -0
- data/lib/rubocop/cop/performance/fixed_size.rb +1 -0
- data/lib/rubocop/cop/performance/flat_map.rb +9 -8
- data/lib/rubocop/cop/performance/hash_each.rb +86 -0
- data/lib/rubocop/cop/performance/lstrip_rstrip.rb +44 -0
- data/lib/rubocop/cop/performance/range_include.rb +40 -0
- data/lib/rubocop/cop/performance/redundant_block_call.rb +57 -0
- data/lib/rubocop/cop/performance/redundant_match.rb +51 -0
- data/lib/rubocop/cop/performance/redundant_merge.rb +85 -0
- data/lib/rubocop/cop/performance/redundant_sort_by.rb +45 -0
- data/lib/rubocop/cop/performance/reverse_each.rb +3 -2
- data/lib/rubocop/cop/performance/sample.rb +6 -5
- data/lib/rubocop/cop/performance/size.rb +2 -1
- data/lib/rubocop/cop/performance/start_with.rb +58 -0
- data/lib/rubocop/cop/performance/string_replacement.rb +18 -23
- data/lib/rubocop/cop/performance/times_map.rb +49 -0
- data/lib/rubocop/cop/rails/action_filter.rb +4 -3
- data/lib/rubocop/cop/rails/date.rb +5 -4
- data/lib/rubocop/cop/rails/delegate.rb +3 -2
- data/lib/rubocop/cop/rails/find_by.rb +20 -14
- data/lib/rubocop/cop/rails/find_each.rb +23 -2
- data/lib/rubocop/cop/rails/has_and_belongs_to_many.rb +3 -2
- data/lib/rubocop/cop/rails/output.rb +4 -2
- data/lib/rubocop/cop/rails/pluralization_grammar.rb +3 -2
- data/lib/rubocop/cop/rails/read_write_attribute.rb +5 -7
- data/lib/rubocop/cop/rails/scope_args.rb +3 -2
- data/lib/rubocop/cop/rails/time_zone.rb +14 -10
- data/lib/rubocop/cop/rails/validation.rb +4 -3
- data/lib/rubocop/cop/severity.rb +8 -7
- data/lib/rubocop/cop/style/access_modifier_indentation.rb +5 -4
- data/lib/rubocop/cop/style/accessor_method_name.rb +1 -0
- data/lib/rubocop/cop/style/alias.rb +84 -24
- data/lib/rubocop/cop/style/align_array.rb +2 -1
- data/lib/rubocop/cop/style/align_hash.rb +13 -14
- data/lib/rubocop/cop/style/align_parameters.rb +3 -2
- data/lib/rubocop/cop/style/and_or.rb +9 -7
- data/lib/rubocop/cop/style/array_join.rb +5 -5
- data/lib/rubocop/cop/style/ascii_comments.rb +2 -1
- data/lib/rubocop/cop/style/ascii_identifiers.rb +2 -1
- data/lib/rubocop/cop/style/attr.rb +30 -5
- data/lib/rubocop/cop/style/auto_resource_cleanup.rb +3 -3
- data/lib/rubocop/cop/style/bare_percent_literals.rb +2 -1
- data/lib/rubocop/cop/style/begin_block.rb +2 -1
- data/lib/rubocop/cop/style/block_comments.rb +2 -1
- data/lib/rubocop/cop/style/block_delimiters.rb +10 -9
- data/lib/rubocop/cop/style/block_end_newline.rb +3 -2
- data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +9 -8
- data/lib/rubocop/cop/style/case_equality.rb +2 -1
- data/lib/rubocop/cop/style/case_indentation.rb +2 -1
- data/lib/rubocop/cop/style/character_literal.rb +11 -7
- data/lib/rubocop/cop/style/class_and_module_camel_case.rb +2 -1
- data/lib/rubocop/cop/style/class_and_module_children.rb +3 -2
- data/lib/rubocop/cop/style/class_check.rb +2 -1
- data/lib/rubocop/cop/style/class_methods.rb +2 -1
- data/lib/rubocop/cop/style/class_vars.rb +2 -1
- data/lib/rubocop/cop/style/closing_parenthesis_indentation.rb +3 -2
- data/lib/rubocop/cop/style/collection_methods.rb +2 -1
- data/lib/rubocop/cop/style/colon_method_call.rb +3 -2
- data/lib/rubocop/cop/style/command_literal.rb +8 -7
- data/lib/rubocop/cop/style/comment_annotation.rb +3 -2
- data/lib/rubocop/cop/style/comment_indentation.rb +4 -6
- data/lib/rubocop/cop/style/conditional_assignment.rb +362 -0
- data/lib/rubocop/cop/style/constant_name.rb +2 -1
- data/lib/rubocop/cop/style/copyright.rb +7 -6
- data/lib/rubocop/cop/style/def_with_parentheses.rb +2 -1
- data/lib/rubocop/cop/style/deprecated_hash_methods.rb +3 -2
- data/lib/rubocop/cop/style/documentation.rb +7 -11
- data/lib/rubocop/cop/style/dot_position.rb +3 -2
- data/lib/rubocop/cop/style/double_negation.rb +2 -1
- data/lib/rubocop/cop/style/each_with_object.rb +4 -3
- data/lib/rubocop/cop/style/else_alignment.rb +3 -2
- data/lib/rubocop/cop/style/empty_else.rb +4 -3
- data/lib/rubocop/cop/style/empty_line_between_defs.rb +2 -1
- data/lib/rubocop/cop/style/empty_lines.rb +10 -4
- data/lib/rubocop/cop/style/empty_lines_around_access_modifier.rb +13 -5
- data/lib/rubocop/cop/style/empty_lines_around_block_body.rb +7 -3
- data/lib/rubocop/cop/style/empty_lines_around_class_body.rb +6 -3
- data/lib/rubocop/cop/style/empty_lines_around_method_body.rb +4 -3
- data/lib/rubocop/cop/style/empty_lines_around_module_body.rb +4 -2
- data/lib/rubocop/cop/style/empty_literal.rb +20 -5
- data/lib/rubocop/cop/style/encoding.rb +8 -11
- data/lib/rubocop/cop/style/end_block.rb +3 -1
- data/lib/rubocop/cop/style/end_of_line.rb +2 -1
- data/lib/rubocop/cop/style/even_odd.rb +4 -3
- data/lib/rubocop/cop/style/extra_spacing.rb +110 -74
- data/lib/rubocop/cop/style/file_name.rb +103 -6
- data/lib/rubocop/cop/style/first_array_element_line_break.rb +3 -2
- data/lib/rubocop/cop/style/first_hash_element_line_break.rb +5 -6
- data/lib/rubocop/cop/style/first_method_argument_line_break.rb +14 -1
- data/lib/rubocop/cop/style/first_method_parameter_line_break.rb +2 -1
- data/lib/rubocop/cop/style/first_parameter_indentation.rb +6 -4
- data/lib/rubocop/cop/style/flip_flop.rb +2 -1
- data/lib/rubocop/cop/style/for.rb +2 -1
- data/lib/rubocop/cop/style/format_string.rb +1 -0
- data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +89 -0
- data/lib/rubocop/cop/style/global_vars.rb +2 -1
- data/lib/rubocop/cop/style/guard_clause.rb +63 -11
- data/lib/rubocop/cop/style/hash_syntax.rb +10 -10
- data/lib/rubocop/cop/style/identical_conditional_branches.rb +93 -0
- data/lib/rubocop/cop/style/if_inside_else.rb +49 -0
- data/lib/rubocop/cop/style/if_unless_modifier.rb +6 -5
- data/lib/rubocop/cop/style/if_with_semicolon.rb +2 -1
- data/lib/rubocop/cop/style/indent_array.rb +89 -38
- data/lib/rubocop/cop/style/indent_assignment.rb +43 -0
- data/lib/rubocop/cop/style/indent_hash.rb +16 -77
- data/lib/rubocop/cop/style/indentation_consistency.rb +2 -1
- data/lib/rubocop/cop/style/indentation_width.rb +11 -11
- data/lib/rubocop/cop/style/infinite_loop.rb +5 -9
- data/lib/rubocop/cop/style/initial_indentation.rb +2 -1
- data/lib/rubocop/cop/style/inline_comment.rb +2 -1
- data/lib/rubocop/cop/style/lambda.rb +14 -11
- data/lib/rubocop/cop/style/lambda_call.rb +4 -4
- data/lib/rubocop/cop/style/leading_comment_space.rb +2 -1
- data/lib/rubocop/cop/style/line_end_concatenation.rb +3 -1
- data/lib/rubocop/cop/style/method_call_parentheses.rb +9 -1
- data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +3 -2
- data/lib/rubocop/cop/style/method_def_parentheses.rb +4 -4
- data/lib/rubocop/cop/style/method_name.rb +1 -0
- data/lib/rubocop/cop/style/missing_else.rb +5 -3
- data/lib/rubocop/cop/style/module_function.rb +2 -1
- data/lib/rubocop/cop/style/multiline_array_brace_layout.rb +95 -0
- data/lib/rubocop/cop/style/multiline_assignment_layout.rb +91 -0
- data/lib/rubocop/cop/style/multiline_block_chain.rb +3 -2
- data/lib/rubocop/cop/style/multiline_block_layout.rb +11 -9
- data/lib/rubocop/cop/style/multiline_if_then.rb +1 -0
- data/lib/rubocop/cop/style/multiline_method_call_indentation.rb +137 -0
- data/lib/rubocop/cop/style/multiline_operation_indentation.rb +25 -135
- data/lib/rubocop/cop/style/multiline_ternary_operator.rb +2 -1
- data/lib/rubocop/cop/style/mutable_constant.rb +4 -5
- data/lib/rubocop/cop/style/negated_if.rb +3 -3
- data/lib/rubocop/cop/style/negated_while.rb +3 -3
- data/lib/rubocop/cop/style/nested_modifier.rb +6 -5
- data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +48 -0
- data/lib/rubocop/cop/style/nested_ternary_operator.rb +2 -1
- data/lib/rubocop/cop/style/next.rb +79 -15
- data/lib/rubocop/cop/style/nil_comparison.rb +5 -5
- data/lib/rubocop/cop/style/non_nil_check.rb +5 -5
- data/lib/rubocop/cop/style/not.rb +5 -9
- data/lib/rubocop/cop/style/numeric_literals.rb +5 -4
- data/lib/rubocop/cop/style/one_line_conditional.rb +3 -2
- data/lib/rubocop/cop/style/op_method.rb +7 -4
- data/lib/rubocop/cop/style/option_hash.rb +13 -7
- data/lib/rubocop/cop/style/optional_arguments.rb +3 -2
- data/lib/rubocop/cop/style/parallel_assignment.rb +40 -16
- data/lib/rubocop/cop/style/parentheses_around_condition.rb +3 -16
- data/lib/rubocop/cop/style/percent_literal_delimiters.rb +3 -2
- data/lib/rubocop/cop/style/percent_q_literals.rb +3 -6
- data/lib/rubocop/cop/style/perl_backrefs.rb +4 -3
- data/lib/rubocop/cop/style/predicate_name.rb +1 -0
- data/lib/rubocop/cop/style/proc.rb +3 -2
- data/lib/rubocop/cop/style/raise_args.rb +2 -1
- data/lib/rubocop/cop/style/redundant_begin.rb +2 -1
- data/lib/rubocop/cop/style/redundant_exception.rb +5 -5
- data/lib/rubocop/cop/style/redundant_freeze.rb +5 -4
- data/lib/rubocop/cop/style/redundant_parentheses.rb +80 -0
- data/lib/rubocop/cop/style/redundant_return.rb +5 -4
- data/lib/rubocop/cop/style/redundant_self.rb +7 -8
- data/lib/rubocop/cop/style/regexp_literal.rb +9 -8
- data/lib/rubocop/cop/style/rescue_ensure_alignment.rb +3 -2
- data/lib/rubocop/cop/style/rescue_modifier.rb +11 -9
- data/lib/rubocop/cop/style/self_assignment.rb +4 -5
- data/lib/rubocop/cop/style/semicolon.rb +3 -2
- data/lib/rubocop/cop/style/send.rb +3 -1
- data/lib/rubocop/cop/style/signal_exception.rb +5 -3
- data/lib/rubocop/cop/style/single_line_block_params.rb +2 -1
- data/lib/rubocop/cop/style/single_line_methods.rb +7 -7
- data/lib/rubocop/cop/style/space_after_colon.rb +2 -1
- data/lib/rubocop/cop/style/space_after_comma.rb +1 -0
- data/lib/rubocop/cop/style/space_after_control_keyword.rb +5 -5
- data/lib/rubocop/cop/style/space_after_method_name.rb +3 -2
- data/lib/rubocop/cop/style/space_after_not.rb +4 -3
- data/lib/rubocop/cop/style/space_after_semicolon.rb +1 -0
- data/lib/rubocop/cop/style/space_around_block_parameters.rb +8 -7
- data/lib/rubocop/cop/style/space_around_equals_in_parameter_default.rb +1 -0
- data/lib/rubocop/cop/style/space_around_operators.rb +72 -32
- data/lib/rubocop/cop/style/space_before_block_braces.rb +2 -1
- data/lib/rubocop/cop/style/space_before_comma.rb +1 -0
- data/lib/rubocop/cop/style/space_before_comment.rb +2 -1
- data/lib/rubocop/cop/style/{single_space_before_first_arg.rb → space_before_first_arg.rb} +13 -4
- data/lib/rubocop/cop/style/space_before_modifier_keyword.rb +4 -3
- data/lib/rubocop/cop/style/space_before_semicolon.rb +1 -0
- data/lib/rubocop/cop/style/space_inside_block_braces.rb +3 -2
- data/lib/rubocop/cop/style/space_inside_brackets.rb +1 -0
- data/lib/rubocop/cop/style/space_inside_hash_literal_braces.rb +4 -1
- data/lib/rubocop/cop/style/space_inside_parens.rb +1 -0
- data/lib/rubocop/cop/style/space_inside_range_literal.rb +5 -4
- data/lib/rubocop/cop/style/space_inside_string_interpolation.rb +8 -17
- data/lib/rubocop/cop/style/special_global_vars.rb +97 -52
- data/lib/rubocop/cop/style/stabby_lambda_parentheses.rb +16 -9
- data/lib/rubocop/cop/style/string_literals.rb +41 -1
- data/lib/rubocop/cop/style/string_literals_in_interpolation.rb +2 -1
- data/lib/rubocop/cop/style/string_methods.rb +2 -1
- data/lib/rubocop/cop/style/struct_inheritance.rb +3 -2
- data/lib/rubocop/cop/style/symbol_array.rb +74 -7
- data/lib/rubocop/cop/style/symbol_literal.rb +4 -7
- data/lib/rubocop/cop/style/symbol_proc.rb +11 -7
- data/lib/rubocop/cop/style/tab.rb +25 -2
- data/lib/rubocop/cop/style/trailing_blank_lines.rb +1 -2
- data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +45 -0
- data/lib/rubocop/cop/style/trailing_comma_in_literal.rb +56 -0
- data/lib/rubocop/cop/style/trailing_underscore_variable.rb +8 -7
- data/lib/rubocop/cop/style/trailing_whitespace.rb +2 -1
- data/lib/rubocop/cop/style/trivial_accessors.rb +18 -9
- data/lib/rubocop/cop/style/unless_else.rb +2 -1
- data/lib/rubocop/cop/style/unneeded_capital_w.rb +4 -3
- data/lib/rubocop/cop/style/unneeded_interpolation.rb +87 -0
- data/lib/rubocop/cop/style/unneeded_percent_q.rb +23 -7
- data/lib/rubocop/cop/style/variable_interpolation.rb +8 -6
- data/lib/rubocop/cop/style/variable_name.rb +1 -0
- data/lib/rubocop/cop/style/when_then.rb +2 -1
- data/lib/rubocop/cop/style/while_until_do.rb +3 -2
- data/lib/rubocop/cop/style/while_until_modifier.rb +3 -4
- data/lib/rubocop/cop/style/word_array.rb +74 -51
- data/lib/rubocop/cop/team.rb +21 -15
- data/lib/rubocop/cop/util.rb +102 -69
- data/lib/rubocop/cop/variable_force.rb +2 -1
- data/lib/rubocop/cop/variable_force/assignment.rb +2 -1
- data/lib/rubocop/cop/variable_force/locatable.rb +1 -0
- data/lib/rubocop/cop/variable_force/reference.rb +1 -0
- data/lib/rubocop/cop/variable_force/scope.rb +2 -1
- data/lib/rubocop/cop/variable_force/variable.rb +2 -1
- data/lib/rubocop/cop/variable_force/variable_table.rb +2 -1
- data/lib/rubocop/error.rb +12 -0
- data/lib/rubocop/formatter/base_formatter.rb +10 -1
- data/lib/rubocop/formatter/clang_style_formatter.rb +1 -0
- data/lib/rubocop/formatter/colorizable.rb +6 -1
- data/lib/rubocop/formatter/disabled_config_formatter.rb +29 -15
- data/lib/rubocop/formatter/disabled_lines_formatter.rb +3 -1
- data/lib/rubocop/formatter/emacs_style_formatter.rb +7 -3
- data/lib/rubocop/formatter/file_list_formatter.rb +1 -0
- data/lib/rubocop/formatter/formatter_set.rb +10 -19
- data/lib/rubocop/formatter/fuubar_style_formatter.rb +2 -1
- data/lib/rubocop/formatter/html_formatter.rb +15 -14
- data/lib/rubocop/formatter/json_formatter.rb +2 -1
- data/lib/rubocop/formatter/offense_count_formatter.rb +1 -0
- data/lib/rubocop/formatter/progress_formatter.rb +3 -3
- data/lib/rubocop/formatter/simple_text_formatter.rb +50 -17
- data/lib/rubocop/formatter/text_util.rb +8 -10
- data/lib/rubocop/formatter/worst_offenders_formatter.rb +61 -0
- data/lib/rubocop/name_similarity.rb +22 -0
- data/lib/rubocop/node_pattern.rb +126 -35
- data/lib/rubocop/options.rb +28 -19
- data/lib/rubocop/path_util.rb +1 -0
- data/lib/rubocop/processed_source.rb +41 -16
- data/lib/rubocop/rake_task.rb +6 -9
- data/lib/rubocop/remote_config.rb +1 -0
- data/lib/rubocop/result_cache.rb +60 -43
- data/lib/rubocop/runner.rb +48 -45
- data/lib/rubocop/string_util.rb +1 -0
- data/lib/rubocop/target_finder.rb +2 -1
- data/lib/rubocop/token.rb +1 -0
- data/lib/rubocop/version.rb +3 -2
- data/lib/rubocop/warning.rb +1 -0
- data/relnotes/v0.36.0.md +306 -0
- data/rubocop.gemspec +3 -9
- metadata +48 -92
- data/lib/rubocop/cop/lint/space_before_first_arg.rb +0 -44
- data/lib/rubocop/cop/rails/default_scope.rb +0 -33
- data/lib/rubocop/cop/style/trailing_comma.rb +0 -182
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require 'yaml'
|
4
5
|
require 'pathname'
|
@@ -10,18 +11,22 @@ module RuboCop
|
|
10
11
|
# during a run of the rubocop program, if files in several
|
11
12
|
# directories are inspected.
|
12
13
|
class ConfigLoader
|
13
|
-
DOTFILE = '.rubocop.yml'
|
14
|
+
DOTFILE = '.rubocop.yml'.freeze
|
14
15
|
RUBOCOP_HOME = File.realpath(File.join(File.dirname(__FILE__), '..', '..'))
|
15
16
|
DEFAULT_FILE = File.join(RUBOCOP_HOME, 'config', 'default.yml')
|
16
|
-
AUTO_GENERATED_FILE = '.rubocop_todo.yml'
|
17
|
+
AUTO_GENERATED_FILE = '.rubocop_todo.yml'.freeze
|
17
18
|
|
18
19
|
class << self
|
19
|
-
attr_accessor :debug, :auto_gen_config
|
20
|
+
attr_accessor :debug, :auto_gen_config
|
20
21
|
attr_writer :root_level # The upwards search is stopped at this level.
|
21
22
|
attr_writer :default_configuration
|
22
23
|
|
23
|
-
|
24
|
-
|
24
|
+
alias debug? debug
|
25
|
+
alias auto_gen_config? auto_gen_config
|
26
|
+
|
27
|
+
def clear_options
|
28
|
+
@debug = @auto_gen_config = @root_level = nil
|
29
|
+
end
|
25
30
|
|
26
31
|
def load_file(path)
|
27
32
|
path = File.absolute_path(path)
|
@@ -40,7 +45,7 @@ module RuboCop
|
|
40
45
|
end
|
41
46
|
|
42
47
|
config.add_missing_namespaces
|
43
|
-
config.
|
48
|
+
config.validate
|
44
49
|
config.make_excludes_absolute
|
45
50
|
config
|
46
51
|
end
|
@@ -60,9 +65,8 @@ module RuboCop
|
|
60
65
|
|
61
66
|
def base_configs(path, inherit_from)
|
62
67
|
configs = Array(inherit_from).compact.map do |f|
|
63
|
-
if f =~ URI.regexp
|
68
|
+
if f =~ /\A#{URI.regexp(%w(http https))}\z/
|
64
69
|
f = RemoteConfig.new(f).file
|
65
|
-
load_file(f)
|
66
70
|
else
|
67
71
|
f = File.expand_path(f, File.dirname(path))
|
68
72
|
|
@@ -72,8 +76,8 @@ module RuboCop
|
|
72
76
|
end
|
73
77
|
|
74
78
|
print 'Inheriting ' if debug?
|
75
|
-
load_file(f)
|
76
79
|
end
|
80
|
+
load_file(f)
|
77
81
|
end
|
78
82
|
|
79
83
|
configs.compact
|
@@ -129,7 +133,7 @@ module RuboCop
|
|
129
133
|
private
|
130
134
|
|
131
135
|
# Returns a new hash where the parameters of the given config hash have
|
132
|
-
# been replaced by
|
136
|
+
# been replaced by parameters returned by the given block.
|
133
137
|
def transform(config)
|
134
138
|
Hash[config.map { |cop, params| [cop, yield(params)] }]
|
135
139
|
end
|
@@ -174,8 +178,14 @@ module RuboCop
|
|
174
178
|
|
175
179
|
def resolve_inheritance_from_gems(hash, gems)
|
176
180
|
(gems || {}).each_pair do |gem_name, config_path|
|
181
|
+
if gem_name == 'rubocop'
|
182
|
+
fail ArgumentError,
|
183
|
+
"can't inherit configuration from the rubocop gem"
|
184
|
+
end
|
185
|
+
|
177
186
|
hash['inherit_from'] = Array(hash['inherit_from'])
|
178
|
-
|
187
|
+
# Put gem configuration first so local configuration overrides it.
|
188
|
+
hash['inherit_from'].unshift gem_config_path(gem_name, config_path)
|
179
189
|
end
|
180
190
|
end
|
181
191
|
|
@@ -204,9 +214,8 @@ module RuboCop
|
|
204
214
|
end
|
205
215
|
|
206
216
|
def old_auto_config_file_warning
|
207
|
-
|
208
|
-
|
209
|
-
exit(1)
|
217
|
+
fail RuboCop::Error, 'rubocop-todo.yml is obsolete; it must be called' \
|
218
|
+
" #{AUTO_GENERATED_FILE} instead"
|
210
219
|
end
|
211
220
|
end
|
212
221
|
end
|
data/lib/rubocop/config_store.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module RuboCop
|
4
5
|
module Cop
|
5
|
-
# This module encapsulates the logic for autocorrect
|
6
|
+
# This module encapsulates the logic for autocorrect behavior for a cop.
|
6
7
|
module AutocorrectLogic
|
7
8
|
def autocorrect?
|
8
9
|
autocorrect_requested? && support_autocorrect? && autocorrect_enabled?
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module RuboCop
|
4
5
|
module Cop
|
@@ -86,11 +87,8 @@ module RuboCop
|
|
86
87
|
def with_cop_error_handling(cop)
|
87
88
|
yield
|
88
89
|
rescue => e
|
89
|
-
if @options[:raise_error]
|
90
|
-
|
91
|
-
else
|
92
|
-
@errors[cop] << e
|
93
|
-
end
|
90
|
+
raise e if @options[:raise_error]
|
91
|
+
@errors[cop] << e
|
94
92
|
end
|
95
93
|
end
|
96
94
|
end
|
data/lib/rubocop/cop/cop.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module RuboCop
|
4
5
|
module Cop
|
5
|
-
class AmbiguousCopName <
|
6
|
+
class AmbiguousCopName < RuboCop::Error; end
|
6
7
|
|
7
8
|
# Store for all cops with helper functions
|
8
9
|
class CopStore < ::Array
|
9
10
|
# @return [Array<String>] list of types for current cops.
|
10
11
|
def types
|
11
|
-
@types
|
12
|
-
@types
|
12
|
+
@types ||= map(&:cop_type).uniq!
|
13
13
|
end
|
14
14
|
|
15
15
|
# @return [Array<Cop>] Cops for that specific type.
|
@@ -32,7 +32,8 @@ module RuboCop
|
|
32
32
|
case found_ns.size
|
33
33
|
when 0 then name # No namespace found. Deal with it later in caller.
|
34
34
|
when 1 then cop_name_with_namespace(name, origin, basename, found_ns[0])
|
35
|
-
else fail AmbiguousCopName, "`#{basename}` used in
|
35
|
+
else fail AmbiguousCopName, "Ambiguous cop name `#{basename}` used in" \
|
36
|
+
"#{origin} needs namespace qualifier."
|
36
37
|
end
|
37
38
|
end
|
38
39
|
|
@@ -65,8 +66,9 @@ module RuboCop
|
|
65
66
|
# end
|
66
67
|
# end
|
67
68
|
class Cop
|
68
|
-
extend
|
69
|
+
extend RuboCop::Sexp
|
69
70
|
extend NodePattern::Macros
|
71
|
+
include RuboCop::Sexp
|
70
72
|
include Util
|
71
73
|
include IgnoredNode
|
72
74
|
include AutocorrectLogic
|
@@ -104,8 +106,13 @@ module RuboCop
|
|
104
106
|
cop_type == :lint
|
105
107
|
end
|
106
108
|
|
107
|
-
|
108
|
-
|
109
|
+
# Returns true if the cop name or the cop namespace matches any of the
|
110
|
+
# given names.
|
111
|
+
def self.match?(given_names)
|
112
|
+
return false unless given_names
|
113
|
+
|
114
|
+
given_names.include?(cop_name) ||
|
115
|
+
given_names.include?(cop_type.to_s.capitalize)
|
109
116
|
end
|
110
117
|
|
111
118
|
def initialize(config = nil, options = nil)
|
@@ -144,15 +151,6 @@ module RuboCop
|
|
144
151
|
config['AllCops'] && config['AllCops']['ExtraDetails']
|
145
152
|
end
|
146
153
|
|
147
|
-
# Returns true if the cop name or the cop namespace matches any of the
|
148
|
-
# given names.
|
149
|
-
def self.match?(given_names)
|
150
|
-
return false unless given_names
|
151
|
-
|
152
|
-
given_names.include?(cop_name) ||
|
153
|
-
given_names.include?(cop_type.to_s.capitalize)
|
154
|
-
end
|
155
|
-
|
156
154
|
def message(_node = nil)
|
157
155
|
self.class::MSG
|
158
156
|
end
|
@@ -194,11 +192,19 @@ module RuboCop
|
|
194
192
|
hash
|
195
193
|
end
|
196
194
|
|
195
|
+
def target_ruby_version
|
196
|
+
@config['AllCops'] && @config['AllCops']['TargetRubyVersion']
|
197
|
+
end
|
198
|
+
|
199
|
+
def parse(source, path = nil)
|
200
|
+
ProcessedSource.new(source, target_ruby_version, path)
|
201
|
+
end
|
202
|
+
|
197
203
|
def cop_name
|
198
204
|
self.class.cop_name
|
199
205
|
end
|
200
206
|
|
201
|
-
|
207
|
+
alias name cop_name
|
202
208
|
|
203
209
|
def relevant_file?(file)
|
204
210
|
file_name_matches_any?(file, 'Include', true) &&
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module RuboCop
|
4
5
|
module Cop
|
@@ -79,6 +80,30 @@ module RuboCop
|
|
79
80
|
def replace(range, content)
|
80
81
|
@source_rewriter.replace(range, content)
|
81
82
|
end
|
83
|
+
|
84
|
+
# Removes `size` characters prior to the source range.
|
85
|
+
#
|
86
|
+
# @param [Parser::Source::Range] range
|
87
|
+
# @param [Integer] size
|
88
|
+
def remove_preceding(range, size)
|
89
|
+
to_remove = Parser::Source::Range.new(range.source_buffer,
|
90
|
+
range.begin_pos - size,
|
91
|
+
range.begin_pos)
|
92
|
+
@source_rewriter.remove(to_remove)
|
93
|
+
end
|
94
|
+
|
95
|
+
# Removes `size` characters from the beginning of the given range.
|
96
|
+
# If `size` is greater than the size of `range`, the removed region can
|
97
|
+
# overrun the end of `range`.
|
98
|
+
#
|
99
|
+
# @param [Parser::Source::Range] range
|
100
|
+
# @param [Integer] size
|
101
|
+
def remove_leading(range, size)
|
102
|
+
to_remove = Parser::Source::Range.new(range.source_buffer,
|
103
|
+
range.begin_pos,
|
104
|
+
range.begin_pos + size)
|
105
|
+
@source_rewriter.remove(to_remove)
|
106
|
+
end
|
82
107
|
end
|
83
108
|
end
|
84
109
|
end
|
data/lib/rubocop/cop/force.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module RuboCop
|
4
5
|
module Cop
|
@@ -10,7 +11,7 @@ module RuboCop
|
|
10
11
|
|
11
12
|
def part_of_ignored_node?(node)
|
12
13
|
ignored_nodes.map(&:loc).any? do |ignored_loc|
|
13
|
-
if ignored_loc.expression.begin_pos > node.
|
14
|
+
if ignored_loc.expression.begin_pos > node.source_range.begin_pos
|
14
15
|
next false
|
15
16
|
end
|
16
17
|
|
@@ -19,7 +20,7 @@ module RuboCop
|
|
19
20
|
else
|
20
21
|
ignored_loc.expression.end_pos
|
21
22
|
end
|
22
|
-
ignored_end_pos >= node.
|
23
|
+
ignored_end_pos >= node.source_range.end_pos
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module RuboCop
|
4
5
|
module Cop
|
@@ -31,7 +32,7 @@ module RuboCop
|
|
31
32
|
MSG_FORMAT = 'Ambiguous %{actual} operator. Parenthesize the method ' \
|
32
33
|
"arguments if it's surely a %{actual} operator, or add " \
|
33
34
|
'a whitespace to the right of the `%{operator}` if it ' \
|
34
|
-
'should be a %{possible}.'
|
35
|
+
'should be a %{possible}.'.freeze
|
35
36
|
|
36
37
|
private
|
37
38
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module RuboCop
|
4
5
|
module Cop
|
@@ -19,7 +20,7 @@ module RuboCop
|
|
19
20
|
|
20
21
|
MSG = 'Ambiguous regexp literal. Parenthesize the method arguments ' \
|
21
22
|
"if it's surely a regexp literal, or add a whitespace to the " \
|
22
|
-
'right of the `/` if it should be a division.'
|
23
|
+
'right of the `/` if it should be a division.'.freeze
|
23
24
|
|
24
25
|
private
|
25
26
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module RuboCop
|
4
5
|
module Cop
|
@@ -8,8 +9,8 @@ module RuboCop
|
|
8
9
|
class AssignmentInCondition < Cop
|
9
10
|
include SafeAssignment
|
10
11
|
|
11
|
-
MSG = 'Assignment in condition - you probably meant to use `==`.'
|
12
|
-
ASGN_TYPES = [:begin, *EQUALS_ASGN_NODES, :send]
|
12
|
+
MSG = 'Assignment in condition - you probably meant to use `==`.'.freeze
|
13
|
+
ASGN_TYPES = [:begin, *EQUALS_ASGN_NODES, :send].freeze
|
13
14
|
|
14
15
|
def on_if(node)
|
15
16
|
check(node)
|
@@ -54,7 +55,7 @@ module RuboCop
|
|
54
55
|
# return to skip all descendant nodes
|
55
56
|
return if result == :skip_children
|
56
57
|
node.children.each do |child|
|
57
|
-
traverse_node(child, types, &block) if child.is_a?(
|
58
|
+
traverse_node(child, types, &block) if child.is_a?(Node)
|
58
59
|
end
|
59
60
|
end
|
60
61
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module RuboCop
|
4
5
|
module Cop
|
@@ -12,95 +13,46 @@ module RuboCop
|
|
12
13
|
# i
|
13
14
|
# end
|
14
15
|
class BlockAlignment < Cop
|
15
|
-
|
16
|
+
MSG = '`%s` at %d, %d is not aligned with `%s` at %d, %d%s.'.freeze
|
16
17
|
|
17
|
-
|
18
|
+
def_node_matcher :block_end_align_target?, <<-PATTERN
|
19
|
+
{assignment?
|
20
|
+
splat
|
21
|
+
and
|
22
|
+
or
|
23
|
+
(send _ :<< ...)
|
24
|
+
(send equal?(%1) !:[] ...)}
|
25
|
+
PATTERN
|
18
26
|
|
19
27
|
def on_block(node)
|
20
|
-
|
21
|
-
check_block_alignment(node, node)
|
22
|
-
end
|
23
|
-
|
24
|
-
def on_and(node)
|
25
|
-
return if ignored_node?(node)
|
26
|
-
|
27
|
-
_left, right = *node
|
28
|
-
return unless right.type == :block
|
29
|
-
|
30
|
-
check_block_alignment(node, right)
|
31
|
-
ignore_node(right)
|
32
|
-
end
|
33
|
-
|
34
|
-
alias_method :on_or, :on_and
|
35
|
-
|
36
|
-
def on_op_asgn(node)
|
37
|
-
variable, _op, args = *node
|
38
|
-
check_assignment(variable, args)
|
39
|
-
end
|
40
|
-
|
41
|
-
def on_send(node)
|
42
|
-
_receiver, _method, *args = *node
|
43
|
-
check_assignment(node, args.last)
|
44
|
-
end
|
45
|
-
|
46
|
-
def on_masgn(node)
|
47
|
-
variables, args = *node
|
48
|
-
check_assignment(variables, args)
|
28
|
+
check_block_alignment(start_for_block_node(node), node)
|
49
29
|
end
|
50
30
|
|
51
31
|
private
|
52
32
|
|
53
|
-
def
|
54
|
-
|
55
|
-
|
56
|
-
block_node = find_block_node(other_node)
|
57
|
-
return unless block_node.type == :block
|
58
|
-
|
59
|
-
# If the block is an argument in a function call, align end with
|
60
|
-
# the block itself, and not with the function.
|
61
|
-
if begin_node.type == :send
|
62
|
-
_receiver, method, *_args = *begin_node
|
63
|
-
begin_node = block_node if method.to_s =~ /^\w+$/
|
64
|
-
end
|
33
|
+
def start_for_block_node(block_node)
|
34
|
+
# Which node should we align the 'end' with?
|
35
|
+
result = block_node
|
65
36
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
37
|
+
while (parent = result.parent)
|
38
|
+
break if !parent || !parent.loc
|
39
|
+
break if parent.loc.line != block_node.loc.line &&
|
40
|
+
!parent.masgn_type?
|
41
|
+
break unless block_end_align_target?(parent, result)
|
42
|
+
result = parent
|
71
43
|
end
|
72
|
-
return if ignored_node?(block_node)
|
73
44
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
def find_block_node(node)
|
79
|
-
while [:send, :lvasgn].include?(node.type)
|
80
|
-
n = case node.type
|
81
|
-
when :send
|
82
|
-
find_block_or_send_node(node) || break
|
83
|
-
when :lvasgn
|
84
|
-
_variable, value = *node
|
85
|
-
value
|
86
|
-
end
|
87
|
-
node = n if n
|
88
|
-
end
|
89
|
-
node
|
90
|
-
end
|
91
|
-
|
92
|
-
def find_block_or_send_node(send_node)
|
93
|
-
receiver, _method, args = *send_node
|
94
|
-
[receiver, args].find do |subnode|
|
95
|
-
subnode && [:block, :send].include?(subnode.type)
|
96
|
-
end
|
45
|
+
# In offense message, we want to show the assignment LHS rather than
|
46
|
+
# the entire assignment
|
47
|
+
result, = *result while result.op_asgn_type? || result.masgn_type?
|
48
|
+
result
|
97
49
|
end
|
98
50
|
|
99
51
|
def check_block_alignment(start_node, block_node)
|
100
52
|
end_loc = block_node.loc.end
|
101
53
|
return unless begins_its_line?(end_loc)
|
102
54
|
|
103
|
-
start_loc = start_node.
|
55
|
+
start_loc = start_node.source_range
|
104
56
|
return unless start_loc.column != end_loc.column
|
105
57
|
|
106
58
|
do_loc = block_node.loc.begin # Actually it's either do or {.
|
@@ -116,7 +68,7 @@ module RuboCop
|
|
116
68
|
|
117
69
|
add_offense(block_node,
|
118
70
|
end_loc,
|
119
|
-
format(MSG, end_loc.line, end_loc.column,
|
71
|
+
format(MSG, end_loc.source, end_loc.line, end_loc.column,
|
120
72
|
start_loc.source.lines.to_a.first.chomp,
|
121
73
|
start_loc.line, start_loc.column,
|
122
74
|
alt_start_msg(match, start_loc, do_loc,
|
@@ -132,19 +84,12 @@ module RuboCop
|
|
132
84
|
end
|
133
85
|
end
|
134
86
|
|
135
|
-
def message
|
136
|
-
end
|
137
|
-
|
138
|
-
def block_is_on_next_line?(begin_node, block_node)
|
139
|
-
begin_node.loc.line != block_node.loc.line
|
140
|
-
end
|
141
|
-
|
142
87
|
def autocorrect(node)
|
143
|
-
ancestor_node =
|
144
|
-
source = node.
|
88
|
+
ancestor_node = start_for_block_node(node)
|
89
|
+
source = node.source_range.source_buffer
|
145
90
|
|
146
91
|
lambda do |corrector|
|
147
|
-
start_col = (ancestor_node || node).
|
92
|
+
start_col = (ancestor_node || node).source_range.column
|
148
93
|
starting_position_of_block_end = node.loc.end.begin_pos
|
149
94
|
end_col = node.loc.end.column
|
150
95
|
|
@@ -159,13 +104,6 @@ module RuboCop
|
|
159
104
|
end
|
160
105
|
end
|
161
106
|
end
|
162
|
-
|
163
|
-
def ancestor_on_same_line(node)
|
164
|
-
node.ancestors.reverse.find do |ancestor|
|
165
|
-
next unless ancestor.loc.respond_to?(:line)
|
166
|
-
ancestor.loc.line == node.loc.line
|
167
|
-
end
|
168
|
-
end
|
169
107
|
end
|
170
108
|
end
|
171
109
|
end
|