rubocop-socketry 0.2.0 → 0.2.2
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 +26 -5
- data/lib/rubocop/socketry/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +2 -2
- 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: 1cd24ac3f11cf5e4b0fc32f54ca985578963b64ea7ccdf9d148996b75e0df68f
|
4
|
+
data.tar.gz: 57ca52a7c26e6f4b029b928ad0b6d5cae1dfab8e8c4105ebd084be7fe1a9732b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '059d5dd3fc0e62510c4966ea018c4ef15d4e8fd54827895441899c47ca38a4d408e9ef39795112f2c913f0af9012172a0339c3ac42de58f1273ca77e4762161a'
|
7
|
+
data.tar.gz: dd8b19f094ace1a5891d14877331d9eda98e45a08e326b2d1b87e96696987067bd369852d2887a4e4d4a1c63c38f549ed2d4e07899607da04e373ae924682465
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -89,16 +89,37 @@ module RuboCop
|
|
89
89
|
deltas
|
90
90
|
end
|
91
91
|
|
92
|
-
|
92
|
+
def receiver_handles_indentation(node)
|
93
|
+
if send_node = node.children.first
|
94
|
+
return false unless send_node.type == :send
|
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.
|
93
106
|
# This method identifies nodes that should affect indentation and records the deltas.
|
94
107
|
# @parameter node [Parser::AST::Node] The current AST node to process.
|
95
108
|
# @parameter deltas [Hash(Integer, Integer)] The deltas hash to populate.
|
96
|
-
|
109
|
+
# @parameter parent [Parser::AST::Node, nil] The parent node for context.
|
110
|
+
def walk_ast_for_indentation(node, deltas, parent = nil)
|
97
111
|
return unless node.is_a?(Parser::AST::Node)
|
98
112
|
|
99
113
|
case node.type
|
100
|
-
when :block
|
101
|
-
|
114
|
+
when :block
|
115
|
+
# For blocks, we need to be careful about method receiver collections
|
116
|
+
if location = node.location
|
117
|
+
unless receiver_handles_indentation(node)
|
118
|
+
deltas[location.line] += 1
|
119
|
+
deltas[location.last_line] -= 1
|
120
|
+
end
|
121
|
+
end
|
122
|
+
when :array, :hash, :class, :module, :sclass, :def, :defs, :while, :until, :for, :case, :kwbegin
|
102
123
|
if location = node.location
|
103
124
|
deltas[location.line] += 1
|
104
125
|
deltas[location.last_line] -= 1
|
@@ -123,7 +144,7 @@ module RuboCop
|
|
123
144
|
end
|
124
145
|
|
125
146
|
node.children.each do |child|
|
126
|
-
walk_ast_for_indentation(child, deltas)
|
147
|
+
walk_ast_for_indentation(child, deltas, node)
|
127
148
|
end
|
128
149
|
end
|
129
150
|
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-socketry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -101,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '0'
|
103
103
|
requirements: []
|
104
|
-
rubygems_version: 3.6.
|
104
|
+
rubygems_version: 3.6.9
|
105
105
|
specification_version: 4
|
106
106
|
summary: RuboCop rules for Socketry projects
|
107
107
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|