rubocop-socketry 0.10.0 → 0.11.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: 36f3f182b831bb4fbae7b9eddb5504cecb05d10616de4b25307d83baa9e578e1
4
- data.tar.gz: a12e31b5ad9834c890ecc20afd9d443ba0b6a760078ee4a5550e63b731e45c4e
3
+ metadata.gz: a21ad68f85134a6078dd60a1c413e3bf0b7ef289ff5a0bfe9f248f441c9c4311
4
+ data.tar.gz: 146288237609f6577df58e013d0803737e25fa2815c8706740c004bc4c0099c6
5
5
  SHA512:
6
- metadata.gz: ffe0bfaa3a740753d590f0852f87374976c0a76e931d0184f63fc553f37a4c5547838d6ab1103f658fecdc4cc3c2a7c30502e813f7987e0dad25d3f4e86ac74f
7
- data.tar.gz: c1b77f49c5bdb0fee928666a1f9436b37ae2d38f35cc17fc5aa274034cd61a31002d7435caf9d4e308fe49ed871e28987d3a9355a255c00c9ec1c06047d4afbe
6
+ metadata.gz: cbfb896891caa89fc6cbdb8aa470520f7412608fad2f6b785d3d5adbb9907787e9bb6f9489dd34e256b067ec917ae054c4e3d6b56c47462a79a0baea49fb3fd3
7
+ data.tar.gz: 38a101cefb2e29216db89282579c227878b4630703275d8a038dadee2cb11bd95385b828b9f11a29012eb2c5ce396c17ad95a5b289d42b6bf4c7d8faa9ba56e2
checksums.yaml.gz.sig CHANGED
Binary file
@@ -27,6 +27,8 @@ module RuboCop
27
27
  MSG_REMOVE_SPACE_LAMBDA = "Remove space before the opening brace for lambdas/procs."
28
28
  MSG_REMOVE_SPACE_EXPRESSION = "Remove space before the opening brace for expressions."
29
29
 
30
+ # Check each brace-delimited block for the required spacing before `{`.
31
+ # @parameter node [RuboCop::AST::BlockNode] The block node to inspect.
30
32
  def on_block(node)
31
33
  return unless node.braces?
32
34
 
@@ -49,6 +49,7 @@ module RuboCop
49
49
  def on_new_investigation
50
50
  indentation_deltas = build_indentation_deltas
51
51
  current_level = 0
52
+ semantic_level = 0
52
53
 
53
54
  processed_source.lines.each_with_index do |line, index|
54
55
  line_number = index + 1
@@ -75,7 +76,16 @@ module RuboCop
75
76
  end
76
77
  end
77
78
 
78
- current_level += delta
79
+ if delta > 0
80
+ current_level += 1
81
+ semantic_level += delta
82
+ elsif delta < 0
83
+ semantic_level += delta
84
+ current_level = [current_level, semantic_level].min
85
+ end
86
+
87
+ current_level = [current_level, 0].max
88
+ semantic_level = [semantic_level, 0].max
79
89
  end
80
90
  end
81
91
 
@@ -87,10 +97,6 @@ module RuboCop
87
97
  def build_indentation_deltas
88
98
  Hash.new(0).tap do |deltas|
89
99
  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
100
  end
95
101
  end
96
102
 
@@ -114,8 +120,8 @@ module RuboCop
114
120
  end
115
121
  end
116
122
  when :if
117
- # We don't want to add deltas for elsif, because it's handled by the if node:
118
- if node.keyword == "if" || node.keyword == "unless"
123
+ # Modifier conditionals don't introduce indentation, and elsif is handled by the if node:
124
+ if !node.modifier_form? && (node.keyword == "if" || node.keyword == "unless")
119
125
  if location = node.location
120
126
  deltas[location.line] += 1
121
127
  deltas[location.last_line] -= 1
@@ -66,6 +66,8 @@ module RuboCop
66
66
 
67
67
  EXCEPTION_VARIABLES = %i[$! $@ $ERROR_INFO $ERROR_POSITION].freeze
68
68
 
69
+ # Check each global variable reference for unsafe exception state access.
70
+ # @parameter node [RuboCop::AST::GlobalVariableNode] The global variable node to inspect.
69
71
  def on_gvar(node)
70
72
  variable_name = node.children.first
71
73
 
@@ -122,4 +124,3 @@ module RuboCop
122
124
  end
123
125
  end
124
126
  end
125
-
@@ -5,6 +5,6 @@
5
5
 
6
6
  module RuboCop
7
7
  module Socketry
8
- VERSION = "0.10.0"
8
+ VERSION = "0.11.1"
9
9
  end
10
10
  end
data/readme.md CHANGED
@@ -27,6 +27,14 @@ Layout/ConsistentBlankLineIndentation:
27
27
 
28
28
  Please see the [project releases](https://socketry.github.io/rubocop-socketry/releases/index) for all releases.
29
29
 
30
+ ### v0.11.1
31
+
32
+ - Fixed `Layout/ConsistentBlankLineIndentation` to ignore modifier conditionals when calculating indentation depth.
33
+
34
+ ### v0.11.0
35
+
36
+ - Fixed `Layout/ConsistentBlankLineIndentation` to preserve semantic indentation depth for same-line nested structures, avoiding negative indentation levels when later closing lines are processed.
37
+
30
38
  ### v0.10.0
31
39
 
32
40
  - Fixed `Layout/BlockDelimiterSpacing` to correctly treat a block as a statement (requiring space before `{`) when it is the sole body of a multi-line outer block or method/class/module definition. Previously, the absence of a `:begin` wrapper in the AST caused such blocks (e.g. `Async {foo}` or `let(:bar) {baz}` inside a `describe`/`context` block) to be misclassified as expression-context and have their space incorrectly removed.
@@ -65,10 +73,6 @@ Please see the [project releases](https://socketry.github.io/rubocop-socketry/re
65
73
 
66
74
  - Added `Layout/BlockDelimiterSpacing` cop to enforce consistent spacing before block delimiters.
67
75
 
68
- ### v0.1.0
69
-
70
- - Initial implementation of `Layout/ConsistentBlankLineIndentation`.
71
-
72
76
  ## Contributing
73
77
 
74
78
  We welcome contributions to this project.
data/releases.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Releases
2
2
 
3
+ ## v0.11.1
4
+
5
+ - Fixed `Layout/ConsistentBlankLineIndentation` to ignore modifier conditionals when calculating indentation depth.
6
+
7
+ ## v0.11.0
8
+
9
+ - Fixed `Layout/ConsistentBlankLineIndentation` to preserve semantic indentation depth for same-line nested structures, avoiding negative indentation levels when later closing lines are processed.
10
+
3
11
  ## v0.10.0
4
12
 
5
13
  - Fixed `Layout/BlockDelimiterSpacing` to correctly treat a block as a statement (requiring space before `{`) when it is the sole body of a multi-line outer block or method/class/module definition. Previously, the absence of a `:begin` wrapper in the AST caused such blocks (e.g. `Async {foo}` or `let(:bar) {baz}` inside a `describe`/`context` block) to be misclassified as expression-context and have their space incorrectly removed.
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.10.0
4
+ version: 0.11.1
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.6
106
+ rubygems_version: 4.0.10
107
107
  specification_version: 4
108
108
  summary: RuboCop rules for Socketry projects
109
109
  test_files: []
metadata.gz.sig CHANGED
Binary file