rubocop-socketry 0.2.2 → 0.2.3
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
- checksums.yaml.gz.sig +0 -0
- data/lib/rubocop/socketry/layout/consistent_blank_line_indentation.rb +12 -8
- data/lib/rubocop/socketry/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b25ad4b5bdd6aeaf9f0b41a518f8c31db3ead2ab410f837827f2bc92d422954b
|
4
|
+
data.tar.gz: b405f44e0c5e435864b035fd24ff5bf56cfa9dc75b7f920b05db906856791f32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ebc654b95f9ff26fc351afc98a9b2250501b05b3a03e882d27c5a2deb689d986f9619f95f520ea1a1a38c638311b90351b1478339f03d0e14a087180f9dd482
|
7
|
+
data.tar.gz: 8a21062e6208ea01b33727343930a50aa7be89d1bf83eaaeb8eb741ac9f4148a46e51b788e0af3360480ca648b2ff012d51d56e9fafcc997bbb336129a8b422f
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -89,6 +89,8 @@ module RuboCop
|
|
89
89
|
deltas
|
90
90
|
end
|
91
91
|
|
92
|
+
STRUCTURAL_NODES = [:array, :hash, :class, :module, :sclass, :def, :defs, :if, :while, :until, :for, :case, :kwbegin]
|
93
|
+
|
92
94
|
def receiver_handles_indentation(node)
|
93
95
|
if send_node = node.children.first
|
94
96
|
return false unless send_node.type == :send
|
@@ -97,12 +99,14 @@ module RuboCop
|
|
97
99
|
# Only structural node types handle their own indentation.
|
98
100
|
# These are nodes that create indentation contexts (arrays, hashes, classes, etc.)
|
99
101
|
# All other receivers (simple references, method calls, literals) should allow block indentation.
|
100
|
-
return
|
102
|
+
return STRUCTURAL_NODES.include?(receiver.type)
|
101
103
|
end
|
102
104
|
end
|
103
105
|
|
104
106
|
return false
|
105
|
-
end
|
107
|
+
end
|
108
|
+
|
109
|
+
# Recursively walk the AST to build indentation deltas for block structures.
|
106
110
|
# This method identifies nodes that should affect indentation and records the deltas.
|
107
111
|
# @parameter node [Parser::AST::Node] The current AST node to process.
|
108
112
|
# @parameter deltas [Hash(Integer, Integer)] The deltas hash to populate.
|
@@ -119,14 +123,9 @@ module RuboCop
|
|
119
123
|
deltas[location.last_line] -= 1
|
120
124
|
end
|
121
125
|
end
|
122
|
-
when :array, :hash, :class, :module, :sclass, :def, :defs, :while, :until, :for, :case, :kwbegin
|
123
|
-
if location = node.location
|
124
|
-
deltas[location.line] += 1
|
125
|
-
deltas[location.last_line] -= 1
|
126
|
-
end
|
127
126
|
when :if
|
128
127
|
# We don't want to add deltas for elsif, because it's handled by the if node:
|
129
|
-
if node.keyword == "if"
|
128
|
+
if node.keyword == "if" || node.keyword == "unless"
|
130
129
|
if location = node.location
|
131
130
|
deltas[location.line] += 1
|
132
131
|
deltas[location.last_line] -= 1
|
@@ -141,6 +140,11 @@ module RuboCop
|
|
141
140
|
end
|
142
141
|
end
|
143
142
|
end
|
143
|
+
when *STRUCTURAL_NODES
|
144
|
+
if location = node.location
|
145
|
+
deltas[location.line] += 1
|
146
|
+
deltas[location.last_line] -= 1
|
147
|
+
end
|
144
148
|
end
|
145
149
|
|
146
150
|
node.children.each do |child|
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|