rubocop-oneoff_codemod 0.0.5 → 0.0.7
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a877f8417cb16bb7c0956b657be916ca5003ce80af7e1f8133d615537945bb8b
|
4
|
+
data.tar.gz: e9970c705d8fb1da22cad3857d9cd1514102e923960bc22861ab53b2ded07e84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b74d4ef24b06d8d103335083fefb6b5f385e59efaea0e04f05f9430461ce406ffcbbc08c2cf2fad6ce661a5cf309d6a31c7d50aa7fe05045da191a9d6804c9d
|
7
|
+
data.tar.gz: 4fb48a4585b45dce3ec3dce95fbdb6dc511693f024f55365dc9581ded263cccfeaaef7198c74096cdb390f45ea5a0a67448d30b69222e1b3dc539cd9bac4141e
|
@@ -19,12 +19,15 @@ module RuboCop
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def find_node_on_line(node, target_line)
|
22
|
-
if node.
|
22
|
+
if node.is_a?(RuboCop::AST::DefNode) && node.loc&.line == target_line
|
23
23
|
node
|
24
24
|
else
|
25
|
-
|
26
|
-
|
25
|
+
finded = nil
|
26
|
+
node.child_nodes.each do |child_node|
|
27
|
+
finded = find_node_on_line child_node, target_line
|
28
|
+
break if finded
|
27
29
|
end
|
30
|
+
finded
|
28
31
|
end
|
29
32
|
end
|
30
33
|
|
@@ -33,6 +36,8 @@ module RuboCop
|
|
33
36
|
next unless comment.text == "# @#{COMMAND}"
|
34
37
|
|
35
38
|
target_node = find_node_on_line(processed_source.ast, comment.location.line + 1)
|
39
|
+
next if target_node.nil?
|
40
|
+
|
36
41
|
target_method = target_node.method_name
|
37
42
|
|
38
43
|
add_offense(comment.location.expression) do |corrector|
|
@@ -45,7 +50,7 @@ module RuboCop
|
|
45
50
|
end
|
46
51
|
end
|
47
52
|
|
48
|
-
corrector.replace(comment.location.expression, "
|
53
|
+
corrector.replace(comment.location.expression, "#: #{string.join}")
|
49
54
|
end
|
50
55
|
end
|
51
56
|
end
|