rubocop-socketry 0.2.2 → 0.2.4
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 +13 -24
- 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: bdf96e461ba72f91f680ae3a68c72b8a3147c3f3643b1ba2ac78b4faa9285ebd
|
4
|
+
data.tar.gz: 541814b98f28c0ccb78378c5752df9d1093afd7e41881e7ba18ad804cc1538da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd942adb6f5fa81ec37d5e3898c2dc736d4a9f9d2530d8f3e08fbfde11decec5cc9f81b40525d8a16370f98de48ad254fa3a20a505dd8e008413154fbe324a00
|
7
|
+
data.tar.gz: 2d33e2859470e2a66df2d58b0b5ced439de091b1d11b14261864f7f0f97d9726a75fa693d066d8ba4bdd51b5c63c808bef8af74fce6e86554436e7fec37e052a
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -89,20 +89,9 @@ module RuboCop
|
|
89
89
|
deltas
|
90
90
|
end
|
91
91
|
|
92
|
-
def
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
if receiver = send_node.children.first
|
97
|
-
# Only structural node types handle their own indentation.
|
98
|
-
# These are nodes that create indentation contexts (arrays, hashes, classes, etc.)
|
99
|
-
# All other receivers (simple references, method calls, literals) should allow block indentation.
|
100
|
-
return [:array, :hash, :class, :module, :sclass, :def, :defs, :if, :while, :until, :for, :case, :kwbegin].include?(receiver.type)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
return false
|
105
|
-
end # Recursively walk the AST to build indentation deltas for block structures.
|
92
|
+
STRUCTURAL_NODES = [:array, :hash, :class, :module, :sclass, :def, :defs, :if, :if, :while, :until, :for, :case, :kwbegin]
|
93
|
+
|
94
|
+
# Recursively walk the AST to build indentation deltas for block structures.
|
106
95
|
# This method identifies nodes that should affect indentation and records the deltas.
|
107
96
|
# @parameter node [Parser::AST::Node] The current AST node to process.
|
108
97
|
# @parameter deltas [Hash(Integer, Integer)] The deltas hash to populate.
|
@@ -112,21 +101,16 @@ module RuboCop
|
|
112
101
|
|
113
102
|
case node.type
|
114
103
|
when :block
|
115
|
-
# For blocks,
|
104
|
+
# For blocks, use the actual block begin/end boundaries, not the full location
|
116
105
|
if location = node.location
|
117
|
-
|
118
|
-
deltas[location.line] += 1
|
119
|
-
deltas[location.
|
106
|
+
if location.begin && location.end
|
107
|
+
deltas[location.begin.line] += 1
|
108
|
+
deltas[location.end.line] -= 1
|
120
109
|
end
|
121
110
|
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
111
|
when :if
|
128
112
|
# We don't want to add deltas for elsif, because it's handled by the if node:
|
129
|
-
if node.keyword == "if"
|
113
|
+
if node.keyword == "if" || node.keyword == "unless"
|
130
114
|
if location = node.location
|
131
115
|
deltas[location.line] += 1
|
132
116
|
deltas[location.last_line] -= 1
|
@@ -141,6 +125,11 @@ module RuboCop
|
|
141
125
|
end
|
142
126
|
end
|
143
127
|
end
|
128
|
+
when *STRUCTURAL_NODES
|
129
|
+
if location = node.location
|
130
|
+
deltas[location.line] += 1
|
131
|
+
deltas[location.last_line] -= 1
|
132
|
+
end
|
144
133
|
end
|
145
134
|
|
146
135
|
node.children.each do |child|
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|