rubocop-socketry 0.1.4 → 0.2.1

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: 726a243627d25f8f76dc549f59278267787272cf69796f60d7287832dc62d5db
4
- data.tar.gz: a29ea75820682a9c02de65b587208dce15034ac951d5c8ed0a247ef1b70fd74d
3
+ metadata.gz: 7054dc76500e02a8df56ff00b5d847396cf4622119b7eca147f7eec162ec7b93
4
+ data.tar.gz: 7e50277305f240048445e71e087948c3e1c9f0f7a8c5bd85b8700348c47fa88d
5
5
  SHA512:
6
- metadata.gz: b81fce2ec333469ac9958d677de1e0d9f406ea3c325b910485b5614f5d647c3ed809f176a1cb491464e8c0bdd4199a1ae4cd7b6110bf08c6602bb4020ebe9992
7
- data.tar.gz: f483f8ecf7b635d9dbabcb52dc26e1104d3a766bf047fc13583ed8d032c002aa4f5df43a1e498bf98df282346ab35db827baf99ebccedaada372f296970dd32f
6
+ metadata.gz: 57d9906646551e6803b2a57b1f00d7b85c46b09dd6fff0da0daae38ae6ac41213f6c0ba6281bfcc65a8e0234b541833ad33cacc32b7d13e9a04f03a7c3b5e438
7
+ data.tar.gz: bdc2fb54732ed2ca0af31a0d7a1dcdf0756830198423cdddd3fe2cb57c93a42519c2e3690d821a6062f750d0dcdf88d57e80dc5aea63c0d302ac8b14b5f606fb
checksums.yaml.gz.sig CHANGED
Binary file
@@ -89,16 +89,36 @@ module RuboCop
89
89
  deltas
90
90
  end
91
91
 
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
+ return receiver.type != :send
98
+ end
99
+ end
100
+
101
+ return false
102
+ end
103
+
92
104
  # Recursively walk the AST to build indentation deltas for block structures.
93
105
  # This method identifies nodes that should affect indentation and records the deltas.
94
106
  # @parameter node [Parser::AST::Node] The current AST node to process.
95
107
  # @parameter deltas [Hash(Integer, Integer)] The deltas hash to populate.
96
- def walk_ast_for_indentation(node, deltas)
108
+ # @parameter parent [Parser::AST::Node, nil] The parent node for context.
109
+ def walk_ast_for_indentation(node, deltas, parent = nil)
97
110
  return unless node.is_a?(Parser::AST::Node)
98
111
 
99
112
  case node.type
100
- when :block, :hash, :array, :class, :module, :sclass, :def, :defs, :case, :while, :until, :for, :kwbegin
101
-
113
+ when :block
114
+ # For blocks, we need to be careful about method receiver collections
115
+ if location = node.location
116
+ unless receiver_handles_indentation(node)
117
+ deltas[location.line] += 1
118
+ deltas[location.last_line] -= 1
119
+ end
120
+ end
121
+ when :hash, :array, :class, :module, :sclass, :def, :defs, :case, :while, :until, :for, :kwbegin
102
122
  if location = node.location
103
123
  deltas[location.line] += 1
104
124
  deltas[location.last_line] -= 1
@@ -114,22 +134,16 @@ module RuboCop
114
134
  when :dstr
115
135
  if location = node.location
116
136
  if location.is_a?(Parser::Source::Map::Heredoc) and body = location.heredoc_body
117
- if location.expression.source.start_with?("<<~")
118
- # Squiggly heredoc - indentation is significant, add deltas
119
- deltas[body.line] += 1
120
- deltas[body.last_line] -= 1
121
- else
122
- # Non-squiggly heredoc - ignore indentation on these lines
123
- (body.line..body.last_line).each do |line|
124
- deltas[line] = nil
125
- end
137
+ # Don't touch the indentation of heredoc bodies:
138
+ (body.line..body.last_line).each do |line|
139
+ deltas[line] = nil
126
140
  end
127
141
  end
128
142
  end
129
143
  end
130
144
 
131
145
  node.children.each do |child|
132
- walk_ast_for_indentation(child, deltas)
146
+ walk_ast_for_indentation(child, deltas, node)
133
147
  end
134
148
  end
135
149
 
@@ -5,6 +5,6 @@
5
5
 
6
6
  module RuboCop
7
7
  module Socketry
8
- VERSION = "0.1.4"
8
+ VERSION = "0.2.1"
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.1.4
4
+ version: 0.2.1
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