rubocop 0.48.1 → 0.49.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -3
- data/config/default.yml +397 -357
- data/config/disabled.yml +29 -29
- data/config/enabled.yml +366 -326
- data/lib/rubocop.rb +85 -70
- data/lib/rubocop/ast/builder.rb +4 -1
- data/lib/rubocop/ast/node.rb +2 -2
- data/lib/rubocop/ast/node/and_node.rb +1 -1
- data/lib/rubocop/ast/node/args_node.rb +24 -0
- data/lib/rubocop/ast/node/block_node.rb +107 -0
- data/lib/rubocop/ast/node/case_node.rb +1 -1
- data/lib/rubocop/ast/node/ensure_node.rb +1 -1
- data/lib/rubocop/ast/node/for_node.rb +1 -1
- data/lib/rubocop/ast/node/if_node.rb +1 -1
- data/lib/rubocop/ast/node/mixin/parameterized_node.rb +74 -0
- data/lib/rubocop/ast/node/or_node.rb +1 -1
- data/lib/rubocop/ast/node/pair_node.rb +1 -1
- data/lib/rubocop/ast/node/resbody_node.rb +1 -1
- data/lib/rubocop/ast/node/send_node.rb +36 -57
- data/lib/rubocop/ast/node/super_node.rb +42 -0
- data/lib/rubocop/ast/node/until_node.rb +1 -1
- data/lib/rubocop/ast/node/when_node.rb +1 -1
- data/lib/rubocop/ast/node/while_node.rb +1 -1
- data/lib/rubocop/cli.rb +10 -0
- data/lib/rubocop/config.rb +23 -7
- data/lib/rubocop/config_loader.rb +19 -3
- data/lib/rubocop/cop/badge.rb +1 -1
- data/lib/rubocop/cop/bundler/duplicated_gem.rb +2 -2
- data/lib/rubocop/cop/commissioner.rb +1 -1
- data/lib/rubocop/cop/cop.rb +10 -0
- data/lib/rubocop/cop/{style → layout}/access_modifier_indentation.rb +33 -3
- data/lib/rubocop/cop/{style → layout}/align_array.rb +16 -1
- data/lib/rubocop/cop/{style → layout}/align_hash.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/align_parameters.rb +29 -1
- data/lib/rubocop/cop/{style → layout}/block_end_newline.rb +10 -5
- data/lib/rubocop/cop/{style → layout}/case_indentation.rb +64 -1
- data/lib/rubocop/cop/{style → layout}/closing_parenthesis_indentation.rb +2 -2
- data/lib/rubocop/cop/{style → layout}/comment_indentation.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/dot_position.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/else_alignment.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/empty_line_after_magic_comment.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/empty_line_between_defs.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/empty_lines.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/empty_lines_around_access_modifier.rb +2 -7
- data/lib/rubocop/cop/{style → layout}/empty_lines_around_begin_body.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/empty_lines_around_block_body.rb +2 -4
- data/lib/rubocop/cop/{style → layout}/empty_lines_around_class_body.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/empty_lines_around_exception_handling_keywords.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/empty_lines_around_method_body.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/empty_lines_around_module_body.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/end_of_line.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/extra_spacing.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/first_array_element_line_break.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/first_hash_element_line_break.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/first_method_argument_line_break.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/first_method_parameter_line_break.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/first_parameter_indentation.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/indent_array.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/indent_assignment.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/indent_hash.rb +2 -2
- data/lib/rubocop/cop/{style → layout}/indent_heredoc.rb +3 -3
- data/lib/rubocop/cop/{style → layout}/indentation_consistency.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/indentation_width.rb +10 -12
- data/lib/rubocop/cop/{style → layout}/initial_indentation.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/leading_comment_space.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/multiline_array_brace_layout.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/multiline_assignment_layout.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/multiline_block_layout.rb +21 -36
- data/lib/rubocop/cop/{style → layout}/multiline_hash_brace_layout.rb +5 -1
- data/lib/rubocop/cop/{style → layout}/multiline_method_call_brace_layout.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/multiline_method_call_indentation.rb +3 -3
- data/lib/rubocop/cop/{style → layout}/multiline_method_definition_brace_layout.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/multiline_operation_indentation.rb +6 -5
- data/lib/rubocop/cop/{style → layout}/rescue_ensure_alignment.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/space_after_colon.rb +2 -2
- data/lib/rubocop/cop/{style → layout}/space_after_comma.rb +2 -2
- data/lib/rubocop/cop/{style → layout}/space_after_method_name.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/space_after_not.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/space_after_semicolon.rb +2 -2
- data/lib/rubocop/cop/{style → layout}/space_around_block_parameters.rb +7 -5
- data/lib/rubocop/cop/{style → layout}/space_around_equals_in_parameter_default.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/space_around_keyword.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/space_around_operators.rb +6 -2
- data/lib/rubocop/cop/{style → layout}/space_before_block_braces.rb +6 -2
- data/lib/rubocop/cop/{style → layout}/space_before_comma.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/space_before_comment.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/space_before_first_arg.rb +4 -2
- data/lib/rubocop/cop/{style → layout}/space_before_semicolon.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/space_in_lambda_literal.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/space_inside_array_percent_literal.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/space_inside_block_braces.rb +3 -4
- data/lib/rubocop/cop/{style → layout}/space_inside_brackets.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/space_inside_hash_literal_braces.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/space_inside_parens.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/space_inside_percent_literal_delimiters.rb +8 -7
- data/lib/rubocop/cop/{style → layout}/space_inside_range_literal.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/space_inside_string_interpolation.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/tab.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/trailing_blank_lines.rb +1 -1
- data/lib/rubocop/cop/{style → layout}/trailing_whitespace.rb +2 -2
- data/lib/rubocop/cop/lint/ambiguous_block_association.rb +1 -1
- data/lib/rubocop/cop/lint/ambiguous_operator.rb +4 -4
- data/lib/rubocop/cop/lint/debugger.rb +0 -15
- data/lib/rubocop/cop/lint/duplicate_methods.rb +2 -1
- data/lib/rubocop/cop/lint/rescue_type.rb +81 -0
- data/lib/rubocop/cop/lint/script_permission.rb +42 -0
- data/lib/rubocop/cop/lint/useless_access_modifier.rb +1 -1
- data/lib/rubocop/cop/message_annotator.rb +23 -13
- data/lib/rubocop/cop/metrics/block_length.rb +1 -1
- data/lib/rubocop/cop/mixin/array_min_size.rb +59 -0
- data/lib/rubocop/cop/mixin/configurable_enforced_style.rb +10 -11
- data/lib/rubocop/cop/mixin/def_node.rb +1 -1
- data/lib/rubocop/cop/mixin/empty_lines_around_body.rb +1 -1
- data/lib/rubocop/cop/mixin/enforce_superclass.rb +36 -0
- data/lib/rubocop/cop/mixin/hash_alignment.rb +1 -1
- data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +7 -3
- data/lib/rubocop/cop/mixin/space_before_punctuation.rb +1 -1
- data/lib/rubocop/cop/performance/caller.rb +41 -0
- data/lib/rubocop/cop/performance/compare_with_block.rb +60 -14
- data/lib/rubocop/cop/performance/double_start_end_with.rb +2 -2
- data/lib/rubocop/cop/performance/redundant_merge.rb +2 -0
- data/lib/rubocop/cop/rails/action_filter.rb +1 -3
- data/lib/rubocop/cop/rails/application_job.rb +32 -0
- data/lib/rubocop/cop/rails/application_record.rb +32 -0
- data/lib/rubocop/cop/rails/blank.rb +9 -3
- data/lib/rubocop/cop/rails/output_safety.rb +59 -15
- data/lib/rubocop/cop/rails/present.rb +9 -3
- data/lib/rubocop/cop/rails/relative_date_constant.rb +35 -4
- data/lib/rubocop/cop/rails/reversible_migration.rb +82 -18
- data/lib/rubocop/cop/rails/save_bang.rb +7 -2
- data/lib/rubocop/cop/rails/skips_model_validations.rb +7 -0
- data/lib/rubocop/cop/registry.rb +4 -3
- data/lib/rubocop/cop/security/eval.rb +9 -3
- data/lib/rubocop/cop/style/and_or.rb +1 -1
- data/lib/rubocop/cop/style/block_delimiters.rb +11 -17
- data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +1 -1
- data/lib/rubocop/cop/style/collection_methods.rb +1 -3
- data/lib/rubocop/cop/style/conditional_assignment.rb +1 -1
- data/lib/rubocop/cop/style/copyright.rb +2 -2
- data/lib/rubocop/cop/style/documentation_method.rb +1 -1
- data/lib/rubocop/cop/style/each_for_simple_loop.rb +2 -1
- data/lib/rubocop/cop/style/each_with_object.rb +10 -6
- data/lib/rubocop/cop/style/empty_case_condition.rb +2 -2
- data/lib/rubocop/cop/style/for.rb +4 -5
- data/lib/rubocop/cop/style/format_string.rb +49 -0
- data/lib/rubocop/cop/style/format_string_token.rb +141 -0
- data/lib/rubocop/cop/style/hash_syntax.rb +1 -1
- data/lib/rubocop/cop/style/identical_conditional_branches.rb +2 -2
- data/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb +1 -1
- data/lib/rubocop/cop/style/inverse_methods.rb +10 -1
- data/lib/rubocop/cop/style/lambda.rb +9 -9
- data/lib/rubocop/cop/style/line_end_concatenation.rb +4 -0
- data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +3 -3
- data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +1 -2
- data/lib/rubocop/cop/style/method_name.rb +8 -2
- data/lib/rubocop/cop/style/mixin_grouping.rb +41 -3
- data/lib/rubocop/cop/style/multiline_block_chain.rb +7 -11
- data/lib/rubocop/cop/style/multiple_comparison.rb +77 -0
- data/lib/rubocop/cop/style/next.rb +11 -22
- data/lib/rubocop/cop/style/parallel_assignment.rb +10 -19
- data/lib/rubocop/cop/style/percent_literal_delimiters.rb +2 -2
- data/lib/rubocop/cop/style/self_assignment.rb +4 -0
- data/lib/rubocop/cop/style/single_line_block_params.rb +23 -17
- data/lib/rubocop/cop/style/symbol_array.rb +24 -13
- data/lib/rubocop/cop/style/symbol_proc.rb +4 -0
- data/lib/rubocop/cop/style/ternary_parentheses.rb +1 -1
- data/lib/rubocop/cop/style/unneeded_interpolation.rb +4 -0
- data/lib/rubocop/cop/style/word_array.rb +33 -53
- data/lib/rubocop/cop/style/yoda_condition.rb +78 -0
- data/lib/rubocop/cop/team.rb +1 -14
- data/lib/rubocop/cop/util.rb +16 -0
- data/lib/rubocop/formatter/simple_text_formatter.rb +0 -11
- data/lib/rubocop/node_pattern.rb +52 -52
- data/lib/rubocop/options.rb +25 -0
- data/lib/rubocop/path_util.rb +17 -1
- data/lib/rubocop/result_cache.rb +8 -7
- data/lib/rubocop/rspec/expect_offense.rb +167 -0
- data/lib/rubocop/rspec/shared_examples.rb +0 -8
- data/lib/rubocop/rspec/support.rb +1 -0
- data/lib/rubocop/runner.rb +12 -2
- data/lib/rubocop/target_finder.rb +5 -0
- data/lib/rubocop/version.rb +1 -1
- metadata +101 -72
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
|
-
module
|
5
|
+
module Layout
|
6
6
|
# This cop checks the indentation of the first element in an array literal
|
7
7
|
# where the opening bracket and the first element are on separate lines.
|
8
8
|
# The other elements' indentations are handled by the AlignArray cop.
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
|
-
module
|
5
|
+
module Layout
|
6
6
|
# This cops checks the indentation of the first key in a hash literal
|
7
7
|
# where the opening brace and the first key are on separate lines. The
|
8
8
|
# other keys' indentations are handled by the AlignHash cop.
|
@@ -102,7 +102,7 @@ module RuboCop
|
|
102
102
|
def separator_style?(first_pair)
|
103
103
|
separator = first_pair.loc.operator
|
104
104
|
key = "Enforced#{separator.is?(':') ? 'Colon' : 'HashRocket'}Style"
|
105
|
-
config.for_cop('
|
105
|
+
config.for_cop('Layout/AlignHash')[key] == 'separator'
|
106
106
|
end
|
107
107
|
|
108
108
|
def check_based_on_longest_key(pairs, left_brace, left_parenthesis)
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
|
-
module
|
5
|
+
module Layout
|
6
6
|
# This cops checks the indentation of the here document bodies. The bodies
|
7
7
|
# are indented one step.
|
8
8
|
# In Ruby 2.3 or newer, squiggly heredocs (`<<~`) should be used. If you
|
@@ -105,8 +105,8 @@ module RuboCop
|
|
105
105
|
if heredoc_indent_type(node) == '~'
|
106
106
|
corrector.replace(node.loc.heredoc_body, indented_body(node))
|
107
107
|
else
|
108
|
-
|
109
|
-
corrected =
|
108
|
+
heredoc_beginning = node.loc.expression.source
|
109
|
+
corrected = heredoc_beginning.sub(/<<-?/, '<<~')
|
110
110
|
corrector.replace(node.loc.expression, corrected)
|
111
111
|
end
|
112
112
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
|
-
module
|
5
|
+
module Layout
|
6
6
|
# This cops checks for indentation that doesn't use the specified number
|
7
7
|
# of spaces.
|
8
8
|
#
|
@@ -45,7 +45,7 @@ module RuboCop
|
|
45
45
|
# end
|
46
46
|
# end
|
47
47
|
# end
|
48
|
-
class IndentationWidth < Cop
|
48
|
+
class IndentationWidth < Cop
|
49
49
|
include EndKeywordAlignment
|
50
50
|
include AutocorrectAlignment
|
51
51
|
include OnMethodDef
|
@@ -75,17 +75,15 @@ module RuboCop
|
|
75
75
|
end
|
76
76
|
|
77
77
|
def on_block(node)
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
check_indentation(loc.end, body)
|
78
|
+
end_loc = node.loc.end
|
79
|
+
|
80
|
+
return unless begins_its_line?(end_loc)
|
81
|
+
|
82
|
+
check_indentation(end_loc, node.body)
|
83
|
+
|
86
84
|
return unless indentation_consistency_style == 'rails'
|
87
85
|
|
88
|
-
check_members(
|
86
|
+
check_members(end_loc, [node.body])
|
89
87
|
end
|
90
88
|
|
91
89
|
def on_module(node)
|
@@ -173,7 +171,7 @@ module RuboCop
|
|
173
171
|
end
|
174
172
|
|
175
173
|
def indentation_consistency_style
|
176
|
-
config.for_cop('
|
174
|
+
config.for_cop('Layout/IndentationConsistency')['EnforcedStyle']
|
177
175
|
end
|
178
176
|
|
179
177
|
def check_assignment(node, rhs)
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
|
-
module
|
5
|
+
module Layout
|
6
6
|
# This cop checks whether the multiline do end blocks have a newline
|
7
7
|
# after the start of the block. Additionally, it checks whether the block
|
8
8
|
# arguments, if any, are on the same line as the start of the block.
|
@@ -42,32 +42,22 @@ module RuboCop
|
|
42
42
|
'block start.'.freeze
|
43
43
|
|
44
44
|
def on_block(node)
|
45
|
-
return if
|
45
|
+
return if node.single_line?
|
46
46
|
|
47
|
-
|
48
|
-
|
49
|
-
# with arguments and the expression start on the same line.
|
50
|
-
_block_start, args, last_expression = node.children
|
51
|
-
do_loc = node.loc.begin # Actually it's either do or {.
|
52
|
-
|
53
|
-
if args_on_different_line?(do_loc.line, args)
|
54
|
-
add_offense_for_expression(node, args, ARG_MSG)
|
47
|
+
unless args_on_beginning_line?(node)
|
48
|
+
add_offense_for_expression(node, node.arguments, ARG_MSG)
|
55
49
|
end
|
56
50
|
|
57
|
-
return unless
|
58
|
-
expression_loc = last_expression.loc
|
59
|
-
return unless do_loc.line == expression_loc.line
|
60
|
-
add_offense_for_expression(node, last_expression, MSG)
|
61
|
-
end
|
51
|
+
return unless node.body && node.loc.begin.line == node.body.loc.line
|
62
52
|
|
63
|
-
|
64
|
-
node.loc.begin.line == node.loc.end.line
|
53
|
+
add_offense_for_expression(node, node.body, MSG)
|
65
54
|
end
|
66
55
|
|
67
|
-
|
68
|
-
return false if args.children.empty?
|
56
|
+
private
|
69
57
|
|
70
|
-
|
58
|
+
def args_on_beginning_line?(node)
|
59
|
+
!node.arguments? ||
|
60
|
+
node.loc.begin.line == node.arguments.loc.last_line
|
71
61
|
end
|
72
62
|
|
73
63
|
def add_offense_for_expression(node, expr, msg)
|
@@ -79,31 +69,26 @@ module RuboCop
|
|
79
69
|
|
80
70
|
def autocorrect(node)
|
81
71
|
lambda do |corrector|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
expr_before_body = args.source_range.end
|
72
|
+
unless args_on_beginning_line?(node)
|
73
|
+
autocorrect_arguments(corrector, node)
|
74
|
+
expr_before_body = node.arguments.source_range.end
|
86
75
|
end
|
87
76
|
|
88
|
-
return unless
|
77
|
+
return unless node.body
|
89
78
|
|
90
79
|
expr_before_body ||= node.loc.begin
|
91
|
-
|
92
|
-
|
80
|
+
|
81
|
+
if expr_before_body.line == node.body.loc.line
|
82
|
+
autocorrect_body(corrector, node, node.body)
|
93
83
|
end
|
94
84
|
end
|
95
85
|
end
|
96
86
|
|
97
|
-
def
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
def autocorrect_arguments(corrector, node, args)
|
102
|
-
end_pos =
|
103
|
-
range_with_surrounding_space(args.source_range, :right, false)
|
104
|
-
.end_pos
|
87
|
+
def autocorrect_arguments(corrector, node)
|
88
|
+
end_pos = range_with_surrounding_space(node.arguments.source_range,
|
89
|
+
:right, false).end_pos
|
105
90
|
range = range_between(node.loc.begin.end.begin_pos, end_pos)
|
106
|
-
corrector.replace(range, " |#{block_arg_string(
|
91
|
+
corrector.replace(range, " |#{block_arg_string(node.arguments)}|")
|
107
92
|
end
|
108
93
|
|
109
94
|
def autocorrect_body(corrector, node, block_body)
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
|
-
module
|
5
|
+
module Layout
|
6
6
|
# This cop checks that the closing brace in a hash literal is either
|
7
7
|
# on the same line as the last hash element, or a new line.
|
8
8
|
#
|
@@ -72,6 +72,10 @@ module RuboCop
|
|
72
72
|
ALWAYS_SAME_LINE_MESSAGE = 'Closing hash brace must be on the same ' \
|
73
73
|
'line as the last hash element.'.freeze
|
74
74
|
|
75
|
+
def self.autocorrect_incompatible_with
|
76
|
+
[Style::BracesAroundHashParameters]
|
77
|
+
end
|
78
|
+
|
75
79
|
def on_hash(node)
|
76
80
|
check_brace_layout(node)
|
77
81
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
|
-
module
|
5
|
+
module Layout
|
6
6
|
# This cop checks the indentation of the method name part in method calls
|
7
7
|
# that span more than one line.
|
8
8
|
#
|
@@ -56,7 +56,7 @@ module RuboCop
|
|
56
56
|
return unless style == :aligned && cop_config['IndentationWidth']
|
57
57
|
|
58
58
|
raise ValidationError,
|
59
|
-
'The `
|
59
|
+
'The `Layout/MultilineMethodCallIndentation`' \
|
60
60
|
' cop only accepts an `IndentationWidth` ' \
|
61
61
|
'configuration parameter when ' \
|
62
62
|
'`EnforcedStyle` is `indented`.'
|
@@ -188,7 +188,7 @@ module RuboCop
|
|
188
188
|
end
|
189
189
|
|
190
190
|
def semantic_alignment_node(node)
|
191
|
-
return if argument_in_method_call(node)
|
191
|
+
return if argument_in_method_call(node, :with_parentheses)
|
192
192
|
|
193
193
|
# descend to root of method chain
|
194
194
|
node = node.receiver while node.receiver
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
|
-
module
|
5
|
+
module Layout
|
6
6
|
# This cop checks the indentation of the right hand side operand in
|
7
7
|
# binary operations that span more than one line.
|
8
8
|
#
|
@@ -28,7 +28,7 @@ module RuboCop
|
|
28
28
|
def validate_config
|
29
29
|
return unless style == :aligned && cop_config['IndentationWidth']
|
30
30
|
|
31
|
-
raise ValidationError, 'The `
|
31
|
+
raise ValidationError, 'The `Layout/MultilineOperationIndentation`' \
|
32
32
|
' cop only accepts an `IndentationWidth` ' \
|
33
33
|
'configuration parameter when ' \
|
34
34
|
'`EnforcedStyle` is `indented`.'
|
@@ -67,9 +67,10 @@ module RuboCop
|
|
67
67
|
return true if begins_its_line?(assignment_rhs.source_range)
|
68
68
|
end
|
69
69
|
|
70
|
-
given_style == :aligned &&
|
71
|
-
|
72
|
-
|
70
|
+
given_style == :aligned &&
|
71
|
+
(kw_node_with_special_indentation(node) ||
|
72
|
+
assignment_node ||
|
73
|
+
argument_in_method_call(node, :with_or_without_parentheses))
|
73
74
|
end
|
74
75
|
|
75
76
|
def message(node, lhs, rhs)
|