rubocop 1.65.0 → 1.65.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rubocop/cop/cop.rb +2 -2
- data/lib/rubocop/cop/layout/assignment_indentation.rb +3 -2
- data/lib/rubocop/cop/layout/condition_position.rb +0 -4
- 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 +0 -4
- 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 +0 -2
- 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 +1 -5
- 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_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 +0 -6
- 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/unified_integer.rb +0 -4
- 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/naming/predicate_name.rb +52 -26
- data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +10 -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/if_with_boolean_literal_branches.rb +0 -1
- data/lib/rubocop/cop/style/invertible_unless_condition.rb +2 -2
- 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/redundant_condition.rb +0 -1
- data/lib/rubocop/cop/style/redundant_regexp_escape.rb +8 -24
- data/lib/rubocop/cop/style/sole_nested_conditional.rb +21 -2
- 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 +5 -1
- data/lib/rubocop/cop/variable_force.rb +13 -1
- data/lib/rubocop/core_ext/string.rb +2 -6
- data/lib/rubocop/ext/regexp_node.rb +9 -31
- data/lib/rubocop/options.rb +3 -1
- data/lib/rubocop/version.rb +1 -1
- data/lib/rubocop.rb +5 -0
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ff6bd1def6f2fc502a83cef45c2031e812de416bf82ee6805ed3c8a4aa4ec08
|
4
|
+
data.tar.gz: 3fc581f44db6ecb7a31a16b58799151c941184b3d972d11716215165c071d672
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07e4e645df882074e88da46ca8a69d7b1d12ec0d83bf4dfaaef6d799dcdb49c584b904d9f186e59278e663bbebe3db8e3950a6d4219fa73487978261c72fded6
|
7
|
+
data.tar.gz: 2d8d8ad60a022ee9df6cb9d164486044787a3a41da8bee073cabb528299d9f62968b8f90fc18a1cba0dbb581968912a478ddda85c1f02c336eb92dbd83092b14
|
data/lib/rubocop/cop/cop.rb
CHANGED
@@ -70,7 +70,7 @@ module RuboCop
|
|
70
70
|
# template file, we convert it to location info in the original file.
|
71
71
|
range = range_for_original(range)
|
72
72
|
|
73
|
-
if block.nil? && !support_autocorrect?
|
73
|
+
if block.nil? && !self.class.support_autocorrect?
|
74
74
|
super(range, message: message, severity: severity)
|
75
75
|
else
|
76
76
|
super(range, message: message, severity: severity) do |corrector|
|
@@ -154,7 +154,7 @@ module RuboCop
|
|
154
154
|
end
|
155
155
|
|
156
156
|
def correction_lambda
|
157
|
-
return unless support_autocorrect?
|
157
|
+
return unless self.class.support_autocorrect?
|
158
158
|
|
159
159
|
dedupe_on_node(@v0_argument) { autocorrect(@v0_argument) }
|
160
160
|
end
|
@@ -6,6 +6,9 @@ module RuboCop
|
|
6
6
|
# Checks the indentation of the first line of the
|
7
7
|
# right-hand-side of a multi-line assignment.
|
8
8
|
#
|
9
|
+
# The indentation of the remaining lines can be corrected with
|
10
|
+
# other cops such as `Layout/IndentationConsistency` and `Layout/EndAlignment`.
|
11
|
+
#
|
9
12
|
# @example
|
10
13
|
# # bad
|
11
14
|
# value =
|
@@ -19,8 +22,6 @@ module RuboCop
|
|
19
22
|
# 'bar'
|
20
23
|
# end
|
21
24
|
#
|
22
|
-
# The indentation of the remaining lines can be corrected with
|
23
|
-
# other cops such as `IndentationConsistency` and `EndAlignment`.
|
24
25
|
class AssignmentIndentation < Base
|
25
26
|
include CheckAssignment
|
26
27
|
include Alignment
|
@@ -11,39 +11,26 @@ module RuboCop
|
|
11
11
|
# @example
|
12
12
|
#
|
13
13
|
# # bad
|
14
|
-
#
|
15
14
|
# def bake(pie: pie)
|
16
15
|
# pie.heat_up
|
17
16
|
# end
|
18
17
|
#
|
19
|
-
# @example
|
20
|
-
#
|
21
18
|
# # good
|
22
|
-
#
|
23
19
|
# def bake(pie:)
|
24
20
|
# pie.refrigerate
|
25
21
|
# end
|
26
22
|
#
|
27
|
-
# @example
|
28
|
-
#
|
29
23
|
# # good
|
30
|
-
#
|
31
24
|
# def bake(pie: self.pie)
|
32
25
|
# pie.feed_to(user)
|
33
26
|
# end
|
34
27
|
#
|
35
|
-
# @example
|
36
|
-
#
|
37
28
|
# # bad
|
38
|
-
#
|
39
29
|
# def cook(dry_ingredients = dry_ingredients)
|
40
30
|
# dry_ingredients.reduce(&:+)
|
41
31
|
# end
|
42
32
|
#
|
43
|
-
# @example
|
44
|
-
#
|
45
33
|
# # good
|
46
|
-
#
|
47
34
|
# def cook(dry_ingredients = self.dry_ingredients)
|
48
35
|
# dry_ingredients.combine
|
49
36
|
# end
|
@@ -44,8 +44,6 @@ module RuboCop
|
|
44
44
|
# do_something
|
45
45
|
# end
|
46
46
|
#
|
47
|
-
# @example
|
48
|
-
#
|
49
47
|
# # bad (ok during development)
|
50
48
|
#
|
51
49
|
# # using byebug
|
@@ -54,8 +52,6 @@ module RuboCop
|
|
54
52
|
# do_something
|
55
53
|
# end
|
56
54
|
#
|
57
|
-
# @example
|
58
|
-
#
|
59
55
|
# # good
|
60
56
|
#
|
61
57
|
# def some_method
|
@@ -9,28 +9,18 @@ module RuboCop
|
|
9
9
|
#
|
10
10
|
# @example
|
11
11
|
#
|
12
|
-
# # Example for OpenSSL::Cipher instantiation.
|
13
|
-
#
|
14
12
|
# # bad
|
15
13
|
# OpenSSL::Cipher::AES.new(128, :GCM)
|
16
14
|
#
|
17
15
|
# # good
|
18
16
|
# OpenSSL::Cipher.new('aes-128-gcm')
|
19
17
|
#
|
20
|
-
# @example
|
21
|
-
#
|
22
|
-
# # Example for OpenSSL::Digest instantiation.
|
23
|
-
#
|
24
18
|
# # bad
|
25
19
|
# OpenSSL::Digest::SHA256.new
|
26
20
|
#
|
27
21
|
# # good
|
28
22
|
# OpenSSL::Digest.new('SHA256')
|
29
23
|
#
|
30
|
-
# @example
|
31
|
-
#
|
32
|
-
# # Example for ::Digest inherited class methods.
|
33
|
-
#
|
34
24
|
# # bad
|
35
25
|
# OpenSSL::Digest::SHA256.digest('foo')
|
36
26
|
#
|
@@ -9,7 +9,6 @@ module RuboCop
|
|
9
9
|
# @example
|
10
10
|
#
|
11
11
|
# # bad
|
12
|
-
#
|
13
12
|
# case x
|
14
13
|
# when 'first'
|
15
14
|
# do_something
|
@@ -17,10 +16,7 @@ module RuboCop
|
|
17
16
|
# do_something_else
|
18
17
|
# end
|
19
18
|
#
|
20
|
-
# @example
|
21
|
-
#
|
22
19
|
# # good
|
23
|
-
#
|
24
20
|
# case x
|
25
21
|
# when 'first'
|
26
22
|
# do_something
|
@@ -9,7 +9,6 @@ module RuboCop
|
|
9
9
|
# @example
|
10
10
|
#
|
11
11
|
# # bad
|
12
|
-
#
|
13
12
|
# def foo
|
14
13
|
# 1
|
15
14
|
# end
|
@@ -18,20 +17,14 @@ module RuboCop
|
|
18
17
|
# 2
|
19
18
|
# end
|
20
19
|
#
|
21
|
-
# @example
|
22
|
-
#
|
23
20
|
# # bad
|
24
|
-
#
|
25
21
|
# def foo
|
26
22
|
# 1
|
27
23
|
# end
|
28
24
|
#
|
29
25
|
# alias foo bar
|
30
26
|
#
|
31
|
-
# @example
|
32
|
-
#
|
33
27
|
# # good
|
34
|
-
#
|
35
28
|
# def foo
|
36
29
|
# 1
|
37
30
|
# end
|
@@ -40,10 +33,7 @@ module RuboCop
|
|
40
33
|
# 2
|
41
34
|
# end
|
42
35
|
#
|
43
|
-
# @example
|
44
|
-
#
|
45
36
|
# # good
|
46
|
-
#
|
47
37
|
# def foo
|
48
38
|
# 1
|
49
39
|
# end
|
@@ -12,13 +12,9 @@ module RuboCop
|
|
12
12
|
# @example
|
13
13
|
#
|
14
14
|
# # bad
|
15
|
-
#
|
16
15
|
# sum = numbers.each_with_object(0) { |e, a| a += e }
|
17
16
|
#
|
18
|
-
# @example
|
19
|
-
#
|
20
17
|
# # good
|
21
|
-
#
|
22
18
|
# num = 0
|
23
19
|
# sum = numbers.each_with_object(num) { |e, a| a += e }
|
24
20
|
class EachWithObjectArgument < Base
|
@@ -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
|
@@ -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 = [
|
@@ -80,7 +76,7 @@ module RuboCop
|
|
80
76
|
end
|
81
77
|
|
82
78
|
def string_literal?(node)
|
83
|
-
node.str_type? ||
|
79
|
+
node.str_type? || node.dstr_type?
|
84
80
|
end
|
85
81
|
|
86
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
|
@@ -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
|
#
|