rubocop-socketry 0.9.0 → 0.11.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: bcb70c0ac2421d12d0a38c1e28338e67b3d57e1bef6d9d0121a00c6d042953d5
4
- data.tar.gz: f6754cbd98784332753e86c9fc5261ba8214708f94c4d7ca2e7783f21520c956
3
+ metadata.gz: 6afce664365a0b7fa9a50a48b6aebc9f05b1de2755f8bc133a85b051b0819d79
4
+ data.tar.gz: fb88cb2a6b157b82269bc2afa51cbe08d9327b8d885b4b7baab08180bf2dcd62
5
5
  SHA512:
6
- metadata.gz: 696a82e7609dc56b42bb91bbd4a13d998c1bc64f65e227fc63dcba97e0f15740e883007e1766cc9b30e36ad30fca6e74b03d3aca10c0f23fce47dd87c9b1062a
7
- data.tar.gz: 60e83ca55460e2af2dac385563f139edb7fbe4e0fc2b0b7de82c0110ca06c4360d6b4c639278a09f64be313ccfe4c442a3ecc4a7e024923e86487967ce5fc15a
6
+ metadata.gz: a433da1fbc1394419fc20e73c4c3a883b5a18ca58b7e0ff46e070a9f7aee7139e6dee1edda29053c1d2015650714db1aaa3152ae479716ef6269d880191e4dc0
7
+ data.tar.gz: 3aa6a42823410aae0c2b7889915c0857c54efbcb3f83e8a7f07a83cf98014a862ec479f1ba0db7aeb1017bb3b4aabd3197be7a194d6f7a4473723eee5f265300
checksums.yaml.gz.sig CHANGED
@@ -1,3 +1,2 @@
1
- ��=�-��rY�!5A��Y�.��7LY붺�
2
- ��� L5V����b
3
- ��is�0'(Ȟ���ASKUk�� �D���*zKm4�T�#4��3����:|җK뷪e��!u@�*L 1��45p*M�����+�M>��v��eK���,���_�$�B�L�1���},P���C�v��/�`L9�/�8���Fޱ2by˵QN�������I5���� J�F\��8o-?2�d����X4 �<:���9��y�&��:싺Y@�M��4���'O��;��θ��eC���T63=�9�M���W��ߡ�\eEX���ͱ�D�ޗ��9��s�u��b��8r�F�8���+u�A�
1
+ OHBp��&�s&o_�i���R�2�N��K-��@����7�ʓµ���27�,����"K/
2
+ B;�Z��g@�����f�e42���*��"���=�6٠��IqC��'(�;��[�c{_g>^�<s�z#�/Ş��GF�9��j��}�@�������?�����
@@ -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
 
@@ -86,9 +88,25 @@ module RuboCop
86
88
  parent = node.parent
87
89
  return false unless parent
88
90
 
89
- # If parent is a :begin node (sequence of statements), this is top-level
90
- # Otherwise, it's part of an expression or nested context
91
- parent.type != :begin
91
+ case parent.type
92
+ when :begin
93
+ # Sequence of statements — this is a top-level statement.
94
+ false
95
+ when :block, :numblock
96
+ # When a block is the sole body statement of an outer block there is no
97
+ # :begin wrapper; the outer block node is the direct parent.
98
+ # Only the body slot counts as a statement context, and only when the
99
+ # outer block itself spans multiple lines (e.g. a do…end describe/context
100
+ # block). Single-line inline blocks (`foo {bar{baz}}`) keep their
101
+ # compact style.
102
+ parent.body == node ? !parent.multiline? : true
103
+ when :def, :defs, :class, :module, :sclass
104
+ # Same situation for method / class / module bodies with a single
105
+ # statement — they are always multi-line in practice.
106
+ parent.body != node
107
+ else
108
+ true
109
+ end
92
110
  end
93
111
 
94
112
  # Check that there's no space before the opening brace for lambdas
@@ -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
 
@@ -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.9.0"
8
+ VERSION = "0.11.0"
9
9
  end
10
10
  end
data/readme.md CHANGED
@@ -27,6 +27,20 @@ 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.0
31
+
32
+ - Fixed `Layout/ConsistentBlankLineIndentation` to preserve semantic indentation depth for same-line nested structures, avoiding negative indentation levels when later closing lines are processed.
33
+
34
+ ### v0.10.0
35
+
36
+ - 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.
37
+ - Single-line inline outer blocks (e.g. `foo {bar{baz}}`) continue to use compact style with no space before the inner brace.
38
+
39
+ ### v0.9.0
40
+
41
+ - Fixed `Layout/ConsistentBlankLineIndentation` to correctly handle files containing multiple blocks.
42
+ - Expanded `Layout/BlockDelimiterSpacing` test coverage to include method chaining scenarios.
43
+
30
44
  ### v0.8.0
31
45
 
32
46
  - Fixed `Layout/BlockDelimiterSpacing` to correctly distinguish between statement and expression contexts for blocks inside `do...end` blocks.
data/releases.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Releases
2
2
 
3
+ ## v0.11.0
4
+
5
+ - Fixed `Layout/ConsistentBlankLineIndentation` to preserve semantic indentation depth for same-line nested structures, avoiding negative indentation levels when later closing lines are processed.
6
+
7
+ ## v0.10.0
8
+
9
+ - 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.
10
+ - Single-line inline outer blocks (e.g. `foo {bar{baz}}`) continue to use compact style with no space before the inner brace.
11
+
12
+ ## v0.9.0
13
+
14
+ - Fixed `Layout/ConsistentBlankLineIndentation` to correctly handle files containing multiple blocks.
15
+ - Expanded `Layout/BlockDelimiterSpacing` test coverage to include method chaining scenarios.
16
+
3
17
  ## v0.8.0
4
18
 
5
19
  - Fixed `Layout/BlockDelimiterSpacing` to correctly distinguish between statement and expression contexts for blocks inside `do...end` blocks.
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.9.0
4
+ version: 0.11.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.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