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
data/config/disabled.yml
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# These are all the cops that are disabled in the default configuration.
|
2
2
|
|
3
|
+
# By default, the rails cops are not run. Override in project or home
|
4
|
+
# directory .rubocop.yml files, or by giving the -R/--rails option.
|
5
|
+
Rails:
|
6
|
+
Enabled: false
|
7
|
+
|
3
8
|
Style/AutoResourceCleanup:
|
4
9
|
Description: 'Suggests the usage of an auto resource cleanup version of a method (if available).'
|
5
10
|
Enabled: false
|
@@ -18,10 +23,6 @@ Style/Encoding:
|
|
18
23
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#utf-8'
|
19
24
|
Enabled: false
|
20
25
|
|
21
|
-
Style/InlineComment:
|
22
|
-
Description: 'Avoid inline comments.'
|
23
|
-
Enabled: false
|
24
|
-
|
25
26
|
Style/FirstArrayElementLineBreak:
|
26
27
|
Description: >-
|
27
28
|
Checks for a line break before the first element in a
|
@@ -46,6 +47,10 @@ Style/FirstMethodParameterLineBreak:
|
|
46
47
|
multi-line method parameter definition.
|
47
48
|
Enabled: false
|
48
49
|
|
50
|
+
Style/InlineComment:
|
51
|
+
Description: 'Avoid inline comments.'
|
52
|
+
Enabled: false
|
53
|
+
|
49
54
|
Style/MethodCalledOnDoEndBlock:
|
50
55
|
Description: 'Avoid chaining a method call on a do...end block.'
|
51
56
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#single-line-blocks'
|
@@ -68,8 +73,16 @@ Style/MissingElse:
|
|
68
73
|
- case
|
69
74
|
- both
|
70
75
|
|
71
|
-
Style/
|
72
|
-
Description:
|
76
|
+
Style/MultilineArrayBraceLayout:
|
77
|
+
Description: >-
|
78
|
+
Checks that the closing brace in an array literal is
|
79
|
+
symmetrical with respect to the opening brace and the
|
80
|
+
array elements.
|
81
|
+
Enabled: false
|
82
|
+
|
83
|
+
Style/MultilineAssignmentLayout:
|
84
|
+
Description: 'Check for a newline after the assignment operator in multi-line assignments.'
|
85
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#indent-conditional-assignment'
|
73
86
|
Enabled: false
|
74
87
|
|
75
88
|
Style/OptionHash:
|
data/config/enabled.yml
CHANGED
@@ -153,6 +153,16 @@ Style/CommentIndentation:
|
|
153
153
|
Description: 'Indentation of comments.'
|
154
154
|
Enabled: true
|
155
155
|
|
156
|
+
Style/ConditionalAssignment:
|
157
|
+
Description: >-
|
158
|
+
Use the return value of `if` and `case` statements for
|
159
|
+
assignment to a variable and variable comparison instead
|
160
|
+
of assigning that variable inside of each branch.
|
161
|
+
Enabled: true
|
162
|
+
SingleLineConditionsOnly: true
|
163
|
+
# Whether the cop should register offenses for conditionals whose branches
|
164
|
+
# contain more than one statement a piece
|
165
|
+
|
156
166
|
Style/ConstantName:
|
157
167
|
Description: 'Constants should use SCREAMING_SNAKE_CASE.'
|
158
168
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#screaming-snake-case'
|
@@ -255,6 +265,12 @@ Style/FileName:
|
|
255
265
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#snake-case-files'
|
256
266
|
Enabled: true
|
257
267
|
|
268
|
+
Style/FrozenStringLiteralComment:
|
269
|
+
Description: >-
|
270
|
+
Add the frozen_string_literal comment to the top of files
|
271
|
+
to help transition from Ruby 2.3.0 to Ruby 3.0.
|
272
|
+
Enabled: true
|
273
|
+
|
258
274
|
Style/InitialIndentation:
|
259
275
|
Description: >-
|
260
276
|
Checks the indentation of the first non-blank non-comment line in a file.
|
@@ -297,6 +313,10 @@ Style/HashSyntax:
|
|
297
313
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#hash-literals'
|
298
314
|
Enabled: true
|
299
315
|
|
316
|
+
Style/IfInsideElse:
|
317
|
+
Description: 'Finds if nodes inside else, which can be converted to elsif.'
|
318
|
+
Enabled: true
|
319
|
+
|
300
320
|
Style/IfUnlessModifier:
|
301
321
|
Description: >-
|
302
322
|
Favor modifier if/unless usage when you have a
|
@@ -318,12 +338,25 @@ Style/IndentationWidth:
|
|
318
338
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#spaces-indentation'
|
319
339
|
Enabled: true
|
320
340
|
|
341
|
+
Style/IdenticalConditionalBranches:
|
342
|
+
Description: >-
|
343
|
+
Checks that conditional statements do not have an identical
|
344
|
+
line at the end of each branch, which can validly be moved
|
345
|
+
out of the conditional.
|
346
|
+
Enabled: true
|
347
|
+
|
321
348
|
Style/IndentArray:
|
322
349
|
Description: >-
|
323
350
|
Checks the indentation of the first element in an array
|
324
351
|
literal.
|
325
352
|
Enabled: true
|
326
353
|
|
354
|
+
Style/IndentAssignment:
|
355
|
+
Description: >-
|
356
|
+
Checks the indentation of the first line of the
|
357
|
+
right-hand-side of a multi-line assignment.
|
358
|
+
Enabled: true
|
359
|
+
|
327
360
|
Style/IndentHash:
|
328
361
|
Description: 'Checks the indentation of the first key in a hash literal.'
|
329
362
|
Enabled: true
|
@@ -390,6 +423,12 @@ Style/MultilineIfThen:
|
|
390
423
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-then'
|
391
424
|
Enabled: true
|
392
425
|
|
426
|
+
Style/MultilineMethodCallIndentation:
|
427
|
+
Description: >-
|
428
|
+
Checks indentation of method calls with the dot operator
|
429
|
+
that span more than one line.
|
430
|
+
Enabled: true
|
431
|
+
|
393
432
|
Style/MultilineOperationIndentation:
|
394
433
|
Description: >-
|
395
434
|
Checks indentation of binary operations that span more than
|
@@ -403,6 +442,10 @@ Style/MultilineTernaryOperator:
|
|
403
442
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-multiline-ternary'
|
404
443
|
Enabled: true
|
405
444
|
|
445
|
+
Style/MutableConstant:
|
446
|
+
Description: 'Do not assign mutable objects to constants.'
|
447
|
+
Enabled: true
|
448
|
+
|
406
449
|
Style/NegatedIf:
|
407
450
|
Description: >-
|
408
451
|
Favor unless over if for negative conditions
|
@@ -417,6 +460,13 @@ Style/NegatedWhile:
|
|
417
460
|
|
418
461
|
Style/NestedModifier:
|
419
462
|
Description: 'Avoid using nested modifiers.'
|
463
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-modifiers'
|
464
|
+
Enabled: true
|
465
|
+
|
466
|
+
Style/NestedParenthesizedCalls:
|
467
|
+
Description: >-
|
468
|
+
Parenthesize method calls which are nested inside the
|
469
|
+
argument list of another parenthesized method call.
|
420
470
|
Enabled: true
|
421
471
|
|
422
472
|
Style/NestedTernaryOperator:
|
@@ -528,6 +578,10 @@ Style/RedundantFreeze:
|
|
528
578
|
Description: "Checks usages of Object#freeze on immutable objects."
|
529
579
|
Enabled: true
|
530
580
|
|
581
|
+
Style/RedundantParentheses:
|
582
|
+
Description: "Checks for parentheses that seem not to serve any purpose."
|
583
|
+
Enabled: true
|
584
|
+
|
531
585
|
Style/RedundantReturn:
|
532
586
|
Description: "Don't use return where it's not required."
|
533
587
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-explicit-return'
|
@@ -579,7 +633,7 @@ Style/SingleLineMethods:
|
|
579
633
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-single-line-methods'
|
580
634
|
Enabled: true
|
581
635
|
|
582
|
-
Style/
|
636
|
+
Style/SpaceBeforeFirstArg:
|
583
637
|
Description: >-
|
584
638
|
Checks that exactly one space is used between a method name
|
585
639
|
and the first argument for method calls without parentheses.
|
@@ -733,8 +787,13 @@ Style/TrailingBlankLines:
|
|
733
787
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#newline-eof'
|
734
788
|
Enabled: true
|
735
789
|
|
736
|
-
Style/
|
737
|
-
Description: 'Checks for trailing comma in
|
790
|
+
Style/TrailingCommaInArguments:
|
791
|
+
Description: 'Checks for trailing comma in argument lists.'
|
792
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
|
793
|
+
Enabled: true
|
794
|
+
|
795
|
+
Style/TrailingCommaInLiteral:
|
796
|
+
Description: 'Checks for trailing comma in array and hash literals.'
|
738
797
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
|
739
798
|
Enabled: true
|
740
799
|
|
@@ -759,6 +818,10 @@ Style/UnneededCapitalW:
|
|
759
818
|
Description: 'Checks for %W when interpolation is not needed.'
|
760
819
|
Enabled: true
|
761
820
|
|
821
|
+
Style/UnneededInterpolation:
|
822
|
+
Description: 'Checks for strings that are just an interpolated expression.'
|
823
|
+
Enabled: true
|
824
|
+
|
762
825
|
Style/UnneededPercentQ:
|
763
826
|
Description: 'Checks for %q/%Q when single quotes or double quotes would do.'
|
764
827
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-q'
|
@@ -903,7 +966,7 @@ Lint/DeprecatedClassMethods:
|
|
903
966
|
Enabled: true
|
904
967
|
|
905
968
|
Lint/DuplicateMethods:
|
906
|
-
Description: 'Check for duplicate
|
969
|
+
Description: 'Check for duplicate method definitions.'
|
907
970
|
Enabled: true
|
908
971
|
|
909
972
|
Lint/DuplicatedKey:
|
@@ -943,6 +1006,12 @@ Lint/Eval:
|
|
943
1006
|
Description: 'The use of eval represents a serious security risk.'
|
944
1007
|
Enabled: true
|
945
1008
|
|
1009
|
+
Lint/FloatOutOfRange:
|
1010
|
+
Description: >-
|
1011
|
+
Catches floating-point literals too large or small for Ruby to
|
1012
|
+
represent.
|
1013
|
+
Enabled: true
|
1014
|
+
|
946
1015
|
Lint/FormatParameterMismatch:
|
947
1016
|
Description: 'The number of parameters to format/sprint must match the fields.'
|
948
1017
|
Enabled: true
|
@@ -952,6 +1021,18 @@ Lint/HandleExceptions:
|
|
952
1021
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions'
|
953
1022
|
Enabled: true
|
954
1023
|
|
1024
|
+
Lint/ImplicitStringConcatenation:
|
1025
|
+
Description: >-
|
1026
|
+
Checks for adjacent string literals on the same line, which
|
1027
|
+
could better be represented as a single string literal.
|
1028
|
+
Enabled: true
|
1029
|
+
|
1030
|
+
Lint/IneffectiveAccessModifier:
|
1031
|
+
Description: >-
|
1032
|
+
Checks for attempts to use `private` or `protected` to set
|
1033
|
+
the visibility of a class method, which does not work.
|
1034
|
+
Enabled: true
|
1035
|
+
|
955
1036
|
Lint/InvalidCharacterLiteral:
|
956
1037
|
Description: >-
|
957
1038
|
Checks for invalid character literals with a non-escaped
|
@@ -978,6 +1059,12 @@ Lint/NestedMethodDefinition:
|
|
978
1059
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-methods'
|
979
1060
|
Enabled: true
|
980
1061
|
|
1062
|
+
Lint/NextWithoutAccumulator:
|
1063
|
+
Description: >-
|
1064
|
+
Do not omit the accumulator when calling `next`
|
1065
|
+
in a `reduce`/`inject` block.
|
1066
|
+
Enabled: true
|
1067
|
+
|
981
1068
|
Lint/NonLocalExitFromIterator:
|
982
1069
|
Description: 'Do not use return in iterator to cause non-local exit.'
|
983
1070
|
Enabled: true
|
@@ -989,6 +1076,12 @@ Lint/ParenthesesAsGroupedExpression:
|
|
989
1076
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-no-spaces'
|
990
1077
|
Enabled: true
|
991
1078
|
|
1079
|
+
Lint/RandOne:
|
1080
|
+
Description: >-
|
1081
|
+
Checks for `rand(1)` calls. Such calls always return `0`
|
1082
|
+
and most likely a mistake.
|
1083
|
+
Enabled: true
|
1084
|
+
|
992
1085
|
Lint/RequireParentheses:
|
993
1086
|
Description: >-
|
994
1087
|
Use parentheses in the method call to avoid confusion
|
@@ -1006,12 +1099,6 @@ Lint/ShadowingOuterLocalVariable:
|
|
1006
1099
|
for block arguments or block local variables.
|
1007
1100
|
Enabled: true
|
1008
1101
|
|
1009
|
-
Lint/SpaceBeforeFirstArg:
|
1010
|
-
Description: >-
|
1011
|
-
Put a space between a method name and the first argument
|
1012
|
-
in a method call without parentheses.
|
1013
|
-
Enabled: true
|
1014
|
-
|
1015
1102
|
Lint/StringConversionInInterpolation:
|
1016
1103
|
Description: 'Checks for Object#to_s usage in string interpolation.'
|
1017
1104
|
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-to-s'
|
@@ -1069,6 +1156,11 @@ Lint/Void:
|
|
1069
1156
|
|
1070
1157
|
##################### Performance #############################
|
1071
1158
|
|
1159
|
+
Performance/Casecmp:
|
1160
|
+
Description: 'Use `casecmp` rather than `downcase ==`.'
|
1161
|
+
Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringcasecmp-vs-stringdowncase---code'
|
1162
|
+
Enabled: true
|
1163
|
+
|
1072
1164
|
Performance/CaseWhenSplat:
|
1073
1165
|
Description: >-
|
1074
1166
|
Place `when` conditions that use splat at the end
|
@@ -1089,6 +1181,17 @@ Performance/Detect:
|
|
1089
1181
|
Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerabledetect-vs-enumerableselectfirst-code'
|
1090
1182
|
Enabled: true
|
1091
1183
|
|
1184
|
+
Performance/DoubleStartEndWith:
|
1185
|
+
Description: >-
|
1186
|
+
Use `str.{start,end}_with?(x, ..., y, ...)`
|
1187
|
+
instead of `str.{start,end}_with?(x, ...) || str.{start,end}_with?(y, ...)`.
|
1188
|
+
Enabled: true
|
1189
|
+
|
1190
|
+
Performance/EndWith:
|
1191
|
+
Description: 'Use `end_with?` instead of a regex match anchored to the end of a string.'
|
1192
|
+
Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringmatch-vs-stringstart_withstringend_with-code-start-code-end'
|
1193
|
+
Enabled: true
|
1194
|
+
|
1092
1195
|
Performance/FixedSize:
|
1093
1196
|
Description: 'Do not compute the size of statically sized objects except in constants'
|
1094
1197
|
Enabled: true
|
@@ -1106,6 +1209,43 @@ Performance/FlatMap:
|
|
1106
1209
|
# This can be dangerous since `flat_map` will only flatten 1 level, and
|
1107
1210
|
# `flatten` without any parameters can flatten multiple levels.
|
1108
1211
|
|
1212
|
+
Performance/HashEachMethods:
|
1213
|
+
Description: >-
|
1214
|
+
Use `Hash#each_key` and `Hash#each_value` instead of
|
1215
|
+
`Hash#keys.each` and `Hash#values.each`.
|
1216
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#hash-each'
|
1217
|
+
Enabled: true
|
1218
|
+
AutoCorrect: false
|
1219
|
+
|
1220
|
+
Performance/LstripRstrip:
|
1221
|
+
Description: 'Use `strip` instead of `lstrip.rstrip`.'
|
1222
|
+
Enabled: true
|
1223
|
+
|
1224
|
+
Performance/RangeInclude:
|
1225
|
+
Description: 'Use `Range#cover?` instead of `Range#include?`.'
|
1226
|
+
Reference: 'https://github.com/JuanitoFatas/fast-ruby#cover-vs-include-code'
|
1227
|
+
Enabled: true
|
1228
|
+
|
1229
|
+
Performance/RedundantBlockCall:
|
1230
|
+
Description: 'Use `yield` instead of `block.call`.'
|
1231
|
+
Reference: 'https://github.com/JuanitoFatas/fast-ruby#proccall-vs-yield-code'
|
1232
|
+
Enabled: true
|
1233
|
+
|
1234
|
+
Performance/RedundantMatch:
|
1235
|
+
Description: >-
|
1236
|
+
Use `=~` instead of `String#match` or `Regexp#match` in a context where the
|
1237
|
+
returned `MatchData` is not needed.
|
1238
|
+
Enabled: true
|
1239
|
+
|
1240
|
+
Performance/RedundantMerge:
|
1241
|
+
Description: 'Use Hash#[]=, rather than Hash#merge! with a single key-value pair.'
|
1242
|
+
Reference: 'https://github.com/JuanitoFatas/fast-ruby#hashmerge-vs-hash-code'
|
1243
|
+
Enabled: true
|
1244
|
+
|
1245
|
+
Performance/RedundantSortBy:
|
1246
|
+
Description: 'Use `sort` instead of `sort_by { |x| x }`.'
|
1247
|
+
Enabled: true
|
1248
|
+
|
1109
1249
|
Performance/ReverseEach:
|
1110
1250
|
Description: 'Use `reverse_each` instead of `reverse.each`.'
|
1111
1251
|
Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerablereverseeach-vs-enumerablereverse_each-code'
|
@@ -1125,6 +1265,11 @@ Performance/Size:
|
|
1125
1265
|
Reference: 'https://github.com/JuanitoFatas/fast-ruby#arraycount-vs-arraysize-code'
|
1126
1266
|
Enabled: true
|
1127
1267
|
|
1268
|
+
Performance/StartWith:
|
1269
|
+
Description: 'Use `start_with?` instead of a regex match anchored to the beginning of a string.'
|
1270
|
+
Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringmatch-vs-stringstart_withstringend_with-code-start-code-end'
|
1271
|
+
Enabled: true
|
1272
|
+
|
1128
1273
|
Performance/StringReplacement:
|
1129
1274
|
Description: >-
|
1130
1275
|
Use `tr` instead of `gsub` when you are replacing the same
|
@@ -1133,6 +1278,10 @@ Performance/StringReplacement:
|
|
1133
1278
|
Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringgsub-vs-stringtr-code'
|
1134
1279
|
Enabled: true
|
1135
1280
|
|
1281
|
+
Performance/TimesMap:
|
1282
|
+
Description: 'Checks for .times.map calls.'
|
1283
|
+
Enabled: true
|
1284
|
+
|
1136
1285
|
##################### Rails ##################################
|
1137
1286
|
|
1138
1287
|
Rails/ActionFilter:
|
@@ -1145,10 +1294,6 @@ Rails/Date:
|
|
1145
1294
|
such as Date.today, Date.current etc.
|
1146
1295
|
Enabled: true
|
1147
1296
|
|
1148
|
-
Rails/DefaultScope:
|
1149
|
-
Description: 'Checks if the argument passed to default_scope is a block.'
|
1150
|
-
Enabled: true
|
1151
|
-
|
1152
1297
|
Rails/Delegate:
|
1153
1298
|
Description: 'Prefer delegate method for delegations.'
|
1154
1299
|
Enabled: true
|
data/lib/rubocop.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require 'parser
|
4
|
+
require 'parser'
|
4
5
|
require 'rainbow'
|
5
6
|
|
6
7
|
require 'English'
|
7
8
|
require 'set'
|
8
|
-
require '
|
9
|
+
require 'powerpack/array/butfirst'
|
9
10
|
require 'powerpack/enumerable/drop_last'
|
10
11
|
require 'powerpack/hash/symbolize_keys'
|
11
12
|
require 'powerpack/string/blank'
|
@@ -15,8 +16,13 @@ require 'rubocop/version'
|
|
15
16
|
|
16
17
|
require 'rubocop/path_util'
|
17
18
|
require 'rubocop/string_util'
|
19
|
+
require 'rubocop/name_similarity'
|
18
20
|
require 'rubocop/node_pattern'
|
21
|
+
require 'rubocop/ast_node/sexp'
|
19
22
|
require 'rubocop/ast_node'
|
23
|
+
require 'rubocop/ast_node/builder'
|
24
|
+
require 'rubocop/error'
|
25
|
+
require 'rubocop/warning'
|
20
26
|
|
21
27
|
require 'rubocop/cop/util'
|
22
28
|
require 'rubocop/cop/offense'
|
@@ -39,35 +45,41 @@ require 'rubocop/cop/variable_force/variable_table'
|
|
39
45
|
|
40
46
|
require 'rubocop/cop/mixin/access_modifier_node'
|
41
47
|
require 'rubocop/cop/mixin/annotation_comment'
|
48
|
+
require 'rubocop/cop/mixin/array_hash_indentation'
|
42
49
|
require 'rubocop/cop/mixin/array_syntax'
|
43
50
|
require 'rubocop/cop/mixin/autocorrect_alignment'
|
44
51
|
require 'rubocop/cop/mixin/autocorrect_unless_changing_ast'
|
45
52
|
require 'rubocop/cop/mixin/check_assignment'
|
46
53
|
require 'rubocop/cop/mixin/configurable_max'
|
47
|
-
require 'rubocop/cop/mixin/code_length'
|
48
|
-
require 'rubocop/cop/mixin/classish_length'
|
54
|
+
require 'rubocop/cop/mixin/code_length' # relies on configurable_max
|
55
|
+
require 'rubocop/cop/mixin/classish_length' # relies on code_length
|
49
56
|
require 'rubocop/cop/mixin/configurable_enforced_style'
|
50
57
|
require 'rubocop/cop/mixin/configurable_naming'
|
51
58
|
require 'rubocop/cop/mixin/empty_lines_around_body'
|
52
59
|
require 'rubocop/cop/mixin/end_keyword_alignment'
|
53
60
|
require 'rubocop/cop/mixin/first_element_line_break'
|
61
|
+
require 'rubocop/cop/mixin/hash_node'
|
54
62
|
require 'rubocop/cop/mixin/if_node'
|
55
|
-
require 'rubocop/cop/mixin/negative_conditional'
|
56
63
|
require 'rubocop/cop/mixin/on_method_def'
|
57
|
-
require 'rubocop/cop/mixin/method_complexity'
|
64
|
+
require 'rubocop/cop/mixin/method_complexity' # relies on on_method_def
|
58
65
|
require 'rubocop/cop/mixin/method_preference'
|
59
66
|
require 'rubocop/cop/mixin/min_body_length'
|
67
|
+
require 'rubocop/cop/mixin/multiline_expression_indentation'
|
68
|
+
require 'rubocop/cop/mixin/negative_conditional'
|
60
69
|
require 'rubocop/cop/mixin/on_normal_if_unless'
|
70
|
+
require 'rubocop/cop/mixin/parentheses'
|
61
71
|
require 'rubocop/cop/mixin/parser_diagnostic'
|
62
72
|
require 'rubocop/cop/mixin/percent_literal'
|
73
|
+
require 'rubocop/cop/mixin/preceding_following_alignment'
|
63
74
|
require 'rubocop/cop/mixin/safe_assignment'
|
64
|
-
require 'rubocop/cop/mixin/surrounding_space'
|
65
|
-
require 'rubocop/cop/mixin/space_inside'
|
66
75
|
require 'rubocop/cop/mixin/space_after_punctuation'
|
67
76
|
require 'rubocop/cop/mixin/space_before_punctuation'
|
77
|
+
require 'rubocop/cop/mixin/surrounding_space'
|
78
|
+
require 'rubocop/cop/mixin/space_inside' # relies on surrounding_space
|
68
79
|
require 'rubocop/cop/mixin/statement_modifier'
|
69
80
|
require 'rubocop/cop/mixin/string_help'
|
70
81
|
require 'rubocop/cop/mixin/string_literals_help'
|
82
|
+
require 'rubocop/cop/mixin/trailing_comma'
|
71
83
|
require 'rubocop/cop/mixin/unused_argument'
|
72
84
|
|
73
85
|
require 'rubocop/cop/lint/ambiguous_operator'
|
@@ -89,19 +101,23 @@ require 'rubocop/cop/lint/end_alignment'
|
|
89
101
|
require 'rubocop/cop/lint/end_in_method'
|
90
102
|
require 'rubocop/cop/lint/ensure_return'
|
91
103
|
require 'rubocop/cop/lint/eval'
|
104
|
+
require 'rubocop/cop/lint/float_out_of_range'
|
92
105
|
require 'rubocop/cop/lint/format_parameter_mismatch'
|
93
106
|
require 'rubocop/cop/lint/handle_exceptions'
|
107
|
+
require 'rubocop/cop/lint/implicit_string_concatenation'
|
108
|
+
require 'rubocop/cop/lint/ineffective_access_modifier'
|
94
109
|
require 'rubocop/cop/lint/invalid_character_literal'
|
95
110
|
require 'rubocop/cop/lint/literal_in_condition'
|
96
111
|
require 'rubocop/cop/lint/literal_in_interpolation'
|
97
112
|
require 'rubocop/cop/lint/loop'
|
98
113
|
require 'rubocop/cop/lint/nested_method_definition'
|
114
|
+
require 'rubocop/cop/lint/next_without_accumulator'
|
99
115
|
require 'rubocop/cop/lint/non_local_exit_from_iterator'
|
100
116
|
require 'rubocop/cop/lint/parentheses_as_grouped_expression'
|
117
|
+
require 'rubocop/cop/lint/rand_one'
|
101
118
|
require 'rubocop/cop/lint/require_parentheses'
|
102
119
|
require 'rubocop/cop/lint/rescue_exception'
|
103
120
|
require 'rubocop/cop/lint/shadowing_outer_local_variable'
|
104
|
-
require 'rubocop/cop/lint/space_before_first_arg'
|
105
121
|
require 'rubocop/cop/lint/string_conversion_in_interpolation'
|
106
122
|
require 'rubocop/cop/lint/syntax'
|
107
123
|
require 'rubocop/cop/lint/underscore_prefixed_variable_name'
|
@@ -116,25 +132,37 @@ require 'rubocop/cop/lint/useless_else_without_rescue'
|
|
116
132
|
require 'rubocop/cop/lint/useless_setter_call'
|
117
133
|
require 'rubocop/cop/lint/void'
|
118
134
|
|
135
|
+
require 'rubocop/cop/metrics/cyclomatic_complexity'
|
136
|
+
require 'rubocop/cop/metrics/abc_size' # relies on cyclomatic_complexity
|
119
137
|
require 'rubocop/cop/metrics/block_nesting'
|
120
138
|
require 'rubocop/cop/metrics/class_length'
|
121
|
-
require 'rubocop/cop/metrics/module_length'
|
122
|
-
require 'rubocop/cop/metrics/cyclomatic_complexity'
|
123
|
-
require 'rubocop/cop/metrics/abc_size'
|
124
139
|
require 'rubocop/cop/metrics/line_length'
|
125
140
|
require 'rubocop/cop/metrics/method_length'
|
141
|
+
require 'rubocop/cop/metrics/module_length'
|
126
142
|
require 'rubocop/cop/metrics/parameter_lists'
|
127
143
|
require 'rubocop/cop/metrics/perceived_complexity'
|
128
144
|
|
129
145
|
require 'rubocop/cop/performance/case_when_splat'
|
146
|
+
require 'rubocop/cop/performance/casecmp'
|
130
147
|
require 'rubocop/cop/performance/count'
|
131
148
|
require 'rubocop/cop/performance/detect'
|
149
|
+
require 'rubocop/cop/performance/double_start_end_with'
|
150
|
+
require 'rubocop/cop/performance/end_with'
|
132
151
|
require 'rubocop/cop/performance/fixed_size'
|
133
152
|
require 'rubocop/cop/performance/flat_map'
|
153
|
+
require 'rubocop/cop/performance/hash_each'
|
154
|
+
require 'rubocop/cop/performance/lstrip_rstrip'
|
155
|
+
require 'rubocop/cop/performance/range_include'
|
156
|
+
require 'rubocop/cop/performance/redundant_block_call'
|
157
|
+
require 'rubocop/cop/performance/redundant_match'
|
158
|
+
require 'rubocop/cop/performance/redundant_merge'
|
159
|
+
require 'rubocop/cop/performance/redundant_sort_by'
|
134
160
|
require 'rubocop/cop/performance/reverse_each'
|
135
161
|
require 'rubocop/cop/performance/sample'
|
136
162
|
require 'rubocop/cop/performance/size'
|
163
|
+
require 'rubocop/cop/performance/start_with'
|
137
164
|
require 'rubocop/cop/performance/string_replacement'
|
165
|
+
require 'rubocop/cop/performance/times_map'
|
138
166
|
|
139
167
|
require 'rubocop/cop/style/access_modifier_indentation'
|
140
168
|
require 'rubocop/cop/style/accessor_method_name'
|
@@ -151,8 +179,8 @@ require 'rubocop/cop/style/auto_resource_cleanup'
|
|
151
179
|
require 'rubocop/cop/style/bare_percent_literals'
|
152
180
|
require 'rubocop/cop/style/begin_block'
|
153
181
|
require 'rubocop/cop/style/block_comments'
|
154
|
-
require 'rubocop/cop/style/block_end_newline'
|
155
182
|
require 'rubocop/cop/style/block_delimiters'
|
183
|
+
require 'rubocop/cop/style/block_end_newline'
|
156
184
|
require 'rubocop/cop/style/braces_around_hash_parameters'
|
157
185
|
require 'rubocop/cop/style/case_equality'
|
158
186
|
require 'rubocop/cop/style/case_indentation'
|
@@ -168,8 +196,9 @@ require 'rubocop/cop/style/colon_method_call'
|
|
168
196
|
require 'rubocop/cop/style/command_literal'
|
169
197
|
require 'rubocop/cop/style/comment_annotation'
|
170
198
|
require 'rubocop/cop/style/comment_indentation'
|
171
|
-
require 'rubocop/cop/style/
|
199
|
+
require 'rubocop/cop/style/conditional_assignment'
|
172
200
|
require 'rubocop/cop/style/constant_name'
|
201
|
+
require 'rubocop/cop/style/copyright'
|
173
202
|
require 'rubocop/cop/style/def_with_parentheses'
|
174
203
|
require 'rubocop/cop/style/deprecated_hash_methods'
|
175
204
|
require 'rubocop/cop/style/documentation'
|
@@ -178,7 +207,6 @@ require 'rubocop/cop/style/double_negation'
|
|
178
207
|
require 'rubocop/cop/style/each_with_object'
|
179
208
|
require 'rubocop/cop/style/else_alignment'
|
180
209
|
require 'rubocop/cop/style/empty_else'
|
181
|
-
require 'rubocop/cop/style/missing_else'
|
182
210
|
require 'rubocop/cop/style/empty_line_between_defs'
|
183
211
|
require 'rubocop/cop/style/empty_lines'
|
184
212
|
require 'rubocop/cop/style/empty_lines_around_access_modifier'
|
@@ -201,12 +229,16 @@ require 'rubocop/cop/style/first_parameter_indentation'
|
|
201
229
|
require 'rubocop/cop/style/flip_flop'
|
202
230
|
require 'rubocop/cop/style/for'
|
203
231
|
require 'rubocop/cop/style/format_string'
|
232
|
+
require 'rubocop/cop/style/frozen_string_literal_comment'
|
204
233
|
require 'rubocop/cop/style/global_vars'
|
205
234
|
require 'rubocop/cop/style/guard_clause'
|
206
235
|
require 'rubocop/cop/style/hash_syntax'
|
236
|
+
require 'rubocop/cop/style/identical_conditional_branches'
|
237
|
+
require 'rubocop/cop/style/if_inside_else'
|
207
238
|
require 'rubocop/cop/style/if_unless_modifier'
|
208
239
|
require 'rubocop/cop/style/if_with_semicolon'
|
209
240
|
require 'rubocop/cop/style/indent_array'
|
241
|
+
require 'rubocop/cop/style/indent_assignment'
|
210
242
|
require 'rubocop/cop/style/indent_hash'
|
211
243
|
require 'rubocop/cop/style/indentation_consistency'
|
212
244
|
require 'rubocop/cop/style/indentation_width'
|
@@ -221,16 +253,21 @@ require 'rubocop/cop/style/method_call_parentheses'
|
|
221
253
|
require 'rubocop/cop/style/method_called_on_do_end_block'
|
222
254
|
require 'rubocop/cop/style/method_def_parentheses'
|
223
255
|
require 'rubocop/cop/style/method_name'
|
256
|
+
require 'rubocop/cop/style/missing_else'
|
224
257
|
require 'rubocop/cop/style/module_function'
|
258
|
+
require 'rubocop/cop/style/multiline_array_brace_layout'
|
259
|
+
require 'rubocop/cop/style/multiline_assignment_layout'
|
225
260
|
require 'rubocop/cop/style/multiline_block_chain'
|
226
261
|
require 'rubocop/cop/style/multiline_block_layout'
|
227
262
|
require 'rubocop/cop/style/multiline_if_then'
|
263
|
+
require 'rubocop/cop/style/multiline_method_call_indentation'
|
228
264
|
require 'rubocop/cop/style/multiline_operation_indentation'
|
229
265
|
require 'rubocop/cop/style/multiline_ternary_operator'
|
230
266
|
require 'rubocop/cop/style/mutable_constant'
|
231
267
|
require 'rubocop/cop/style/negated_if'
|
232
268
|
require 'rubocop/cop/style/negated_while'
|
233
269
|
require 'rubocop/cop/style/nested_modifier'
|
270
|
+
require 'rubocop/cop/style/nested_parenthesized_calls'
|
234
271
|
require 'rubocop/cop/style/nested_ternary_operator'
|
235
272
|
require 'rubocop/cop/style/next'
|
236
273
|
require 'rubocop/cop/style/nil_comparison'
|
@@ -239,8 +276,8 @@ require 'rubocop/cop/style/not'
|
|
239
276
|
require 'rubocop/cop/style/numeric_literals'
|
240
277
|
require 'rubocop/cop/style/one_line_conditional'
|
241
278
|
require 'rubocop/cop/style/op_method'
|
242
|
-
require 'rubocop/cop/style/optional_arguments'
|
243
279
|
require 'rubocop/cop/style/option_hash'
|
280
|
+
require 'rubocop/cop/style/optional_arguments'
|
244
281
|
require 'rubocop/cop/style/parallel_assignment'
|
245
282
|
require 'rubocop/cop/style/parentheses_around_condition'
|
246
283
|
require 'rubocop/cop/style/percent_literal_delimiters'
|
@@ -252,6 +289,7 @@ require 'rubocop/cop/style/raise_args'
|
|
252
289
|
require 'rubocop/cop/style/redundant_begin'
|
253
290
|
require 'rubocop/cop/style/redundant_exception'
|
254
291
|
require 'rubocop/cop/style/redundant_freeze'
|
292
|
+
require 'rubocop/cop/style/redundant_parentheses'
|
255
293
|
require 'rubocop/cop/style/redundant_return'
|
256
294
|
require 'rubocop/cop/style/redundant_self'
|
257
295
|
require 'rubocop/cop/style/regexp_literal'
|
@@ -263,7 +301,6 @@ require 'rubocop/cop/style/send'
|
|
263
301
|
require 'rubocop/cop/style/signal_exception'
|
264
302
|
require 'rubocop/cop/style/single_line_block_params'
|
265
303
|
require 'rubocop/cop/style/single_line_methods'
|
266
|
-
require 'rubocop/cop/style/single_space_before_first_arg'
|
267
304
|
require 'rubocop/cop/style/space_after_colon'
|
268
305
|
require 'rubocop/cop/style/space_after_comma'
|
269
306
|
require 'rubocop/cop/style/space_after_control_keyword'
|
@@ -276,6 +313,7 @@ require 'rubocop/cop/style/space_around_operators'
|
|
276
313
|
require 'rubocop/cop/style/space_before_block_braces'
|
277
314
|
require 'rubocop/cop/style/space_before_comma'
|
278
315
|
require 'rubocop/cop/style/space_before_comment'
|
316
|
+
require 'rubocop/cop/style/space_before_first_arg'
|
279
317
|
require 'rubocop/cop/style/space_before_modifier_keyword'
|
280
318
|
require 'rubocop/cop/style/space_before_semicolon'
|
281
319
|
require 'rubocop/cop/style/space_inside_block_braces'
|
@@ -295,13 +333,15 @@ require 'rubocop/cop/style/symbol_literal'
|
|
295
333
|
require 'rubocop/cop/style/symbol_proc'
|
296
334
|
require 'rubocop/cop/style/tab'
|
297
335
|
require 'rubocop/cop/style/trailing_blank_lines'
|
298
|
-
require 'rubocop/cop/style/
|
336
|
+
require 'rubocop/cop/style/trailing_comma_in_arguments'
|
337
|
+
require 'rubocop/cop/style/trailing_comma_in_literal'
|
338
|
+
require 'rubocop/cop/style/trailing_underscore_variable'
|
299
339
|
require 'rubocop/cop/style/trailing_whitespace'
|
300
340
|
require 'rubocop/cop/style/trivial_accessors'
|
301
341
|
require 'rubocop/cop/style/unless_else'
|
302
342
|
require 'rubocop/cop/style/unneeded_capital_w'
|
343
|
+
require 'rubocop/cop/style/unneeded_interpolation'
|
303
344
|
require 'rubocop/cop/style/unneeded_percent_q'
|
304
|
-
require 'rubocop/cop/style/trailing_underscore_variable'
|
305
345
|
require 'rubocop/cop/style/variable_interpolation'
|
306
346
|
require 'rubocop/cop/style/variable_name'
|
307
347
|
require 'rubocop/cop/style/when_then'
|
@@ -311,7 +351,6 @@ require 'rubocop/cop/style/word_array'
|
|
311
351
|
|
312
352
|
require 'rubocop/cop/rails/action_filter'
|
313
353
|
require 'rubocop/cop/rails/date'
|
314
|
-
require 'rubocop/cop/rails/default_scope'
|
315
354
|
require 'rubocop/cop/rails/delegate'
|
316
355
|
require 'rubocop/cop/rails/find_by'
|
317
356
|
require 'rubocop/cop/rails/find_each'
|
@@ -325,18 +364,21 @@ require 'rubocop/cop/rails/validation'
|
|
325
364
|
|
326
365
|
require 'rubocop/formatter/base_formatter'
|
327
366
|
require 'rubocop/formatter/simple_text_formatter'
|
328
|
-
require 'rubocop/formatter/
|
367
|
+
require 'rubocop/formatter/clang_style_formatter' # relies on simple text
|
329
368
|
require 'rubocop/formatter/disabled_config_formatter'
|
369
|
+
require 'rubocop/formatter/disabled_lines_formatter'
|
330
370
|
require 'rubocop/formatter/emacs_style_formatter'
|
331
|
-
require 'rubocop/formatter/
|
332
|
-
require 'rubocop/formatter/progress_formatter'
|
371
|
+
require 'rubocop/formatter/file_list_formatter'
|
333
372
|
require 'rubocop/formatter/fuubar_style_formatter'
|
334
|
-
require 'rubocop/formatter/json_formatter'
|
335
373
|
require 'rubocop/formatter/html_formatter'
|
336
|
-
require 'rubocop/formatter/
|
374
|
+
require 'rubocop/formatter/json_formatter'
|
337
375
|
require 'rubocop/formatter/offense_count_formatter'
|
376
|
+
require 'rubocop/formatter/progress_formatter'
|
377
|
+
require 'rubocop/formatter/worst_offenders_formatter'
|
378
|
+
|
338
379
|
require 'rubocop/formatter/formatter_set'
|
339
380
|
|
381
|
+
require 'rubocop/cached_data'
|
340
382
|
require 'rubocop/config'
|
341
383
|
require 'rubocop/config_loader'
|
342
384
|
require 'rubocop/config_store'
|
@@ -348,5 +390,4 @@ require 'rubocop/result_cache'
|
|
348
390
|
require 'rubocop/runner'
|
349
391
|
require 'rubocop/cli'
|
350
392
|
require 'rubocop/options'
|
351
|
-
require 'rubocop/warning'
|
352
393
|
require 'rubocop/remote_config'
|