rubocop 1.64.1 → 1.65.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/config/default.yml +11 -1
- data/lib/rubocop/config_loader.rb +1 -1
- data/lib/rubocop/config_loader_resolver.rb +9 -3
- data/lib/rubocop/cop/cop.rb +22 -4
- data/lib/rubocop/cop/gemspec/add_runtime_dependency.rb +38 -0
- data/lib/rubocop/cop/gemspec/duplicated_assignment.rb +2 -2
- data/lib/rubocop/cop/gemspec/ruby_version_globals_usage.rb +3 -3
- data/lib/rubocop/cop/layout/assignment_indentation.rb +3 -2
- data/lib/rubocop/cop/layout/case_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/condition_position.rb +0 -4
- data/lib/rubocop/cop/layout/empty_line_after_multiline_condition.rb +1 -1
- data/lib/rubocop/cop/layout/first_argument_indentation.rb +2 -2
- data/lib/rubocop/cop/layout/heredoc_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/indentation_width.rb +1 -1
- data/lib/rubocop/cop/layout/line_length.rb +20 -20
- data/lib/rubocop/cop/layout/space_around_operators.rb +3 -0
- data/lib/rubocop/cop/legacy/corrector.rb +12 -2
- data/lib/rubocop/cop/lint/ambiguous_block_association.rb +0 -2
- data/lib/rubocop/cop/lint/ambiguous_operator.rb +0 -2
- data/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb +0 -2
- data/lib/rubocop/cop/lint/boolean_symbol.rb +0 -2
- data/lib/rubocop/cop/lint/circular_argument_reference.rb +0 -13
- data/lib/rubocop/cop/lint/debugger.rb +0 -4
- data/lib/rubocop/cop/lint/deprecated_open_ssl_constant.rb +0 -10
- data/lib/rubocop/cop/lint/duplicate_case_condition.rb +1 -5
- data/lib/rubocop/cop/lint/duplicate_hash_key.rb +0 -4
- data/lib/rubocop/cop/lint/duplicate_methods.rb +0 -10
- data/lib/rubocop/cop/lint/each_with_object_argument.rb +0 -4
- data/lib/rubocop/cop/lint/else_layout.rb +0 -2
- data/lib/rubocop/cop/lint/empty_ensure.rb +1 -11
- data/lib/rubocop/cop/lint/empty_interpolation.rb +0 -4
- data/lib/rubocop/cop/lint/empty_when.rb +1 -3
- data/lib/rubocop/cop/lint/ensure_return.rb +1 -6
- data/lib/rubocop/cop/lint/float_comparison.rb +3 -1
- data/lib/rubocop/cop/lint/float_out_of_range.rb +0 -4
- data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +0 -10
- data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +15 -12
- data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +0 -7
- data/lib/rubocop/cop/lint/interpolation_check.rb +0 -4
- data/lib/rubocop/cop/lint/literal_as_condition.rb +1 -1
- data/lib/rubocop/cop/lint/literal_assignment_in_condition.rb +1 -1
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +0 -4
- data/lib/rubocop/cop/lint/loop.rb +6 -12
- data/lib/rubocop/cop/lint/nested_method_definition.rb +1 -7
- data/lib/rubocop/cop/lint/next_without_accumulator.rb +0 -4
- data/lib/rubocop/cop/lint/no_return_in_begin_end_blocks.rb +0 -5
- data/lib/rubocop/cop/lint/percent_string_array.rb +0 -4
- data/lib/rubocop/cop/lint/percent_symbol_array.rb +0 -4
- data/lib/rubocop/cop/lint/rand_one.rb +0 -4
- data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +3 -1
- data/lib/rubocop/cop/lint/redundant_splat_expansion.rb +1 -1
- data/lib/rubocop/cop/lint/redundant_string_coercion.rb +0 -4
- data/lib/rubocop/cop/lint/require_parentheses.rb +0 -4
- data/lib/rubocop/cop/lint/rescue_exception.rb +0 -4
- data/lib/rubocop/cop/lint/return_in_void_context.rb +0 -2
- data/lib/rubocop/cop/lint/safe_navigation_chain.rb +0 -4
- data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +6 -10
- data/lib/rubocop/cop/lint/to_enum_arguments.rb +2 -9
- data/lib/rubocop/cop/lint/unified_integer.rb +0 -4
- data/lib/rubocop/cop/lint/unmodified_reduce_accumulator.rb +1 -0
- data/lib/rubocop/cop/lint/unreachable_code.rb +0 -5
- data/lib/rubocop/cop/lint/useless_assignment.rb +1 -5
- data/lib/rubocop/cop/lint/useless_else_without_rescue.rb +0 -4
- data/lib/rubocop/cop/lint/useless_setter_call.rb +0 -4
- data/lib/rubocop/cop/lint/void.rb +5 -0
- data/lib/rubocop/cop/metrics/block_nesting.rb +19 -7
- data/lib/rubocop/cop/mixin/alignment.rb +5 -1
- data/lib/rubocop/cop/mixin/allowed_methods.rb +7 -1
- data/lib/rubocop/cop/mixin/allowed_pattern.rb +15 -3
- data/lib/rubocop/cop/mixin/configurable_max.rb +5 -1
- data/lib/rubocop/cop/mixin/rescue_node.rb +4 -0
- data/lib/rubocop/cop/naming/predicate_name.rb +52 -26
- data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +10 -1
- data/lib/rubocop/cop/style/arguments_forwarding.rb +1 -1
- data/lib/rubocop/cop/style/def_with_parentheses.rb +0 -2
- data/lib/rubocop/cop/style/each_for_simple_loop.rb +0 -1
- data/lib/rubocop/cop/style/eval_with_location.rb +12 -11
- data/lib/rubocop/cop/style/file_read.rb +2 -5
- data/lib/rubocop/cop/style/file_write.rb +2 -5
- data/lib/rubocop/cop/style/global_std_stream.rb +7 -1
- data/lib/rubocop/cop/style/hash_except.rb +8 -5
- data/lib/rubocop/cop/style/if_with_boolean_literal_branches.rb +0 -1
- data/lib/rubocop/cop/style/invertible_unless_condition.rb +2 -2
- data/lib/rubocop/cop/style/map_compact_with_conditional_block.rb +77 -43
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +5 -0
- data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +1 -1
- data/lib/rubocop/cop/style/missing_else.rb +0 -4
- data/lib/rubocop/cop/style/multiline_when_then.rb +0 -4
- data/lib/rubocop/cop/style/quoted_symbols.rb +1 -1
- data/lib/rubocop/cop/style/redundant_begin.rb +1 -1
- data/lib/rubocop/cop/style/redundant_condition.rb +0 -1
- data/lib/rubocop/cop/style/redundant_file_extension_in_require.rb +1 -1
- data/lib/rubocop/cop/style/redundant_regexp_escape.rb +8 -24
- data/lib/rubocop/cop/style/send_with_literal_method_name.rb +15 -1
- data/lib/rubocop/cop/style/sole_nested_conditional.rb +21 -2
- data/lib/rubocop/cop/style/super_arguments.rb +28 -10
- data/lib/rubocop/cop/style/symbol_proc.rb +8 -1
- data/lib/rubocop/cop/style/while_until_do.rb +0 -2
- data/lib/rubocop/cop/style/while_until_modifier.rb +0 -1
- data/lib/rubocop/cop/style/zero_length_predicate.rb +32 -24
- data/lib/rubocop/cop/team.rb +8 -0
- data/lib/rubocop/cop/util.rb +7 -1
- data/lib/rubocop/cop/variable_force.rb +13 -1
- data/lib/rubocop/cops_documentation_generator.rb +1 -1
- data/lib/rubocop/core_ext/string.rb +2 -6
- data/lib/rubocop/ext/regexp_node.rb +9 -31
- data/lib/rubocop/ext/regexp_parser.rb +4 -21
- data/lib/rubocop/formatter/html_formatter.rb +3 -1
- data/lib/rubocop/options.rb +3 -1
- data/lib/rubocop/rspec/shared_contexts.rb +20 -0
- data/lib/rubocop/rspec/support.rb +1 -0
- data/lib/rubocop/server/cache.rb +10 -0
- data/lib/rubocop/server/client_command/exec.rb +2 -2
- data/lib/rubocop/server/client_command/start.rb +1 -1
- data/lib/rubocop/server/core.rb +4 -0
- data/lib/rubocop/version.rb +1 -1
- data/lib/rubocop.rb +6 -0
- metadata +7 -6
@@ -3,40 +3,30 @@
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
5
|
module Lint
|
6
|
-
# Checks for empty `ensure` blocks
|
6
|
+
# Checks for empty `ensure` blocks.
|
7
7
|
#
|
8
8
|
# @example
|
9
9
|
#
|
10
10
|
# # bad
|
11
|
-
#
|
12
11
|
# def some_method
|
13
12
|
# do_something
|
14
13
|
# ensure
|
15
14
|
# end
|
16
15
|
#
|
17
|
-
# @example
|
18
|
-
#
|
19
16
|
# # bad
|
20
|
-
#
|
21
17
|
# begin
|
22
18
|
# do_something
|
23
19
|
# ensure
|
24
20
|
# end
|
25
21
|
#
|
26
|
-
# @example
|
27
|
-
#
|
28
22
|
# # good
|
29
|
-
#
|
30
23
|
# def some_method
|
31
24
|
# do_something
|
32
25
|
# ensure
|
33
26
|
# do_something_else
|
34
27
|
# end
|
35
28
|
#
|
36
|
-
# @example
|
37
|
-
#
|
38
29
|
# # good
|
39
|
-
#
|
40
30
|
# begin
|
41
31
|
# do_something
|
42
32
|
# ensure
|
@@ -14,8 +14,6 @@ module RuboCop
|
|
14
14
|
# when baz
|
15
15
|
# end
|
16
16
|
#
|
17
|
-
# @example
|
18
|
-
#
|
19
17
|
# # good
|
20
18
|
# case condition
|
21
19
|
# when foo
|
@@ -50,7 +48,7 @@ module RuboCop
|
|
50
48
|
MSG = 'Avoid `when` branches without a body.'
|
51
49
|
|
52
50
|
def on_case(node)
|
53
|
-
node.
|
51
|
+
node.when_branches.each do |when_node|
|
54
52
|
next if when_node.body
|
55
53
|
next if cop_config['AllowComments'] && contains_comments?(when_node)
|
56
54
|
|
@@ -13,7 +13,6 @@ module RuboCop
|
|
13
13
|
# @example
|
14
14
|
#
|
15
15
|
# # bad
|
16
|
-
#
|
17
16
|
# def foo
|
18
17
|
# do_something
|
19
18
|
# ensure
|
@@ -21,10 +20,7 @@ module RuboCop
|
|
21
20
|
# return self
|
22
21
|
# end
|
23
22
|
#
|
24
|
-
# @example
|
25
|
-
#
|
26
23
|
# # good
|
27
|
-
#
|
28
24
|
# def foo
|
29
25
|
# do_something
|
30
26
|
# self
|
@@ -32,8 +28,7 @@ module RuboCop
|
|
32
28
|
# cleanup
|
33
29
|
# end
|
34
30
|
#
|
35
|
-
# #
|
36
|
-
#
|
31
|
+
# # good
|
37
32
|
# def foo
|
38
33
|
# begin
|
39
34
|
# do_something
|
@@ -66,7 +66,9 @@ module RuboCop
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def literal_zero?(node)
|
69
|
-
|
69
|
+
# TODO: https://github.com/rubocop/rubocop-ast/pull/304 is released,
|
70
|
+
# replace this condition with `node&.numeric_type? && node.value.zero?`.
|
71
|
+
node&.numeric_type? && node.node_parts[0].zero?
|
70
72
|
end
|
71
73
|
|
72
74
|
# rubocop:disable Metrics/PerceivedComplexity
|
@@ -14,25 +14,15 @@ module RuboCop
|
|
14
14
|
# @example
|
15
15
|
#
|
16
16
|
# # bad
|
17
|
-
#
|
18
17
|
# format('A value: %s and another: %i', a_value)
|
19
18
|
#
|
20
|
-
# @example
|
21
|
-
#
|
22
19
|
# # good
|
23
|
-
#
|
24
20
|
# format('A value: %s and another: %i', a_value, another)
|
25
21
|
#
|
26
|
-
# @example
|
27
|
-
#
|
28
22
|
# # bad
|
29
|
-
#
|
30
23
|
# format('Unnumbered format: %s and numbered: %2$s', a_value, another)
|
31
24
|
#
|
32
|
-
# @example
|
33
|
-
#
|
34
25
|
# # good
|
35
|
-
#
|
36
26
|
# format('Numbered format: %1$s and numbered %2$s', a_value, another)
|
37
27
|
class FormatParameterMismatch < Base
|
38
28
|
# http://rubular.com/r/CvpbxkcTzy
|
@@ -9,13 +9,9 @@ module RuboCop
|
|
9
9
|
# @example
|
10
10
|
#
|
11
11
|
# # bad
|
12
|
-
#
|
13
12
|
# array = ['Item 1' 'Item 2']
|
14
13
|
#
|
15
|
-
# @example
|
16
|
-
#
|
17
14
|
# # good
|
18
|
-
#
|
19
15
|
# array = ['Item 1Item 2']
|
20
16
|
# array = ['Item 1' + 'Item 2']
|
21
17
|
# array = [
|
@@ -23,27 +19,34 @@ module RuboCop
|
|
23
19
|
# 'Item 2'
|
24
20
|
# ]
|
25
21
|
class ImplicitStringConcatenation < Base
|
26
|
-
|
22
|
+
extend AutoCorrector
|
23
|
+
|
24
|
+
MSG = 'Combine %<lhs>s and %<rhs>s into a single string ' \
|
27
25
|
'literal, rather than using implicit string concatenation.'
|
28
26
|
FOR_ARRAY = ' Or, if they were intended to be separate array ' \
|
29
27
|
'elements, separate them with a comma.'
|
30
28
|
FOR_METHOD = ' Or, if they were intended to be separate method ' \
|
31
29
|
'arguments, separate them with a comma.'
|
32
30
|
|
31
|
+
# rubocop:disable Metrics/AbcSize
|
33
32
|
def on_dstr(node)
|
34
|
-
each_bad_cons(node) do |
|
35
|
-
range
|
36
|
-
message = format(MSG,
|
37
|
-
string1: display_str(child_node1),
|
38
|
-
string2: display_str(child_node2))
|
33
|
+
each_bad_cons(node) do |lhs_node, rhs_node|
|
34
|
+
range = lhs_node.source_range.join(rhs_node.source_range)
|
35
|
+
message = format(MSG, lhs: display_str(lhs_node), rhs: display_str(rhs_node))
|
39
36
|
if node.parent&.array_type?
|
40
37
|
message << FOR_ARRAY
|
41
38
|
elsif node.parent&.send_type?
|
42
39
|
message << FOR_METHOD
|
43
40
|
end
|
44
|
-
|
41
|
+
|
42
|
+
add_offense(range, message: message) do |corrector|
|
43
|
+
preferred = "#{lhs_node.source} + #{rhs_node.source}"
|
44
|
+
|
45
|
+
corrector.replace(range, preferred)
|
46
|
+
end
|
45
47
|
end
|
46
48
|
end
|
49
|
+
# rubocop:enable Metrics/AbcSize
|
47
50
|
|
48
51
|
private
|
49
52
|
|
@@ -73,7 +76,7 @@ module RuboCop
|
|
73
76
|
end
|
74
77
|
|
75
78
|
def string_literal?(node)
|
76
|
-
node.str_type? ||
|
79
|
+
node.str_type? || node.dstr_type?
|
77
80
|
end
|
78
81
|
|
79
82
|
def string_literals?(node1, node2)
|
@@ -11,7 +11,6 @@ module RuboCop
|
|
11
11
|
# @example
|
12
12
|
#
|
13
13
|
# # bad
|
14
|
-
#
|
15
14
|
# class C
|
16
15
|
# private
|
17
16
|
#
|
@@ -20,10 +19,7 @@ module RuboCop
|
|
20
19
|
# end
|
21
20
|
# end
|
22
21
|
#
|
23
|
-
# @example
|
24
|
-
#
|
25
22
|
# # good
|
26
|
-
#
|
27
23
|
# class C
|
28
24
|
# def self.method
|
29
25
|
# puts 'hi'
|
@@ -32,10 +28,7 @@ module RuboCop
|
|
32
28
|
# private_class_method :method
|
33
29
|
# end
|
34
30
|
#
|
35
|
-
# @example
|
36
|
-
#
|
37
31
|
# # good
|
38
|
-
#
|
39
32
|
# class C
|
40
33
|
# class << self
|
41
34
|
# private
|
@@ -14,13 +14,9 @@ module RuboCop
|
|
14
14
|
# @example
|
15
15
|
#
|
16
16
|
# # bad
|
17
|
-
#
|
18
17
|
# foo = 'something with #{interpolation} inside'
|
19
18
|
#
|
20
|
-
# @example
|
21
|
-
#
|
22
19
|
# # good
|
23
|
-
#
|
24
20
|
# foo = "something with #{interpolation} inside"
|
25
21
|
class InterpolationCheck < Base
|
26
22
|
extend AutoCorrector
|
@@ -19,17 +19,6 @@ module RuboCop
|
|
19
19
|
# do_something
|
20
20
|
# end while some_condition
|
21
21
|
#
|
22
|
-
# @example
|
23
|
-
#
|
24
|
-
# # bad
|
25
|
-
#
|
26
|
-
# # using until
|
27
|
-
# begin
|
28
|
-
# do_something
|
29
|
-
# end until some_condition
|
30
|
-
#
|
31
|
-
# @example
|
32
|
-
#
|
33
22
|
# # good
|
34
23
|
#
|
35
24
|
# # while replacement
|
@@ -38,7 +27,12 @@ module RuboCop
|
|
38
27
|
# break unless some_condition
|
39
28
|
# end
|
40
29
|
#
|
41
|
-
#
|
30
|
+
# # bad
|
31
|
+
#
|
32
|
+
# # using until
|
33
|
+
# begin
|
34
|
+
# do_something
|
35
|
+
# end until some_condition
|
42
36
|
#
|
43
37
|
# # good
|
44
38
|
#
|
@@ -17,8 +17,6 @@ module RuboCop
|
|
17
17
|
# end
|
18
18
|
# end
|
19
19
|
#
|
20
|
-
# @example
|
21
|
-
#
|
22
20
|
# # good
|
23
21
|
#
|
24
22
|
# def foo
|
@@ -26,8 +24,6 @@ module RuboCop
|
|
26
24
|
# bar.call
|
27
25
|
# end
|
28
26
|
#
|
29
|
-
# @example
|
30
|
-
#
|
31
27
|
# # good
|
32
28
|
#
|
33
29
|
# # `class_eval`, `instance_eval`, `module_eval`, `class_exec`, `instance_exec`, and
|
@@ -47,8 +43,6 @@ module RuboCop
|
|
47
43
|
# end
|
48
44
|
# end
|
49
45
|
#
|
50
|
-
# @example
|
51
|
-
#
|
52
46
|
# # good
|
53
47
|
#
|
54
48
|
# def foo
|
@@ -102,7 +96,7 @@ module RuboCop
|
|
102
96
|
|
103
97
|
def on_def(node)
|
104
98
|
subject, = *node
|
105
|
-
return if node.defs_type? && subject.
|
99
|
+
return if node.defs_type? && subject.variable?
|
106
100
|
|
107
101
|
def_ancestor = node.each_ancestor(:def, :defs).first
|
108
102
|
return unless def_ancestor
|
@@ -8,16 +8,12 @@ module RuboCop
|
|
8
8
|
# @example
|
9
9
|
#
|
10
10
|
# # bad
|
11
|
-
#
|
12
11
|
# result = (1..4).reduce(0) do |acc, i|
|
13
12
|
# next if i.odd?
|
14
13
|
# acc + i
|
15
14
|
# end
|
16
15
|
#
|
17
|
-
# @example
|
18
|
-
#
|
19
16
|
# # good
|
20
|
-
#
|
21
17
|
# result = (1..4).reduce(0) do |acc, i|
|
22
18
|
# next acc if i.odd?
|
23
19
|
# acc + i
|
@@ -11,17 +11,13 @@ module RuboCop
|
|
11
11
|
# @example
|
12
12
|
#
|
13
13
|
# # bad
|
14
|
-
#
|
15
14
|
# @some_variable ||= begin
|
16
15
|
# return some_value if some_condition_is_met
|
17
16
|
#
|
18
17
|
# do_something
|
19
18
|
# end
|
20
19
|
#
|
21
|
-
# @example
|
22
|
-
#
|
23
20
|
# # good
|
24
|
-
#
|
25
21
|
# @some_variable ||= begin
|
26
22
|
# if some_condition_is_met
|
27
23
|
# some_value
|
@@ -31,7 +27,6 @@ module RuboCop
|
|
31
27
|
# end
|
32
28
|
#
|
33
29
|
# # good
|
34
|
-
#
|
35
30
|
# some_variable = if some_condition_is_met
|
36
31
|
# return if another_condition_is_met
|
37
32
|
#
|
@@ -9,16 +9,12 @@ module RuboCop
|
|
9
9
|
# @example
|
10
10
|
#
|
11
11
|
# # bad
|
12
|
-
#
|
13
12
|
# rand 1
|
14
13
|
# Kernel.rand(-1)
|
15
14
|
# rand 1.0
|
16
15
|
# rand(-1.0)
|
17
16
|
#
|
18
|
-
# @example
|
19
|
-
#
|
20
17
|
# # good
|
21
|
-
#
|
22
18
|
# 0 # just use 0 instead
|
23
19
|
class RandOne < Base
|
24
20
|
MSG = '`%<method>s` always returns `0`. Perhaps you meant `rand(2)` or `rand`?'
|
@@ -14,14 +14,16 @@ module RuboCop
|
|
14
14
|
#
|
15
15
|
# When comment enables all cops at once `rubocop:enable all`
|
16
16
|
# that cop checks whether any cop was actually enabled.
|
17
|
+
#
|
17
18
|
# @example
|
19
|
+
#
|
18
20
|
# # bad
|
19
21
|
# foo = 1
|
20
22
|
# # rubocop:enable Layout/LineLength
|
21
23
|
#
|
22
24
|
# # good
|
23
25
|
# foo = 1
|
24
|
-
#
|
26
|
+
#
|
25
27
|
# # bad
|
26
28
|
# # rubocop:disable Style/StringLiterals
|
27
29
|
# foo = "1"
|
@@ -9,16 +9,12 @@ module RuboCop
|
|
9
9
|
# @example
|
10
10
|
#
|
11
11
|
# # bad
|
12
|
-
#
|
13
12
|
# "result is #{something.to_s}"
|
14
13
|
# print something.to_s
|
15
14
|
# puts something.to_s
|
16
15
|
# warn something.to_s
|
17
16
|
#
|
18
|
-
# @example
|
19
|
-
#
|
20
17
|
# # good
|
21
|
-
#
|
22
18
|
# "result is #{something}"
|
23
19
|
# print something
|
24
20
|
# puts something
|
@@ -12,17 +12,16 @@ module RuboCop
|
|
12
12
|
# because `Ractor` should not access outer variables.
|
13
13
|
# eg. following style is encouraged:
|
14
14
|
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
15
|
+
# [source,ruby]
|
16
|
+
# ----
|
17
|
+
# worker_id, pipe = env
|
18
|
+
# Ractor.new(worker_id, pipe) do |worker_id, pipe|
|
19
|
+
# end
|
20
|
+
# ----
|
21
21
|
#
|
22
22
|
# @example
|
23
23
|
#
|
24
24
|
# # bad
|
25
|
-
#
|
26
25
|
# def some_method
|
27
26
|
# foo = 1
|
28
27
|
#
|
@@ -31,10 +30,7 @@ module RuboCop
|
|
31
30
|
# end
|
32
31
|
# end
|
33
32
|
#
|
34
|
-
# @example
|
35
|
-
#
|
36
33
|
# # good
|
37
|
-
#
|
38
34
|
# def some_method
|
39
35
|
# foo = 1
|
40
36
|
#
|
@@ -49,15 +49,8 @@ module RuboCop
|
|
49
49
|
return unless def_node
|
50
50
|
|
51
51
|
enum_conversion_call?(node) do |method_node, arguments|
|
52
|
-
next if method_node.
|
53
|
-
|
54
|
-
|
55
|
-
valid = if method_name?(method_node, def_node.method_name)
|
56
|
-
arguments_match?(arguments, def_node)
|
57
|
-
else
|
58
|
-
def_node.arguments.empty?
|
59
|
-
end
|
60
|
-
return if valid
|
52
|
+
next if !method_name?(method_node, def_node.method_name) ||
|
53
|
+
arguments_match?(arguments, def_node)
|
61
54
|
|
62
55
|
add_offense(node)
|
63
56
|
end
|
@@ -10,14 +10,12 @@ module RuboCop
|
|
10
10
|
# @example
|
11
11
|
#
|
12
12
|
# # bad
|
13
|
-
#
|
14
13
|
# def some_method
|
15
14
|
# return
|
16
15
|
# do_something
|
17
16
|
# end
|
18
17
|
#
|
19
18
|
# # bad
|
20
|
-
#
|
21
19
|
# def some_method
|
22
20
|
# if cond
|
23
21
|
# return
|
@@ -27,10 +25,7 @@ module RuboCop
|
|
27
25
|
# do_something
|
28
26
|
# end
|
29
27
|
#
|
30
|
-
# @example
|
31
|
-
#
|
32
28
|
# # good
|
33
|
-
#
|
34
29
|
# def some_method
|
35
30
|
# do_something
|
36
31
|
# end
|