rubocop 1.16.0 → 1.16.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/config/default.yml +1 -0
- data/lib/rubocop/cop/layout/hash_alignment.rb +2 -1
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +2 -1
- data/lib/rubocop/cop/style/multiline_when_then.rb +2 -11
- data/lib/rubocop/cop/style/quoted_symbols.rb +6 -1
- data/lib/rubocop/cop/style/redundant_self.rb +24 -2
- data/lib/rubocop/rake_task.rb +1 -1
- data/lib/rubocop/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 336b4f09242c5130a3e66be9c17bb23a1d884d0e9d788799f3ff3291616367d7
|
4
|
+
data.tar.gz: 2bbcb0fed39b66808dac5bf4c4df3f6bf4fbf606fcb6f0136acdaff5a1212d42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 006de603e9c559a6c34fb1e25d7c7b255ca8231773e4e8f4c99a6f31a2914ba11069597e66806564bd761a493581f62e0028bd0e47d470fc28ff7822bd9e90d9
|
7
|
+
data.tar.gz: e5fb0bf4851cd7273834f1b89e952406942379298b93ac130dcfc254e3fe427dfdae8adca3666ac45db9314645e74f3bb86aae9fe199f1bb0fe3e0e21047fcb6
|
data/config/default.yml
CHANGED
@@ -217,7 +217,8 @@ module RuboCop
|
|
217
217
|
private
|
218
218
|
|
219
219
|
def autocorrect_incompatible_with_other_cops?(node)
|
220
|
-
enforce_first_argument_with_fixed_indentation? &&
|
220
|
+
enforce_first_argument_with_fixed_indentation? &&
|
221
|
+
node.parent&.call_type? && node.parent.loc.line == node.pairs.first.loc.line
|
221
222
|
end
|
222
223
|
|
223
224
|
def reset!
|
@@ -116,7 +116,8 @@ module RuboCop
|
|
116
116
|
end
|
117
117
|
|
118
118
|
def call_with_braced_block?(node)
|
119
|
-
(node.send_type? || node.super_type?) &&
|
119
|
+
(node.send_type? || node.super_type?) &&
|
120
|
+
((node.parent&.block_type? || node.parent&.numblock_type?) && node.parent&.braces?)
|
120
121
|
end
|
121
122
|
|
122
123
|
def call_as_argument_or_chain?(node)
|
@@ -35,17 +35,7 @@ module RuboCop
|
|
35
35
|
MSG = 'Do not use `then` for multiline `when` statement.'
|
36
36
|
|
37
37
|
def on_when(node)
|
38
|
-
|
39
|
-
return unless node.then?
|
40
|
-
|
41
|
-
# Single line usage of `then` is not an offense
|
42
|
-
return if !node.children.last.nil? && !node.multiline?
|
43
|
-
|
44
|
-
# Requires `then` for write `when` and its body on the same line.
|
45
|
-
return if require_then?(node)
|
46
|
-
|
47
|
-
# For arrays and hashes there's no offense
|
48
|
-
return if accept_node_type?(node.body)
|
38
|
+
return if !node.then? || require_then?(node)
|
49
39
|
|
50
40
|
range = node.loc.begin
|
51
41
|
add_offense(range) do |corrector|
|
@@ -57,6 +47,7 @@ module RuboCop
|
|
57
47
|
|
58
48
|
private
|
59
49
|
|
50
|
+
# Requires `then` for write `when` and its body on the same line.
|
60
51
|
def require_then?(when_node)
|
61
52
|
unless when_node.conditions.first.first_line == when_node.conditions.last.last_line
|
62
53
|
return true
|
@@ -58,7 +58,7 @@ module RuboCop
|
|
58
58
|
private
|
59
59
|
|
60
60
|
def autocorrect(corrector, node)
|
61
|
-
str = if
|
61
|
+
str = if hash_colon_key?(node)
|
62
62
|
# strip quotes
|
63
63
|
correct_quotes(node.source[1..-2])
|
64
64
|
else
|
@@ -69,6 +69,11 @@ module RuboCop
|
|
69
69
|
corrector.replace(node, str)
|
70
70
|
end
|
71
71
|
|
72
|
+
def hash_colon_key?(node)
|
73
|
+
# Is the node a hash key with the colon style?
|
74
|
+
hash_key?(node) && node.parent.colon?
|
75
|
+
end
|
76
|
+
|
72
77
|
def correct_quotes(str)
|
73
78
|
if style == :single_quotes
|
74
79
|
to_string_literal(str)
|
@@ -92,7 +92,7 @@ module RuboCop
|
|
92
92
|
|
93
93
|
def on_masgn(node)
|
94
94
|
lhs, rhs = *node
|
95
|
-
|
95
|
+
add_masgn_lhs_variables(rhs, lhs)
|
96
96
|
end
|
97
97
|
|
98
98
|
def on_lvasgn(node)
|
@@ -106,7 +106,7 @@ module RuboCop
|
|
106
106
|
|
107
107
|
return if allowed_send_node?(node)
|
108
108
|
|
109
|
-
add_offense(node) do |corrector|
|
109
|
+
add_offense(node.receiver) do |corrector|
|
110
110
|
corrector.remove(node.receiver)
|
111
111
|
corrector.remove(node.loc.dot)
|
112
112
|
end
|
@@ -116,6 +116,22 @@ module RuboCop
|
|
116
116
|
add_scope(node, @local_variables_scopes[node])
|
117
117
|
end
|
118
118
|
|
119
|
+
def on_if(node)
|
120
|
+
# Allow conditional nodes to use `self` in the condition if that variable
|
121
|
+
# name is used in an `lvasgn` or `masgn` within the `if`.
|
122
|
+
node.child_nodes.each do |child_node|
|
123
|
+
lhs, _rhs = *child_node
|
124
|
+
|
125
|
+
if child_node.lvasgn_type?
|
126
|
+
add_lhs_to_local_variables_scopes(node.condition, lhs)
|
127
|
+
elsif child_node.masgn_type?
|
128
|
+
add_masgn_lhs_variables(node.condition, lhs)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
alias on_while on_if
|
133
|
+
alias on_until on_if
|
134
|
+
|
119
135
|
private
|
120
136
|
|
121
137
|
def add_scope(node, local_variables = [])
|
@@ -163,6 +179,12 @@ module RuboCop
|
|
163
179
|
@local_variables_scopes[rhs] << lhs
|
164
180
|
end
|
165
181
|
end
|
182
|
+
|
183
|
+
def add_masgn_lhs_variables(rhs, lhs)
|
184
|
+
lhs.children.each do |child|
|
185
|
+
add_lhs_to_local_variables_scopes(rhs, child.to_a.first)
|
186
|
+
end
|
187
|
+
end
|
166
188
|
end
|
167
189
|
end
|
168
190
|
end
|
data/lib/rubocop/rake_task.rb
CHANGED
@@ -70,7 +70,7 @@ module RuboCop
|
|
70
70
|
options = full_options.unshift('--auto-correct-all')
|
71
71
|
# `parallel` will automatically be removed from the options internally.
|
72
72
|
# This is a nice to have to suppress the warning message
|
73
|
-
# about parallel and auto-
|
73
|
+
# about parallel and auto-correct not being compatible.
|
74
74
|
options.delete('--parallel')
|
75
75
|
run_cli(verbose, options)
|
76
76
|
end
|
data/lib/rubocop/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.16.
|
4
|
+
version: 1.16.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bozhidar Batsov
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-06-
|
13
|
+
date: 2021-06-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: parallel
|