rubocop-socketry 0.8.0 → 0.9.0

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: 0dacbb6af420eedc76cec483085c0bac470416faf318a2ddaee52980c3a43f59
4
- data.tar.gz: 4f128fdca62a037f273ee0ab534446e08df7b97bd578b6ca50f287f3f63e8d43
3
+ metadata.gz: bcb70c0ac2421d12d0a38c1e28338e67b3d57e1bef6d9d0121a00c6d042953d5
4
+ data.tar.gz: f6754cbd98784332753e86c9fc5261ba8214708f94c4d7ca2e7783f21520c956
5
5
  SHA512:
6
- metadata.gz: b87895050fdfd00301e6f3f33bd742f87f6ffcc46963f33f33df285e7f8d3e9079b24fb6be8aee2352c697df1d36d7fddf9cca90e9453da047b3fad2cd5208ab
7
- data.tar.gz: 0b21c56b058e9a97716e37846c52238afb798d5b584f6920820706aa93e11b41a5f1e5258b5171d7842c943916d9b93b53b9674e4c4a0f1e9fd016f2d7ba9839
6
+ metadata.gz: 696a82e7609dc56b42bb91bbd4a13d998c1bc64f65e227fc63dcba97e0f15740e883007e1766cc9b30e36ad30fca6e74b03d3aca10c0f23fce47dd87c9b1062a
7
+ data.tar.gz: 60e83ca55460e2af2dac385563f139edb7fbe4e0fc2b0b7de82c0110ca06c4360d6b4c639278a09f64be313ccfe4c442a3ecc4a7e024923e86487967ce5fc15a
checksums.yaml.gz.sig CHANGED
Binary file
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2025-2026, by Samuel Williams.
4
+ # Copyright, 2025, by Samuel Williams.
5
5
 
6
6
  require "rubocop"
7
7
 
@@ -81,28 +81,14 @@ module RuboCop
81
81
 
82
82
  # Check if the block is part of an expression (not a top-level statement)
83
83
  # Top-level statements are directly inside a :begin node (file/method body)
84
- # or inside do...end block bodies, and should have space.
85
- # Everything else (expressions, nested arguments, etc.) should not have space.
84
+ # and should have space. Everything else (expressions, nested blocks) should not.
86
85
  def part_of_expression?(node)
87
86
  parent = node.parent
88
87
  return false unless parent
89
88
 
90
89
  # If parent is a :begin node (sequence of statements), this is top-level
91
- return false if parent.type == :begin
92
-
93
- # If parent is a :block node, check if it's a do...end block
94
- # do...end blocks contain statements (no space)
95
- # {...} blocks contain expressions (space required)
96
- if parent.type == :block
97
- # do...end blocks use keywords, {...} blocks use braces
98
- return false unless parent.braces?
99
- end
100
-
101
- # Check if we're in a :kwbegin node (begin...end block body)
102
- return false if parent.type == :kwbegin
103
-
104
- # Otherwise, it's part of an expression (assignment, argument, etc.)
105
- true
90
+ # Otherwise, it's part of an expression or nested context
91
+ parent.type != :begin
106
92
  end
107
93
 
108
94
  # Check that there's no space before the opening brace for lambdas
@@ -61,6 +61,7 @@ module RuboCop
61
61
  # Check blank lines for correct indentation:
62
62
  if line.strip.empty?
63
63
  expected_indentation = indentation(current_level)
64
+
64
65
  if line != expected_indentation
65
66
  add_offense(
66
67
  source_range(processed_source.buffer, line_number, 0, line.length),
@@ -84,9 +85,13 @@ module RuboCop
84
85
  # This method walks the AST to identify where indentation should increase or decrease.
85
86
  # @returns [Hash(Integer, Integer)] A hash where keys are line numbers and values are deltas.
86
87
  def build_indentation_deltas
87
- deltas = Hash.new(0)
88
- walk_ast_for_indentation(processed_source.ast, deltas)
89
- deltas
88
+ Hash.new(0).tap do |deltas|
89
+ walk_ast_for_indentation(processed_source.ast, deltas)
90
+
91
+ # Cap deltas to a maximum of +1 or -1 per line to handle cases where
92
+ # multiple structures open/close on the same line (e.g., `[..., {`)
93
+ deltas.transform_values!{|delta| delta.nil? ? nil : delta.clamp(-1, 1)}
94
+ end
90
95
  end
91
96
 
92
97
  STRUCTURAL_NODES = [:array, :hash, :class, :module, :sclass, :def, :defs, :if, :if, :while, :until, :for, :case, :kwbegin, :regexp]
@@ -5,6 +5,6 @@
5
5
 
6
6
  module RuboCop
7
7
  module Socketry
8
- VERSION = "0.8.0"
8
+ VERSION = "0.9.0"
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.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  - !ruby/object:Gem::Version
104
104
  version: '0'
105
105
  requirements: []
106
- rubygems_version: 4.0.3
106
+ rubygems_version: 4.0.6
107
107
  specification_version: 4
108
108
  summary: RuboCop rules for Socketry projects
109
109
  test_files: []
metadata.gz.sig CHANGED
Binary file