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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 703167377c5947f3c290afdce02b498de3287c05457714f7025e84719069e457
4
- data.tar.gz: aa33490e887990aa87c9f420ba5fede419151530b914a71760a54aba0e4375db
3
+ metadata.gz: 1cd24ac3f11cf5e4b0fc32f54ca985578963b64ea7ccdf9d148996b75e0df68f
4
+ data.tar.gz: 57ca52a7c26e6f4b029b928ad0b6d5cae1dfab8e8c4105ebd084be7fe1a9732b
5
5
  SHA512:
6
- metadata.gz: 82ef9bb8c77df77e6ba4dfd4af7429cc16ee7ff1993fcdf7b04d20b22b992dbcde2c16b2d28ea28d2e1cce431ce0ec9c22dc222c884d83f03fa0e67b09d44877
7
- data.tar.gz: a35703890431c38cbe64514cd616b4c755138fe4ffedc90383d5addcb21a5fa36799435733fb0503fefa1a8d4b41b19ec7761542a68d90ef9cb9ce9daf0a4d46
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
- # Recursively walk the AST to build indentation deltas for block structures.
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
- def walk_ast_for_indentation(node, deltas)
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, :hash, :array, :class, :module, :sclass, :def, :defs, :case, :while, :until, :for, :kwbegin
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
 
@@ -5,6 +5,6 @@
5
5
 
6
6
  module RuboCop
7
7
  module Socketry
8
- VERSION = "0.2.0"
8
+ VERSION = "0.2.2"
9
9
  end
10
10
  end
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.0
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.7
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