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
|
module RuboCop
|
4
5
|
module Cop
|
@@ -13,13 +14,13 @@ module RuboCop
|
|
13
14
|
# # good
|
14
15
|
# Person = Struct.new(:first_name, :last_name)
|
15
16
|
class StructInheritance < Cop
|
16
|
-
MSG = "Don't extend an instance initialized by `Struct.new`."
|
17
|
+
MSG = "Don't extend an instance initialized by `Struct.new`.".freeze
|
17
18
|
|
18
19
|
def on_class(node)
|
19
20
|
_name, superclass, _body = *node
|
20
21
|
return unless struct_constructor?(superclass)
|
21
22
|
|
22
|
-
add_offense(node, superclass.
|
23
|
+
add_offense(node, superclass.source_range, MSG)
|
23
24
|
end
|
24
25
|
|
25
26
|
private
|
@@ -1,21 +1,88 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module RuboCop
|
4
5
|
module Cop
|
5
6
|
module Style
|
6
|
-
# This cop
|
7
|
-
#
|
7
|
+
# This cop can check for array literals made up of symbols that are not
|
8
|
+
# using the %i() syntax.
|
8
9
|
#
|
9
|
-
#
|
10
|
+
# Alternatively, it checks for symbol arrays using the %i() syntax on
|
11
|
+
# projects which do not want to use that syntax, perhaps because they
|
12
|
+
# support a version of Ruby lower than 2.0.
|
10
13
|
class SymbolArray < Cop
|
14
|
+
include ConfigurableEnforcedStyle
|
11
15
|
include ArraySyntax
|
12
16
|
|
13
|
-
|
17
|
+
PERCENT_MSG = 'Use `%i` or `%I` for an array of symbols.'.freeze
|
18
|
+
ARRAY_MSG = 'Use `[]` for an array of symbols.'.freeze
|
14
19
|
|
15
20
|
def on_array(node)
|
16
|
-
|
17
|
-
|
18
|
-
|
21
|
+
if bracketed_array_of?(:sym, node)
|
22
|
+
return if comments_in_array?(node)
|
23
|
+
return if symbols_contain_spaces?(node)
|
24
|
+
style_detected(:brackets)
|
25
|
+
add_offense(node, :expression, PERCENT_MSG) if style == :percent
|
26
|
+
elsif node.loc.begin && node.loc.begin.source =~ /\A%[iI]/
|
27
|
+
style_detected(:percent)
|
28
|
+
add_offense(node, :expression, ARRAY_MSG) if style == :brackets
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def validate_config
|
33
|
+
if style == :percent && target_ruby_version < 2.0
|
34
|
+
fail ValidationError, 'The default `percent` style for the ' \
|
35
|
+
'`Style/SymbolArray` cop is only compatible' \
|
36
|
+
' with Ruby 2.0 and up, but the target Ruby' \
|
37
|
+
" version for your project is 1.9.\nPlease " \
|
38
|
+
'either disable this cop, configure it to ' \
|
39
|
+
'use `array` style, or adjust the ' \
|
40
|
+
'`TargetRubyVersion` parameter in your ' \
|
41
|
+
'configuration.'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def comments_in_array?(node)
|
48
|
+
comments = processed_source.comments
|
49
|
+
array_range = node.source_range.to_a
|
50
|
+
|
51
|
+
comments.any? do |comment|
|
52
|
+
!(comment.loc.expression.to_a & array_range).empty?
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def symbols_contain_spaces?(node)
|
57
|
+
node.children.any? do |sym|
|
58
|
+
content, = *sym
|
59
|
+
content =~ / /
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def autocorrect(node)
|
64
|
+
syms = node.children.map { |c| c.children[0].to_s }
|
65
|
+
corrected = if style == :percent
|
66
|
+
escape = syms.any? { |s| double_quotes_required?(s) }
|
67
|
+
syms = syms.map { |s| escape_string(s) } if escape
|
68
|
+
syms = syms.map { |s| s.gsub(/\)/, '\\)') }
|
69
|
+
if escape
|
70
|
+
"%I(#{syms.join(' ')})"
|
71
|
+
else
|
72
|
+
"%i(#{syms.join(' ')})"
|
73
|
+
end
|
74
|
+
else
|
75
|
+
syms = syms.map { |s| to_symbol_literal(s) }
|
76
|
+
"[#{syms.join(', ')}]"
|
77
|
+
end
|
78
|
+
|
79
|
+
lambda do |corrector|
|
80
|
+
corrector.replace(node.source_range, corrected)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def escape_string(string)
|
85
|
+
string.inspect[1..-2].tap { |s| s.gsub!(/\\"/, '"') }
|
19
86
|
end
|
20
87
|
end
|
21
88
|
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
|
@@ -13,21 +14,17 @@ module RuboCop
|
|
13
14
|
# # good
|
14
15
|
# :symbol
|
15
16
|
class SymbolLiteral < Cop
|
16
|
-
MSG = 'Do not use strings for word-like symbol literals.'
|
17
|
+
MSG = 'Do not use strings for word-like symbol literals.'.freeze
|
17
18
|
|
18
19
|
def on_sym(node)
|
19
|
-
|
20
|
-
|
21
|
-
return unless sym_name =~ /\A:["'][A-Za-z_]\w*["']\z/
|
20
|
+
return unless node.source =~ /\A:["'][A-Za-z_]\w*["']\z/
|
22
21
|
|
23
22
|
add_offense(node, :expression)
|
24
23
|
end
|
25
24
|
|
26
25
|
def autocorrect(node)
|
27
26
|
lambda do |corrector|
|
28
|
-
|
29
|
-
corrector.replace(node.loc.expression,
|
30
|
-
current_name.delete(%q('")))
|
27
|
+
corrector.replace(node.source_range, node.source.delete(%q('")))
|
31
28
|
end
|
32
29
|
end
|
33
30
|
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,7 +13,7 @@ module RuboCop
|
|
12
13
|
# # good
|
13
14
|
# something.map(&:upcase)
|
14
15
|
class SymbolProc < Cop
|
15
|
-
MSG = 'Pass `&:%s` as an argument to `%s` instead of a block.'
|
16
|
+
MSG = 'Pass `&:%s` as an argument to `%s` instead of a block.'.freeze
|
16
17
|
|
17
18
|
PROC_NODE = s(:send, s(:const, nil, :Proc), :new)
|
18
19
|
|
@@ -35,7 +36,7 @@ module RuboCop
|
|
35
36
|
|
36
37
|
_receiver, method_name, _args = *block_body
|
37
38
|
|
38
|
-
sb = node.
|
39
|
+
sb = node.source_range.source_buffer
|
39
40
|
block_start = node.loc.begin.begin_pos
|
40
41
|
block_end = node.loc.end.end_pos
|
41
42
|
range = Parser::Source::Range.new(sb, block_start, block_end)
|
@@ -54,11 +55,10 @@ module RuboCop
|
|
54
55
|
|
55
56
|
if super?(block_send_or_super)
|
56
57
|
args = *block_send_or_super
|
57
|
-
autocorrect_method(corrector, node, args, method_name)
|
58
58
|
else
|
59
59
|
_breceiver, _bmethod_name, *args = *block_send_or_super
|
60
|
-
autocorrect_method(corrector, node, args, method_name)
|
61
60
|
end
|
61
|
+
autocorrect_method(corrector, node, args, method_name)
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
@@ -75,13 +75,17 @@ module RuboCop
|
|
75
75
|
end
|
76
76
|
|
77
77
|
def autocorrect_with_args(corrector, node, args, method_name)
|
78
|
-
|
78
|
+
arg_range = args.last.source_range
|
79
|
+
arg_range = range_with_surrounding_comma(arg_range, :right)
|
80
|
+
replacement = " &:#{method_name}"
|
81
|
+
replacement = ',' + replacement unless arg_range.source.end_with?(',')
|
82
|
+
corrector.insert_after(arg_range, replacement)
|
79
83
|
corrector.remove(block_range_with_space(node))
|
80
84
|
end
|
81
85
|
|
82
86
|
def block_range_with_space(node)
|
83
87
|
block_range =
|
84
|
-
Parser::Source::Range.new(node.
|
88
|
+
Parser::Source::Range.new(node.source_range.source_buffer,
|
85
89
|
begin_pos_for_replacement(node),
|
86
90
|
node.loc.end.end_pos)
|
87
91
|
range_with_surrounding_space(block_range, :left)
|
@@ -89,7 +93,7 @@ module RuboCop
|
|
89
93
|
|
90
94
|
def begin_pos_for_replacement(node)
|
91
95
|
block_send_or_super, _block_args, _block_body = *node
|
92
|
-
expr = block_send_or_super.
|
96
|
+
expr = block_send_or_super.source_range
|
93
97
|
|
94
98
|
if (paren_pos = (expr.source =~ /\(\s*\)$/))
|
95
99
|
expr.begin_pos + paren_pos
|
@@ -1,19 +1,24 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'set'
|
2
5
|
|
3
6
|
module RuboCop
|
4
7
|
module Cop
|
5
8
|
module Style
|
6
9
|
# This cop checks for tabs inside the source code.
|
7
10
|
class Tab < Cop
|
8
|
-
MSG = 'Tab detected.'
|
11
|
+
MSG = 'Tab detected.'.freeze
|
9
12
|
|
10
13
|
def investigate(processed_source)
|
14
|
+
str_lines = string_literal_lines(processed_source.ast)
|
15
|
+
|
11
16
|
processed_source.lines.each_with_index do |line, index|
|
12
17
|
match = line.match(/^( *)[\t ]*\t/)
|
13
18
|
next unless match
|
19
|
+
next if str_lines.include?(index + 1)
|
14
20
|
|
15
21
|
spaces = match.captures[0]
|
16
|
-
|
17
22
|
range = source_range(processed_source.buffer,
|
18
23
|
index + 1,
|
19
24
|
(spaces.length)...(match.end(0)))
|
@@ -29,6 +34,24 @@ module RuboCop
|
|
29
34
|
corrector.replace(range, range.source.gsub(/\t/, ' '))
|
30
35
|
end
|
31
36
|
end
|
37
|
+
|
38
|
+
def string_literal_lines(ast)
|
39
|
+
# which lines start inside a string literal?
|
40
|
+
return [] if ast.nil?
|
41
|
+
|
42
|
+
ast.each_node(:str, :dstr).each_with_object(Set.new) do |str, lines|
|
43
|
+
loc = str.location
|
44
|
+
|
45
|
+
str_lines = if loc.is_a?(Parser::Source::Map::Heredoc)
|
46
|
+
body = loc.heredoc_body
|
47
|
+
(body.first_line)..(body.last_line)
|
48
|
+
else
|
49
|
+
(loc.first_line + 1)..(loc.last_line)
|
50
|
+
end
|
51
|
+
|
52
|
+
lines.merge(str_lines.to_a)
|
53
|
+
end
|
54
|
+
end
|
32
55
|
end
|
33
56
|
end
|
34
57
|
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
|
@@ -42,8 +43,6 @@ module RuboCop
|
|
42
43
|
message(wanted_blank_lines, blank_lines))
|
43
44
|
end
|
44
45
|
|
45
|
-
private
|
46
|
-
|
47
46
|
def ends_in_end?(processed_source)
|
48
47
|
sb = processed_source.buffer
|
49
48
|
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Style
|
6
|
+
# This cop checks for trailing comma in argument lists.
|
7
|
+
#
|
8
|
+
# @example
|
9
|
+
# # always bad
|
10
|
+
# method(1, 2,)
|
11
|
+
#
|
12
|
+
# # good if EnforcedStyleForMultiline is consistent_comma
|
13
|
+
# method(
|
14
|
+
# 1, 2,
|
15
|
+
# 3,
|
16
|
+
# )
|
17
|
+
#
|
18
|
+
# # good if EnforcedStyleForMultiline is comma or consistent_comma
|
19
|
+
# method(
|
20
|
+
# 1,
|
21
|
+
# 2,
|
22
|
+
# )
|
23
|
+
#
|
24
|
+
# # good if EnforcedStyleForMultiline is no_comma
|
25
|
+
# method(
|
26
|
+
# 1,
|
27
|
+
# 2
|
28
|
+
# )
|
29
|
+
class TrailingCommaInArguments < Cop
|
30
|
+
include TrailingComma
|
31
|
+
|
32
|
+
def on_send(node)
|
33
|
+
_receiver, _method_name, *args = *node
|
34
|
+
return if args.empty?
|
35
|
+
# It's impossible for a method call without parentheses to have
|
36
|
+
# a trailing comma.
|
37
|
+
return unless brackets?(node)
|
38
|
+
|
39
|
+
check(node, args, 'parameter of %s method call',
|
40
|
+
args.last.source_range.end_pos, node.source_range.end_pos)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Style
|
6
|
+
# This cop checks for trailing comma in array and hash literals.
|
7
|
+
#
|
8
|
+
# @example
|
9
|
+
# # always bad
|
10
|
+
# a = [1, 2,]
|
11
|
+
#
|
12
|
+
# # good if EnforcedStyleForMultiline is consistent_comma
|
13
|
+
# a = [
|
14
|
+
# 1, 2,
|
15
|
+
# 3,
|
16
|
+
# ]
|
17
|
+
#
|
18
|
+
# # good if EnforcedStyleForMultiline is comma or consistent_comma
|
19
|
+
# a = [
|
20
|
+
# 1,
|
21
|
+
# 2,
|
22
|
+
# ]
|
23
|
+
#
|
24
|
+
# # good if EnforcedStyleForMultiline is no_comma
|
25
|
+
# a = [
|
26
|
+
# 1,
|
27
|
+
# 2
|
28
|
+
# ]
|
29
|
+
class TrailingCommaInLiteral < Cop
|
30
|
+
include ArraySyntax
|
31
|
+
include TrailingComma
|
32
|
+
|
33
|
+
def on_array(node)
|
34
|
+
check_literal(node, 'item of %s array') if square_brackets?(node)
|
35
|
+
end
|
36
|
+
|
37
|
+
def on_hash(node)
|
38
|
+
check_literal(node, 'item of %s hash')
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def check_literal(node, kind)
|
44
|
+
return if node.children.empty?
|
45
|
+
# A braceless hash is the last parameter of a method call and will be
|
46
|
+
# checked as such.
|
47
|
+
return unless brackets?(node)
|
48
|
+
|
49
|
+
check(node, node.children, kind,
|
50
|
+
node.children.last.source_range.end_pos,
|
51
|
+
node.loc.end.begin_pos)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
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
|
@@ -31,9 +32,9 @@ module RuboCop
|
|
31
32
|
return if first_offense.nil?
|
32
33
|
|
33
34
|
range =
|
34
|
-
Parser::Source::Range.new(node.
|
35
|
-
first_offense.
|
36
|
-
variables.last.
|
35
|
+
Parser::Source::Range.new(node.source_range.source_buffer,
|
36
|
+
first_offense.source_range.begin_pos,
|
37
|
+
variables.last.source_range.end_pos)
|
37
38
|
add_offense(node, range)
|
38
39
|
end
|
39
40
|
|
@@ -43,15 +44,15 @@ module RuboCop
|
|
43
44
|
first_offense = find_first_offense(variables)
|
44
45
|
|
45
46
|
end_position =
|
46
|
-
if first_offense.
|
47
|
-
right.
|
47
|
+
if first_offense.source_range == variables.first.source_range
|
48
|
+
right.source_range.begin_pos
|
48
49
|
else
|
49
50
|
node.loc.operator.begin_pos
|
50
51
|
end
|
51
52
|
|
52
53
|
range =
|
53
|
-
Parser::Source::Range.new(node.
|
54
|
-
first_offense.
|
54
|
+
Parser::Source::Range.new(node.source_range.source_buffer,
|
55
|
+
first_offense.source_range.begin_pos,
|
55
56
|
end_position)
|
56
57
|
|
57
58
|
->(corrector) { corrector.remove(range) unless range.nil? }
|
@@ -1,11 +1,12 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module RuboCop
|
4
5
|
module Cop
|
5
6
|
module Style
|
6
7
|
# This cop looks for trailing whitespace in the source code.
|
7
8
|
class TrailingWhitespace < Cop
|
8
|
-
MSG = 'Trailing whitespace detected.'
|
9
|
+
MSG = 'Trailing whitespace detected.'.freeze
|
9
10
|
|
10
11
|
def investigate(processed_source)
|
11
12
|
processed_source.lines.each_with_index do |line, index|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module RuboCop
|
4
5
|
module Cop
|
@@ -6,16 +7,16 @@ module RuboCop
|
|
6
7
|
# This cop looks for trivial reader/writer methods, that could
|
7
8
|
# have been created with the attr_* family of functions automatically.
|
8
9
|
class TrivialAccessors < Cop
|
9
|
-
MSG = 'Use `attr_%s` to define trivial %s methods.'
|
10
|
+
MSG = 'Use `attr_%s` to define trivial %s methods.'.freeze
|
10
11
|
|
11
12
|
def on_def(node)
|
12
|
-
return if
|
13
|
+
return if in_module_or_instance_eval?(node)
|
13
14
|
method_name, args, body = *node
|
14
15
|
on_method_def(node, method_name, args, body)
|
15
16
|
end
|
16
17
|
|
17
18
|
def on_defs(node)
|
18
|
-
return if
|
19
|
+
return if in_module_or_instance_eval?(node)
|
19
20
|
return if ignore_class_methods?
|
20
21
|
_scope, method_name, args, body = *node
|
21
22
|
on_method_def(node, method_name, args, body)
|
@@ -23,10 +24,18 @@ module RuboCop
|
|
23
24
|
|
24
25
|
private
|
25
26
|
|
26
|
-
def
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
def in_module_or_instance_eval?(node)
|
28
|
+
node.each_ancestor(:block, :class, :sclass, :module).each do |pnode|
|
29
|
+
case pnode.type
|
30
|
+
when :class, :sclass
|
31
|
+
return false
|
32
|
+
when :module
|
33
|
+
return true
|
34
|
+
else
|
35
|
+
return true if pnode.method_name == :instance_eval
|
36
|
+
end
|
37
|
+
end
|
38
|
+
false
|
30
39
|
end
|
31
40
|
|
32
41
|
def on_method_def(node, method_name, args, body)
|
@@ -141,7 +150,7 @@ module RuboCop
|
|
141
150
|
end
|
142
151
|
|
143
152
|
lambda do |corrector|
|
144
|
-
corrector.replace(node.
|
153
|
+
corrector.replace(node.source_range, accessor(kind, method_name))
|
145
154
|
end
|
146
155
|
end
|
147
156
|
|
@@ -155,7 +164,7 @@ module RuboCop
|
|
155
164
|
lambda do |corrector|
|
156
165
|
indent = ' ' * node.loc.column
|
157
166
|
corrector.replace(
|
158
|
-
node.
|
167
|
+
node.source_range,
|
159
168
|
['class << self',
|
160
169
|
"#{indent} #{accessor(kind, method_name)}",
|
161
170
|
"#{indent}end"].join("\n")
|