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,10 +2,10 @@
|
|
2
2
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
|
-
module
|
5
|
+
module Layout
|
6
6
|
# Checks for colon (:) not followed by some kind of space.
|
7
7
|
# N.B. this cop does not handle spaces after a ternary operator, which are
|
8
|
-
# instead handled by
|
8
|
+
# instead handled by Layout/SpaceAroundOperators.
|
9
9
|
class SpaceAfterColon < Cop
|
10
10
|
MSG = 'Space missing after colon.'.freeze
|
11
11
|
|
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
|
-
module
|
5
|
+
module Layout
|
6
6
|
# Checks for comma (,) not followed by some kind of space.
|
7
7
|
class SpaceAfterComma < Cop
|
8
8
|
include SpaceAfterPunctuation
|
9
9
|
|
10
10
|
def space_style_before_rcurly
|
11
|
-
cfg = config.for_cop('
|
11
|
+
cfg = config.for_cop('Layout/SpaceInsideHashLiteralBraces')
|
12
12
|
cfg['EnforcedStyle'] || 'space'
|
13
13
|
end
|
14
14
|
|
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
|
-
module
|
5
|
+
module Layout
|
6
6
|
# Checks for semicolon (;) not followed by some kind of space.
|
7
7
|
class SpaceAfterSemicolon < Cop
|
8
8
|
include SpaceAfterPunctuation
|
9
9
|
|
10
10
|
def space_style_before_rcurly
|
11
|
-
cfg = config.for_cop('
|
11
|
+
cfg = config.for_cop('Layout/SpaceInsideBlockBraces')
|
12
12
|
cfg['EnforcedStyle'] || 'space'
|
13
13
|
end
|
14
14
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
|
-
module
|
5
|
+
module Layout
|
6
6
|
# Checks the spacing inside and after block parameters pipes.
|
7
7
|
#
|
8
8
|
# @example
|
@@ -16,15 +16,17 @@ module RuboCop
|
|
16
16
|
include ConfigurableEnforcedStyle
|
17
17
|
|
18
18
|
def on_block(node)
|
19
|
-
|
19
|
+
return unless node.arguments?
|
20
|
+
|
21
|
+
args = node.arguments
|
22
|
+
|
20
23
|
opening_pipe = args.loc.begin
|
21
24
|
closing_pipe = args.loc.end
|
22
|
-
return unless !args.children.empty? && opening_pipe
|
23
25
|
|
24
26
|
check_inside_pipes(args.children, opening_pipe, closing_pipe)
|
25
27
|
|
26
|
-
if body
|
27
|
-
check_space(closing_pipe.end_pos, body.source_range.begin_pos,
|
28
|
+
if node.body
|
29
|
+
check_space(closing_pipe.end_pos, node.body.source_range.begin_pos,
|
28
30
|
closing_pipe, 'after closing `|`')
|
29
31
|
end
|
30
32
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
|
-
module
|
5
|
+
module Layout
|
6
6
|
# Checks that operators have space around them, except for **
|
7
7
|
# which should not have surrounding space.
|
8
8
|
class SpaceAroundOperators < Cop
|
@@ -10,6 +10,10 @@ module RuboCop
|
|
10
10
|
|
11
11
|
IRREGULAR_METHODS = %i[[] ! []=].freeze
|
12
12
|
|
13
|
+
def self.autocorrect_incompatible_with
|
14
|
+
[Style::SelfAssignment]
|
15
|
+
end
|
16
|
+
|
13
17
|
def on_pair(node)
|
14
18
|
return unless node.hash_rocket?
|
15
19
|
|
@@ -129,7 +133,7 @@ module RuboCop
|
|
129
133
|
end
|
130
134
|
|
131
135
|
def align_hash_cop_config
|
132
|
-
config.for_cop('
|
136
|
+
config.for_cop('Layout/AlignHash')
|
133
137
|
end
|
134
138
|
|
135
139
|
def hash_table_style?
|
@@ -2,14 +2,18 @@
|
|
2
2
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
|
-
module
|
5
|
+
module Layout
|
6
6
|
# Checks that block braces have or don't have a space before the opening
|
7
7
|
# brace depending on configuration.
|
8
8
|
class SpaceBeforeBlockBraces < Cop
|
9
9
|
include ConfigurableEnforcedStyle
|
10
10
|
|
11
|
+
def self.autocorrect_incompatible_with
|
12
|
+
[Style::SymbolProc]
|
13
|
+
end
|
14
|
+
|
11
15
|
def on_block(node)
|
12
|
-
return if node.
|
16
|
+
return if node.keywords?
|
13
17
|
|
14
18
|
left_brace = node.loc.begin
|
15
19
|
space_plus_brace = range_with_surrounding_space(left_brace)
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
|
-
module
|
5
|
+
module Layout
|
6
6
|
# Checks that exactly one space is used between a method name and the
|
7
7
|
# first argument for method calls without parentheses.
|
8
8
|
#
|
@@ -14,10 +14,12 @@ module RuboCop
|
|
14
14
|
# @bad
|
15
15
|
# something x
|
16
16
|
# something y, z
|
17
|
+
# something'hello'
|
17
18
|
#
|
18
19
|
# @good
|
19
20
|
# something x
|
20
21
|
# something y, z
|
22
|
+
# something 'hello'
|
21
23
|
#
|
22
24
|
class SpaceBeforeFirstArg < Cop
|
23
25
|
include PrecedingFollowingAlignment
|
@@ -34,7 +36,7 @@ module RuboCop
|
|
34
36
|
space = range_between(first_arg_with_space.begin_pos,
|
35
37
|
first_arg.begin_pos)
|
36
38
|
|
37
|
-
add_offense(space, space) if space.length
|
39
|
+
add_offense(space, space) if space.length != 1
|
38
40
|
end
|
39
41
|
|
40
42
|
def autocorrect(range)
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
|
-
module
|
5
|
+
module Layout
|
6
6
|
# Checks that block braces have or don't have surrounding space inside
|
7
7
|
# them on configuration. For blocks taking parameters, it checks that the
|
8
8
|
# left brace has or doesn't have trailing space depending on
|
@@ -12,7 +12,7 @@ module RuboCop
|
|
12
12
|
include SurroundingSpace
|
13
13
|
|
14
14
|
def on_block(node)
|
15
|
-
return if node.
|
15
|
+
return if node.keywords?
|
16
16
|
|
17
17
|
left_brace = node.loc.begin
|
18
18
|
right_brace = node.loc.end
|
@@ -46,8 +46,7 @@ module RuboCop
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def braces_with_contents_inside(node, inner)
|
49
|
-
|
50
|
-
args_delimiter = args.loc.begin # Can be ( | or nil.
|
49
|
+
args_delimiter = node.arguments.loc.begin # Can be ( | or nil.
|
51
50
|
|
52
51
|
check_left_brace(inner, node.loc.begin, args_delimiter)
|
53
52
|
check_right_brace(inner, node.loc.end, block_length(node))
|
@@ -2,18 +2,19 @@
|
|
2
2
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
|
-
module
|
5
|
+
module Layout
|
6
6
|
# Checks for unnecessary additional spaces inside the delimiters of
|
7
7
|
# %i/%w/%x literals.
|
8
8
|
#
|
9
9
|
# @example
|
10
|
-
#
|
10
|
+
#
|
11
|
+
# # good
|
11
12
|
# %i(foo bar baz)
|
12
13
|
#
|
13
|
-
#
|
14
|
+
# # bad
|
14
15
|
# %w( foo bar baz )
|
15
16
|
#
|
16
|
-
#
|
17
|
+
# # bad
|
17
18
|
# %x( ls -l )
|
18
19
|
class SpaceInsidePercentLiteralDelimiters < Cop
|
19
20
|
include MatchRange
|
@@ -27,11 +28,11 @@ module RuboCop
|
|
27
28
|
process(node, '%i', '%I', '%w', '%W')
|
28
29
|
end
|
29
30
|
|
30
|
-
def
|
31
|
-
|
31
|
+
def on_xstr(node)
|
32
|
+
process(node, '%x')
|
32
33
|
end
|
33
34
|
|
34
|
-
def
|
35
|
+
def on_percent_literal(node)
|
35
36
|
add_offenses_for_unnecessary_spaces(node)
|
36
37
|
end
|
37
38
|
|
@@ -2,14 +2,14 @@
|
|
2
2
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
|
-
module
|
5
|
+
module Layout
|
6
6
|
# This cop looks for trailing whitespace in the source code.
|
7
7
|
class TrailingWhitespace < Cop
|
8
8
|
MSG = 'Trailing whitespace detected.'.freeze
|
9
9
|
|
10
10
|
def investigate(processed_source)
|
11
11
|
processed_source.lines.each_with_index do |line, index|
|
12
|
-
next unless line
|
12
|
+
next unless line.end_with?(' ', "\t")
|
13
13
|
|
14
14
|
range = source_range(processed_source.buffer,
|
15
15
|
index + 1,
|
@@ -30,7 +30,7 @@ module RuboCop
|
|
30
30
|
|
31
31
|
def on_send(node)
|
32
32
|
return if node.parenthesized? || allowed_method?(node)
|
33
|
-
return if lambda_argument?(node.
|
33
|
+
return if lambda_argument?(node.last_argument)
|
34
34
|
|
35
35
|
return unless method_with_block?(node.last_argument)
|
36
36
|
last_param = node.last_argument.children.first
|
@@ -33,10 +33,10 @@ module RuboCop
|
|
33
33
|
hash[:operator] = key
|
34
34
|
end
|
35
35
|
|
36
|
-
MSG_FORMAT = 'Ambiguous
|
37
|
-
"arguments if it's surely a
|
38
|
-
'a whitespace to the right of the
|
39
|
-
'should be a
|
36
|
+
MSG_FORMAT = 'Ambiguous %<actual>s operator. Parenthesize the method ' \
|
37
|
+
"arguments if it's surely a %<actual>s operator, or add " \
|
38
|
+
'a whitespace to the right of the `%<operator>s` if it ' \
|
39
|
+
'should be a %<possible>s.'.freeze
|
40
40
|
|
41
41
|
private
|
42
42
|
|
@@ -63,21 +63,6 @@ module RuboCop
|
|
63
63
|
format(MSG, node.source)
|
64
64
|
end
|
65
65
|
|
66
|
-
def autocorrect(node)
|
67
|
-
lambda do |corrector|
|
68
|
-
if pry_rescue?(node)
|
69
|
-
block = node.parent
|
70
|
-
body = block.children[2] # (block <send> <parameters> <body>)
|
71
|
-
corrector.replace(block.source_range, body.source)
|
72
|
-
else
|
73
|
-
range = node.source_range
|
74
|
-
range = range_with_surrounding_space(range, :left, false)
|
75
|
-
range = range_with_surrounding_space(range, :right, true)
|
76
|
-
corrector.remove(range)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
66
|
def binding_irb?(node)
|
82
67
|
target_ruby_version >= 2.4 && binding_irb_call?(node)
|
83
68
|
end
|