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
|
@@ -7,7 +8,7 @@ module RuboCop
|
|
7
8
|
class SpaceAfterColon < Cop
|
8
9
|
include IfNode
|
9
10
|
|
10
|
-
MSG = 'Space missing after colon.'
|
11
|
+
MSG = 'Space missing after colon.'.freeze
|
11
12
|
|
12
13
|
def on_pair(node)
|
13
14
|
oper = node.loc.operator
|
@@ -1,21 +1,21 @@
|
|
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
|
# Checks for various control keywords missing a space after them.
|
7
8
|
class SpaceAfterControlKeyword < Cop
|
8
|
-
MSG = 'Use space after control keywords.'
|
9
|
+
MSG = 'Use space after control keywords.'.freeze
|
9
10
|
# elsif and unless are handled by on_if.
|
10
|
-
KEYWORDS = %w(if case when while until)
|
11
|
+
KEYWORDS = %w(if case when while until).freeze
|
11
12
|
|
12
13
|
def on_keyword(node)
|
13
14
|
return if node.loc.is_a?(Parser::Source::Map::Ternary)
|
14
15
|
|
15
|
-
exp = node.loc.expression
|
16
16
|
kw = node.loc.keyword
|
17
|
-
kw_offset = kw.begin_pos -
|
18
|
-
return unless
|
17
|
+
kw_offset = kw.begin_pos - node.source_range.begin_pos
|
18
|
+
return unless node.source[kw_offset..-1].start_with?(kw.source + '(')
|
19
19
|
|
20
20
|
add_offense(node, kw)
|
21
21
|
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
|
@@ -16,11 +17,11 @@ module RuboCop
|
|
16
17
|
include OnMethodDef
|
17
18
|
|
18
19
|
MSG = 'Do not put a space between a method name and the opening ' \
|
19
|
-
'parenthesis.'
|
20
|
+
'parenthesis.'.freeze
|
20
21
|
|
21
22
|
def on_method_def(_node, _method_name, args, _body)
|
22
23
|
return unless args.loc.begin && args.loc.begin.is?('(')
|
23
|
-
expr = args.
|
24
|
+
expr = args.source_range
|
24
25
|
pos_before_left_paren = Parser::Source::Range.new(expr.source_buffer,
|
25
26
|
expr.begin_pos - 1,
|
26
27
|
expr.begin_pos)
|
@@ -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,13 +13,13 @@ module RuboCop
|
|
12
13
|
# # good
|
13
14
|
# !something
|
14
15
|
class SpaceAfterNot < Cop
|
15
|
-
MSG = 'Do not leave space between `!` and its argument.'
|
16
|
+
MSG = 'Do not leave space between `!` and its argument.'.freeze
|
16
17
|
|
17
18
|
def on_send(node)
|
18
19
|
_receiver, method_name, *_args = *node
|
19
20
|
|
20
21
|
return unless method_name == :!
|
21
|
-
return unless node.
|
22
|
+
return unless node.source =~ /^!\s+\w+/
|
22
23
|
|
23
24
|
# TODO: Improve source range to highlight the redundant whitespace.
|
24
25
|
add_offense(node, :selector)
|
@@ -30,7 +31,7 @@ module RuboCop
|
|
30
31
|
space_range =
|
31
32
|
Parser::Source::Range.new(node.loc.selector.source_buffer,
|
32
33
|
node.loc.selector.end_pos,
|
33
|
-
receiver.
|
34
|
+
receiver.source_range.begin_pos)
|
34
35
|
corrector.remove(space_range)
|
35
36
|
end
|
36
37
|
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
|
@@ -24,7 +25,7 @@ module RuboCop
|
|
24
25
|
check_inside_pipes(args.children, opening_pipe, closing_pipe)
|
25
26
|
|
26
27
|
if body
|
27
|
-
check_space(closing_pipe.end_pos, body.
|
28
|
+
check_space(closing_pipe.end_pos, body.source_range.begin_pos,
|
28
29
|
closing_pipe, 'after closing `|`')
|
29
30
|
end
|
30
31
|
|
@@ -46,8 +47,8 @@ module RuboCop
|
|
46
47
|
end
|
47
48
|
|
48
49
|
def check_no_space_style_inside_pipes(args, opening_pipe, closing_pipe)
|
49
|
-
first = args.first.
|
50
|
-
last = args.last.
|
50
|
+
first = args.first.source_range
|
51
|
+
last = args.last.source_range
|
51
52
|
|
52
53
|
check_no_space(opening_pipe.end_pos, first.begin_pos,
|
53
54
|
'Space before first')
|
@@ -56,8 +57,8 @@ module RuboCop
|
|
56
57
|
end
|
57
58
|
|
58
59
|
def check_space_style_inside_pipes(args, opening_pipe, closing_pipe)
|
59
|
-
first = args.first.
|
60
|
-
last = args.last.
|
60
|
+
first = args.first.source_range
|
61
|
+
last = args.last.source_range
|
61
62
|
last_end_pos = last_end_pos_inside_pipes(last.end_pos)
|
62
63
|
|
63
64
|
check_space(opening_pipe.end_pos, first.begin_pos, first,
|
@@ -75,8 +76,8 @@ module RuboCop
|
|
75
76
|
end
|
76
77
|
|
77
78
|
def check_each_arg(args)
|
78
|
-
args.children
|
79
|
-
expr = arg.
|
79
|
+
args.children.butfirst.each do |arg|
|
80
|
+
expr = arg.source_range
|
80
81
|
check_no_space(range_with_surrounding_space(expr, :left).begin_pos,
|
81
82
|
expr.begin_pos - 1, 'Extra space before')
|
82
83
|
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
|
@@ -6,34 +7,72 @@ module RuboCop
|
|
6
7
|
# Checks that operators have space around them, except for **
|
7
8
|
# which should not have surrounding space.
|
8
9
|
class SpaceAroundOperators < Cop
|
9
|
-
|
10
|
-
|
11
|
-
TYPES.each { |t| define_method(:"on_#{t}") { |node| check(node) } }
|
10
|
+
include PrecedingFollowingAlignment
|
11
|
+
include HashNode # any_pairs_on_the_same_line?
|
12
12
|
|
13
13
|
def on_pair(node)
|
14
|
-
|
14
|
+
return unless node.loc.operator.is?('=>')
|
15
|
+
|
16
|
+
align_hash_config = config.for_cop('Style/AlignHash')
|
17
|
+
return if align_hash_config['EnforcedHashRocketStyle'] == 'table' &&
|
18
|
+
!any_pairs_on_the_same_line?(node.parent)
|
19
|
+
|
20
|
+
_, right = *node
|
21
|
+
check_operator(node.loc.operator, right.source_range)
|
15
22
|
end
|
16
23
|
|
17
24
|
def on_if(node)
|
18
25
|
return unless node.loc.respond_to?(:question)
|
26
|
+
_, if_branch, else_branch = *node
|
19
27
|
|
20
|
-
check_operator(node.loc.question)
|
21
|
-
check_operator(node.loc.colon)
|
28
|
+
check_operator(node.loc.question, if_branch.source_range)
|
29
|
+
check_operator(node.loc.colon, else_branch.source_range)
|
22
30
|
end
|
23
31
|
|
24
32
|
def on_resbody(node)
|
25
|
-
|
33
|
+
if node.loc.assoc
|
34
|
+
_, variable, = *node
|
35
|
+
check_operator(node.loc.assoc, variable.source_range)
|
36
|
+
end
|
26
37
|
end
|
27
38
|
|
28
39
|
def on_send(node)
|
29
|
-
if node.loc.operator
|
30
|
-
|
40
|
+
if node.loc.operator # aref assignment, attribute assignment
|
41
|
+
on_special_asgn(node)
|
31
42
|
elsif !unary_operation?(node) && !called_with_dot?(node)
|
32
43
|
op = node.loc.selector
|
33
|
-
|
44
|
+
if operator?(op)
|
45
|
+
_, _, right, = *node
|
46
|
+
check_operator(node.loc.selector, right.source_range)
|
47
|
+
end
|
34
48
|
end
|
35
49
|
end
|
36
50
|
|
51
|
+
def on_binary(node)
|
52
|
+
_, right, = *node
|
53
|
+
return if right.nil?
|
54
|
+
check_operator(node.loc.operator, right.source_range)
|
55
|
+
end
|
56
|
+
|
57
|
+
def on_special_asgn(node)
|
58
|
+
return unless node.loc.operator
|
59
|
+
_, _, right, = *node
|
60
|
+
check_operator(node.loc.operator, right.source_range)
|
61
|
+
end
|
62
|
+
|
63
|
+
alias on_or on_binary
|
64
|
+
alias on_and on_binary
|
65
|
+
alias on_lvasgn on_binary
|
66
|
+
alias on_masgn on_binary
|
67
|
+
alias on_casgn on_special_asgn
|
68
|
+
alias on_ivasgn on_binary
|
69
|
+
alias on_cvasgn on_binary
|
70
|
+
alias on_gvasgn on_binary
|
71
|
+
alias on_class on_binary
|
72
|
+
alias on_or_asgn on_binary
|
73
|
+
alias on_and_asgn on_binary
|
74
|
+
alias on_op_asgn on_special_asgn
|
75
|
+
|
37
76
|
private
|
38
77
|
|
39
78
|
def operator?(range)
|
@@ -41,21 +80,16 @@ module RuboCop
|
|
41
80
|
end
|
42
81
|
|
43
82
|
def unary_operation?(node)
|
44
|
-
|
45
|
-
selector
|
46
|
-
|
47
|
-
operator?(selector) && whole.begin_pos == selector.begin_pos
|
83
|
+
return unless (selector = node.loc.selector)
|
84
|
+
operator?(selector) &&
|
85
|
+
node.source_range.begin_pos == selector.begin_pos
|
48
86
|
end
|
49
87
|
|
50
88
|
def called_with_dot?(node)
|
51
89
|
node.loc.dot
|
52
90
|
end
|
53
91
|
|
54
|
-
def
|
55
|
-
check_operator(node.loc.operator) if node.loc.operator
|
56
|
-
end
|
57
|
-
|
58
|
-
def check_operator(op)
|
92
|
+
def check_operator(op, right_operand)
|
59
93
|
with_space = range_with_surrounding_space(op)
|
60
94
|
return if with_space.source.start_with?("\n")
|
61
95
|
|
@@ -65,27 +99,33 @@ module RuboCop
|
|
65
99
|
'Space around operator `**` detected.')
|
66
100
|
end
|
67
101
|
elsif with_space.source !~ /^\s.*\s$/
|
68
|
-
add_offense(with_space, op,
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
102
|
+
add_offense(with_space, op, 'Surrounding space missing for ' \
|
103
|
+
"operator `#{op.source}`.")
|
104
|
+
elsif excess_leading_space?(op, with_space)
|
105
|
+
add_offense(with_space, op, "Operator `#{op.source}` should be " \
|
106
|
+
'surrounded by a single space.')
|
107
|
+
elsif excess_trailing_space?(right_operand, with_space)
|
108
|
+
add_offense(with_space, op, "Operator `#{op.source}` should be " \
|
109
|
+
'surrounded by a single space.')
|
75
110
|
end
|
76
111
|
end
|
77
112
|
|
78
|
-
def
|
79
|
-
|
80
|
-
|
81
|
-
|
113
|
+
def excess_leading_space?(op, with_space)
|
114
|
+
with_space.source =~ /^ / &&
|
115
|
+
(!allow_for_alignment? || !aligned_with_operator?(op))
|
116
|
+
end
|
117
|
+
|
118
|
+
def excess_trailing_space?(right_operand, with_space)
|
119
|
+
with_space.source =~ / $/ &&
|
120
|
+
(!allow_for_alignment? || !aligned_with_something?(right_operand))
|
82
121
|
end
|
83
122
|
|
84
123
|
def autocorrect(range)
|
85
124
|
lambda do |corrector|
|
86
|
-
|
87
|
-
when /\*\*/
|
125
|
+
if range.source =~ /\*\*/
|
88
126
|
corrector.replace(range, '**')
|
127
|
+
elsif range.source.end_with?("\n")
|
128
|
+
corrector.replace(range, " #{range.source.strip}\n")
|
89
129
|
else
|
90
130
|
corrector.replace(range, " #{range.source.strip} ")
|
91
131
|
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
|
@@ -16,7 +17,7 @@ module RuboCop
|
|
16
17
|
# auto-correct, so reporting space issues is not useful, and it
|
17
18
|
# creates auto-correct conflicts.
|
18
19
|
if config.for_cop('Style/BlockDelimiters')['Enabled'] &&
|
19
|
-
|
20
|
+
block_length(node) > 0
|
20
21
|
return
|
21
22
|
end
|
22
23
|
|
@@ -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,7 +7,7 @@ module RuboCop
|
|
6
7
|
# This cop checks for missing space between a token and a comment on the
|
7
8
|
# same line.
|
8
9
|
class SpaceBeforeComment < Cop
|
9
|
-
MSG = 'Put a space before an end-of-line comment.'
|
10
|
+
MSG = 'Put a space before an end-of-line comment.'.freeze
|
10
11
|
|
11
12
|
def investigate(processed_source)
|
12
13
|
processed_source.tokens.each_cons(2) do |t1, t2|
|
@@ -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,13 +7,20 @@ module RuboCop
|
|
6
7
|
# Checks that exactly one space is used between a method name and the
|
7
8
|
# first argument for method calls without parentheses.
|
8
9
|
#
|
9
|
-
#
|
10
|
+
# Alternatively, extra spaces can be added to align the argument with
|
11
|
+
# something on a preceding or following line, if the AllowForAlignment
|
12
|
+
# config parameter is true.
|
10
13
|
#
|
14
|
+
# @example
|
15
|
+
# @bad
|
11
16
|
# something x
|
12
17
|
# something y, z
|
13
18
|
#
|
14
|
-
class
|
15
|
-
|
19
|
+
class SpaceBeforeFirstArg < Cop
|
20
|
+
include PrecedingFollowingAlignment
|
21
|
+
|
22
|
+
MSG = 'Put one space between the method name and ' \
|
23
|
+
'the first argument.'.freeze
|
16
24
|
|
17
25
|
def on_send(node)
|
18
26
|
return if parentheses?(node)
|
@@ -22,8 +30,9 @@ module RuboCop
|
|
22
30
|
return if operator?(method_name)
|
23
31
|
return if node.asgn_method_call?
|
24
32
|
|
25
|
-
arg1 = args.first.
|
33
|
+
arg1 = args.first.source_range
|
26
34
|
return if arg1.line > node.loc.line
|
35
|
+
return if allow_for_alignment? && aligned_with_something?(arg1)
|
27
36
|
|
28
37
|
arg1_with_space = range_with_surrounding_space(arg1, :left)
|
29
38
|
space = Parser::Source::Range.new(arg1.source_buffer,
|
@@ -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
|
# Here we check if modifier keywords are preceded by a space.
|
7
8
|
class SpaceBeforeModifierKeyword < Cop
|
8
|
-
MSG = 'Put a space before the modifier keyword.'
|
9
|
+
MSG = 'Put a space before the modifier keyword.'.freeze
|
9
10
|
|
10
11
|
def on_if(node)
|
11
12
|
return unless modifier?(node)
|
@@ -15,8 +16,8 @@ module RuboCop
|
|
15
16
|
left_of_kw = Parser::Source::Range.new(kw.source_buffer, b - 1, b)
|
16
17
|
add_offense(node, left_of_kw) unless left_of_kw.is?(' ')
|
17
18
|
end
|
18
|
-
|
19
|
-
|
19
|
+
alias on_while on_if
|
20
|
+
alias on_until on_if
|
20
21
|
|
21
22
|
private
|
22
23
|
|
@@ -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
|
# auto-correct, so reporting space issues is not useful, and it
|
20
21
|
# creates auto-correct conflicts.
|
21
22
|
if config.for_cop('Style/BlockDelimiters')['Enabled'] &&
|
22
|
-
|
23
|
+
block_length(node) > 0
|
23
24
|
return
|
24
25
|
end
|
25
26
|
|
@@ -32,7 +33,7 @@ module RuboCop
|
|
32
33
|
private
|
33
34
|
|
34
35
|
def check_inside(node, left_brace, right_brace)
|
35
|
-
sb = node.
|
36
|
+
sb = node.source_range.source_buffer
|
36
37
|
|
37
38
|
if left_brace.end_pos == right_brace.begin_pos
|
38
39
|
adjacent_braces(sb, left_brace, right_brace)
|