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,8 +14,8 @@ module RuboCop
|
|
13
14
|
# reassignments and properly handles varied cases such as branch, loop,
|
14
15
|
# rescue, ensure, etc.
|
15
16
|
class UselessAssignment < Cop
|
16
|
-
|
17
|
-
|
17
|
+
include NameSimilarity
|
18
|
+
MSG = 'Useless assignment to variable - `%s`.'.freeze
|
18
19
|
|
19
20
|
def join_force?(force_class)
|
20
21
|
force_class == VariableForce
|
@@ -35,7 +36,7 @@ module RuboCop
|
|
35
36
|
message = message_for_useless_assignment(assignment)
|
36
37
|
|
37
38
|
location = if assignment.regexp_named_capture?
|
38
|
-
assignment.node.children.first.
|
39
|
+
assignment.node.children.first.source_range
|
39
40
|
else
|
40
41
|
assignment.node.loc.name
|
41
42
|
end
|
@@ -77,19 +78,6 @@ module RuboCop
|
|
77
78
|
end
|
78
79
|
end
|
79
80
|
|
80
|
-
def find_similar_name(target_name, scope)
|
81
|
-
names = collect_variable_like_names(scope)
|
82
|
-
names.delete(target_name)
|
83
|
-
|
84
|
-
scores = names.each_with_object({}) do |name, hash|
|
85
|
-
score = StringUtil.similarity(target_name, name)
|
86
|
-
hash[name] = score if score >= MINIMUM_SIMILARITY_TO_SUGGEST
|
87
|
-
end
|
88
|
-
|
89
|
-
most_similar_name, _max_score = scores.max_by { |_, score| score }
|
90
|
-
most_similar_name
|
91
|
-
end
|
92
|
-
|
93
81
|
def collect_variable_like_names(scope)
|
94
82
|
names = scope.each_node.with_object(Set.new) do |node, set|
|
95
83
|
if variable_like_method_invocation?(node)
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module RuboCop
|
4
5
|
module Cop
|
@@ -9,9 +10,9 @@ module RuboCop
|
|
9
10
|
#
|
10
11
|
# x.top >= x.top
|
11
12
|
class UselessComparison < Cop
|
12
|
-
MSG = 'Comparison of something with itself detected.'
|
13
|
+
MSG = 'Comparison of something with itself detected.'.freeze
|
13
14
|
|
14
|
-
OPS = %w(== === != < > <= >= <=>)
|
15
|
+
OPS = %w(== === != < > <= >= <=>).freeze
|
15
16
|
|
16
17
|
def on_send(node)
|
17
18
|
# lambda.() does not have a selector
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module RuboCop
|
4
5
|
module Cop
|
@@ -14,7 +15,7 @@ module RuboCop
|
|
14
15
|
class UselessElseWithoutRescue < Cop
|
15
16
|
include ParserDiagnostic
|
16
17
|
|
17
|
-
MSG = '`else` without `rescue` is useless.'
|
18
|
+
MSG = '`else` without `rescue` is useless.'.freeze
|
18
19
|
|
19
20
|
private
|
20
21
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module RuboCop
|
4
5
|
module Cop
|
@@ -15,26 +16,19 @@ module RuboCop
|
|
15
16
|
class UselessSetterCall < Cop
|
16
17
|
include OnMethodDef
|
17
18
|
|
18
|
-
MSG = 'Useless setter call to local variable `%s`.'
|
19
|
+
MSG = 'Useless setter call to local variable `%s`.'.freeze
|
19
20
|
ASSIGNMENT_TYPES = [:lvasgn, :ivasgn, :cvasgn, :gvasgn].freeze
|
20
|
-
LITERAL_TYPES = [
|
21
|
-
:true, :false, :nil,
|
22
|
-
:int, :float,
|
23
|
-
:str, :dstr, :sym, :dsym, :xstr, :regexp,
|
24
|
-
:array, :hash,
|
25
|
-
:irange, :erange
|
26
|
-
].freeze
|
27
21
|
|
28
22
|
private
|
29
23
|
|
30
24
|
def on_method_def(_node, _method_name, _args, body)
|
31
25
|
return unless body
|
32
26
|
|
33
|
-
if body.type == :begin
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
27
|
+
expression = if body.type == :begin
|
28
|
+
body.children
|
29
|
+
else
|
30
|
+
body
|
31
|
+
end
|
38
32
|
|
39
33
|
last_expr = expression.is_a?(Array) ? expression.last : expression
|
40
34
|
|
@@ -136,16 +130,16 @@ module RuboCop
|
|
136
130
|
def process_assignment(asgn_node, rhs_node)
|
137
131
|
lhs_variable_name, = *asgn_node
|
138
132
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
133
|
+
@local[lhs_variable_name] = if rhs_node.variable?
|
134
|
+
rhs_variable_name, = *rhs_node
|
135
|
+
@local[rhs_variable_name]
|
136
|
+
else
|
137
|
+
constructor?(rhs_node)
|
138
|
+
end
|
145
139
|
end
|
146
140
|
|
147
141
|
def constructor?(node)
|
148
|
-
return true if
|
142
|
+
return true if node.literal?
|
149
143
|
return false unless node.type == :send
|
150
144
|
_receiver, method = *node
|
151
145
|
method == :new
|
@@ -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,14 +7,11 @@ module RuboCop
|
|
6
7
|
# This cop checks for operators, variables and literals used
|
7
8
|
# in void context.
|
8
9
|
class Void < Cop
|
9
|
-
OP_MSG = 'Operator `%s` used in void context.'
|
10
|
-
VAR_MSG = 'Variable `%s` used in void context.'
|
11
|
-
LIT_MSG = 'Literal `%s` used in void context.'
|
10
|
+
OP_MSG = 'Operator `%s` used in void context.'.freeze
|
11
|
+
VAR_MSG = 'Variable `%s` used in void context.'.freeze
|
12
|
+
LIT_MSG = 'Literal `%s` used in void context.'.freeze
|
12
13
|
|
13
|
-
OPS = %w(* / % + - == === != < > <= >= <=>)
|
14
|
-
VARS = [:ivar, :lvar, :cvar, :const]
|
15
|
-
LITERALS = [:str, :dstr, :int, :float, :array,
|
16
|
-
:hash, :regexp, :nil, :true, :false, :sym]
|
14
|
+
OPS = %w(* / % + - == === != < > <= >= <=>).freeze
|
17
15
|
|
18
16
|
def on_begin(node)
|
19
17
|
check_begin(node)
|
@@ -45,14 +43,15 @@ module RuboCop
|
|
45
43
|
end
|
46
44
|
|
47
45
|
def check_for_var(node)
|
48
|
-
return unless
|
46
|
+
return unless node.variable? || node.const_type?
|
49
47
|
add_offense(node, :name, format(VAR_MSG, node.loc.name.source))
|
50
48
|
end
|
51
49
|
|
52
50
|
def check_for_literal(node)
|
53
|
-
return unless
|
54
|
-
|
55
|
-
|
51
|
+
return unless node.literal?
|
52
|
+
return if node.xstr_type?
|
53
|
+
|
54
|
+
add_offense(node, :expression, format(LIT_MSG, node.source))
|
56
55
|
end
|
57
56
|
end
|
58
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
|
@@ -9,7 +10,8 @@ module RuboCop
|
|
9
10
|
class AbcSize < Cop
|
10
11
|
include MethodComplexity
|
11
12
|
|
12
|
-
MSG = 'Assignment Branch Condition size for %s is too high.
|
13
|
+
MSG = 'Assignment Branch Condition size for %s is too high. ' \
|
14
|
+
'[%.4g/%.4g]'.freeze
|
13
15
|
BRANCH_NODES = [:send].freeze
|
14
16
|
CONDITION_NODES = CyclomaticComplexity::COUNTED_NODES.freeze
|
15
17
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module RuboCop
|
4
5
|
module Cop
|
@@ -15,7 +16,7 @@ module RuboCop
|
|
15
16
|
NESTING_BLOCKS = [
|
16
17
|
:case, :if, :while, :while_post,
|
17
18
|
:until, :until_post, :for, :resbody
|
18
|
-
]
|
19
|
+
].freeze
|
19
20
|
|
20
21
|
def investigate(processed_source)
|
21
22
|
return unless processed_source.ast
|
@@ -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,8 +17,9 @@ module RuboCop
|
|
16
17
|
class CyclomaticComplexity < Cop
|
17
18
|
include MethodComplexity
|
18
19
|
|
19
|
-
MSG = 'Cyclomatic complexity for %s is too high. [%d/%d]'
|
20
|
-
COUNTED_NODES = [:if, :while, :until, :for,
|
20
|
+
MSG = 'Cyclomatic complexity for %s is too high. [%d/%d]'.freeze
|
21
|
+
COUNTED_NODES = [:if, :while, :until, :for,
|
22
|
+
:rescue, :when, :and, :or].freeze
|
21
23
|
|
22
24
|
private
|
23
25
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require 'uri'
|
4
5
|
|
@@ -10,12 +11,17 @@ module RuboCop
|
|
10
11
|
class LineLength < Cop
|
11
12
|
include ConfigurableMax
|
12
13
|
|
13
|
-
MSG = 'Line is too long. [%d/%d]'
|
14
|
+
MSG = 'Line is too long. [%d/%d]'.freeze
|
14
15
|
|
15
16
|
def investigate(processed_source)
|
17
|
+
heredocs = extract_heredocs(processed_source.ast) if allow_heredoc?
|
16
18
|
processed_source.lines.each_with_index do |line, index|
|
17
19
|
next unless line.length > max
|
18
20
|
|
21
|
+
if allow_heredoc?
|
22
|
+
next if line_in_whitelisted_heredoc?(heredocs, index.succ)
|
23
|
+
end
|
24
|
+
|
19
25
|
if allow_uri?
|
20
26
|
uri_range = find_excessive_uri_range(line)
|
21
27
|
next if uri_range && allowed_uri_position?(line, uri_range)
|
@@ -40,6 +46,31 @@ module RuboCop
|
|
40
46
|
cop_config['Max']
|
41
47
|
end
|
42
48
|
|
49
|
+
def allow_heredoc?
|
50
|
+
allowed_heredoc
|
51
|
+
end
|
52
|
+
|
53
|
+
def allowed_heredoc
|
54
|
+
cop_config['AllowHeredoc']
|
55
|
+
end
|
56
|
+
|
57
|
+
def extract_heredocs(ast)
|
58
|
+
return [] unless ast
|
59
|
+
ast.each_node.with_object([]) do |node, heredocs|
|
60
|
+
next unless node.location.is_a?(Parser::Source::Map::Heredoc)
|
61
|
+
body = node.location.heredoc_body
|
62
|
+
delimiter = node.location.heredoc_end.source.strip
|
63
|
+
heredocs << [body.first_line...body.last_line, delimiter]
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def line_in_whitelisted_heredoc?(heredocs, line_number)
|
68
|
+
heredocs.any? do |range, delimiter|
|
69
|
+
range.cover?(line_number) &&
|
70
|
+
(allowed_heredoc == true || allowed_heredoc.include?(delimiter))
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
43
74
|
def allow_uri?
|
44
75
|
cop_config['AllowURI']
|
45
76
|
end
|
@@ -58,18 +89,9 @@ module RuboCop
|
|
58
89
|
|
59
90
|
def match_uris(string)
|
60
91
|
matches = []
|
61
|
-
|
62
|
-
|
63
|
-
loop do
|
64
|
-
match_data = string.match(uri_regexp, unscanned_position)
|
65
|
-
break unless match_data
|
66
|
-
|
67
|
-
uri_ish_string = match_data[0]
|
68
|
-
matches << match_data if valid_uri?(uri_ish_string)
|
69
|
-
|
70
|
-
_, unscanned_position = match_data.offset(0)
|
92
|
+
string.scan(uri_regexp) do
|
93
|
+
matches << $LAST_MATCH_INFO if valid_uri?($LAST_MATCH_INFO[0])
|
71
94
|
end
|
72
|
-
|
73
95
|
matches
|
74
96
|
end
|
75
97
|
|
@@ -81,7 +103,7 @@ module RuboCop
|
|
81
103
|
end
|
82
104
|
|
83
105
|
def uri_regexp
|
84
|
-
URI.regexp(cop_config['URISchemes'])
|
106
|
+
@regexp ||= URI.regexp(cop_config['URISchemes'])
|
85
107
|
end
|
86
108
|
end
|
87
109
|
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
|
@@ -21,7 +22,7 @@ module RuboCop
|
|
21
22
|
end
|
22
23
|
|
23
24
|
def code_length(node)
|
24
|
-
lines = node.
|
25
|
+
lines = node.source.lines.to_a[1..-2] || []
|
25
26
|
|
26
27
|
lines.count { |line| !irrelevant_line(line) }
|
27
28
|
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
|
@@ -10,7 +11,7 @@ module RuboCop
|
|
10
11
|
class ParameterLists < Cop
|
11
12
|
include ConfigurableMax
|
12
13
|
|
13
|
-
MSG = 'Avoid parameter lists longer than %d parameters.'
|
14
|
+
MSG = 'Avoid parameter lists longer than %d parameters.'.freeze
|
14
15
|
|
15
16
|
def on_args(node)
|
16
17
|
count = args_count(node)
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module RuboCop
|
4
5
|
module Cop
|
@@ -30,8 +31,9 @@ module RuboCop
|
|
30
31
|
include MethodComplexity
|
31
32
|
include IfNode
|
32
33
|
|
33
|
-
MSG = 'Perceived complexity for %s is too high. [%d/%d]'
|
34
|
-
COUNTED_NODES = [:if, :case, :while, :until,
|
34
|
+
MSG = 'Perceived complexity for %s is too high. [%d/%d]'.freeze
|
35
|
+
COUNTED_NODES = [:if, :case, :while, :until,
|
36
|
+
:for, :rescue, :and, :or].freeze
|
35
37
|
|
36
38
|
private
|
37
39
|
|
@@ -1,10 +1,11 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module RuboCop
|
4
5
|
module Cop
|
5
6
|
# Common functionality for checking modifier nodes.
|
6
7
|
module AccessModifierNode
|
7
|
-
extend
|
8
|
+
extend RuboCop::Sexp
|
8
9
|
|
9
10
|
PRIVATE_NODE = s(:send, nil, :private)
|
10
11
|
PROTECTED_NODE = s(:send, nil, :protected)
|
@@ -30,20 +31,12 @@ module RuboCop
|
|
30
31
|
def class_or_module_parent?(node)
|
31
32
|
node.each_ancestor do |a|
|
32
33
|
if a.type == :block
|
33
|
-
return true if class_constructor?
|
34
|
+
return true if a.class_constructor?
|
34
35
|
elsif a.type != :begin
|
35
36
|
return [:casgn, :sclass, :class, :module].include?(a.type)
|
36
37
|
end
|
37
38
|
end
|
38
39
|
end
|
39
|
-
|
40
|
-
# Returns true when the block node looks like Class or Module.new do ... .
|
41
|
-
def class_constructor?(block_node)
|
42
|
-
send_node = block_node.children.first
|
43
|
-
receiver_node, method_name, = *send_node
|
44
|
-
return false unless method_name == :new
|
45
|
-
%w(Class Module).include?(Util.const_name(receiver_node))
|
46
|
-
end
|
47
40
|
end
|
48
41
|
end
|
49
42
|
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
# Common code for indenting literal arrays and hashes.
|
6
|
+
module ArrayHashIndentation
|
7
|
+
def each_argument_node(node, type)
|
8
|
+
_receiver, _method_name, *args = *node
|
9
|
+
left_parenthesis = node.loc.begin
|
10
|
+
return unless left_parenthesis
|
11
|
+
|
12
|
+
args.each do |arg|
|
13
|
+
on_node(type, arg, :send) do |type_node|
|
14
|
+
left_brace = type_node.loc.begin
|
15
|
+
if left_brace && left_brace.line == left_parenthesis.line
|
16
|
+
yield type_node, left_parenthesis
|
17
|
+
ignore_node(type_node)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def check_first(first, left_brace, left_parenthesis, offset)
|
24
|
+
actual_column = first.source_range.column
|
25
|
+
expected_column = base_column(left_brace, left_parenthesis) +
|
26
|
+
configured_indentation_width + offset
|
27
|
+
@column_delta = expected_column - actual_column
|
28
|
+
|
29
|
+
if @column_delta == 0
|
30
|
+
# which column was actually used as 'base column' for indentation?
|
31
|
+
# (not the column which we think should be the 'base column',
|
32
|
+
# but the one which has actually been used for that purpose)
|
33
|
+
base_column = actual_column - configured_indentation_width - offset
|
34
|
+
styles = detected_styles(base_column, left_parenthesis, left_brace)
|
35
|
+
if styles.size > 1
|
36
|
+
ambiguous_style_detected(*styles)
|
37
|
+
else
|
38
|
+
correct_style_detected
|
39
|
+
end
|
40
|
+
else
|
41
|
+
incorrect_style_detected(actual_column, offset, first,
|
42
|
+
left_parenthesis, left_brace)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def base_column(left_brace, left_parenthesis)
|
47
|
+
if style == brace_alignment_style
|
48
|
+
left_brace.column
|
49
|
+
elsif left_parenthesis && style == :special_inside_parentheses
|
50
|
+
left_parenthesis.column + 1
|
51
|
+
else
|
52
|
+
left_brace.source_line =~ /\S/
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def detected_styles(column, left_parenthesis, left_brace)
|
57
|
+
styles = []
|
58
|
+
if column == (left_brace.source_line =~ /\S/)
|
59
|
+
styles << :consistent
|
60
|
+
styles << :special_inside_parentheses unless left_parenthesis
|
61
|
+
end
|
62
|
+
if left_parenthesis && column == left_parenthesis.column + 1
|
63
|
+
styles << :special_inside_parentheses
|
64
|
+
end
|
65
|
+
styles << brace_alignment_style if column == left_brace.column
|
66
|
+
styles
|
67
|
+
end
|
68
|
+
|
69
|
+
def incorrect_style_detected(column, offset, first, left_parenthesis,
|
70
|
+
left_brace)
|
71
|
+
add_offense(first, :expression,
|
72
|
+
message(base_description(left_parenthesis))) do
|
73
|
+
base_column = column - configured_indentation_width - offset
|
74
|
+
styles = detected_styles(base_column, left_parenthesis, left_brace)
|
75
|
+
ambiguous_style_detected(*styles)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|