rubocop-dev_doc 0.20.0 → 0.20.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: 34e773b91c19e7fcf99043ec8241ccfda6fedddd52bc17e11b3693852a226710
4
- data.tar.gz: cd2f7c295e98c4963c0914ecf1131a192d69a905315e533f3f4e9571245c01af
3
+ metadata.gz: 41a73fb70d0abd2db9c0e14bbc073859f05cadec33494d35c3ef52b60007d8fc
4
+ data.tar.gz: 5608f88d60896a43884829039c94667bcd4001a6d7802c05825478e19d007d42
5
5
  SHA512:
6
- metadata.gz: f517e4d2f400bd915fd40eb9efde0e4cfd30c13f2e4fb289a2cf1bf489dc27a2888db2d0ab3482c3648f4e33397274fdae4262ba593bf31ed5c1720b073637b9
7
- data.tar.gz: 62751bf6320874a8834de4bff344bf2fd2e905d71371c03aa7402812c7909528d25acaf3ccbb1f31490c0b8adf30b6a77376de399c83384efba2588639b21380
6
+ metadata.gz: 255fbbcb74f4d773bda61f7e797e4b55c2d58f59fe1ed9afb8990a99a96a0b103b923732616db698ed74959bd5e1a9dad5345f53ced1f9f2de14d6198b309abc
7
+ data.tar.gz: '060297a07336e974aa49f206b129892aa0f7c579709dd0d0a2f45130341e98e5606215e01c0aeb6f37b66b378b681902ffe3a295f8dd076a53593c9671dde062'
@@ -96,7 +96,7 @@ module RuboCop
96
96
  ].freeze
97
97
 
98
98
  def on_rescue(node)
99
- check_writes(node.body) if guards_record_not_unique?(node)
99
+ check_writes(node) if guards_record_not_unique?(node)
100
100
  end
101
101
 
102
102
  private
@@ -111,37 +111,47 @@ module RuboCop
111
111
  end
112
112
  end
113
113
 
114
- def check_writes(region)
114
+ def check_writes(rescue_node)
115
+ region = rescue_node.body
115
116
  return unless region
116
117
 
117
118
  region.each_node(:send, :csend) do |candidate|
118
119
  next unless PERSISTENCE_WRITES.include?(candidate.method_name)
119
- next if inside_rescue_body?(candidate, region)
120
+ next if inside_rescue_body?(candidate, rescue_node)
120
121
 
121
- check_savepoint(candidate)
122
+ check_savepoint(candidate, rescue_node)
122
123
  check_index(candidate)
123
124
  end
124
125
  end
125
126
 
127
+ # Ancestors of a write up to (excluding) the rescue node itself —
128
+ # everything lexically inside this rescue's guarded region.
129
+ def ancestors_within_rescue(candidate, rescue_node)
130
+ candidate.each_ancestor.take_while { |ancestor| !ancestor.equal?(rescue_node) }
131
+ end
132
+
126
133
  # A write lexically inside a nested rescue's body is not guarded
127
134
  # by THIS rescue — its own clause owns it.
128
- def inside_rescue_body?(candidate, region)
129
- candidate.each_ancestor.take_while { |ancestor| !ancestor.equal?(region) }.any?(&:resbody_type?)
135
+ def inside_rescue_body?(candidate, rescue_node)
136
+ ancestors_within_rescue(candidate, rescue_node).any?(&:resbody_type?)
130
137
  end
131
138
 
132
- def check_savepoint(write)
133
- return if requires_new_ancestor?(write)
139
+ def check_savepoint(write, rescue_node)
140
+ return if requires_new_within_rescue?(write, rescue_node)
134
141
 
135
142
  add_offense(write.loc.selector, message: SAVEPOINT_MSG)
136
143
  end
137
144
 
138
- # Any lexically enclosing `transaction(requires_new: true)` counts:
139
- # the failed INSERT rolls back to that savepoint however deeply the
140
- # write nests inside the guarded region. A do-block's send node is
141
- # the block's CHILD, so block ancestors are inspected through their
142
- # send node.
143
- def requires_new_ancestor?(write)
144
- write.each_ancestor.any? do |ancestor|
145
+ # The savepoint must be opened INSIDE this rescue's guarded region
146
+ # (between the write and the rescue node): the failed INSERT aborts
147
+ # the enclosing savepoint, so a `requires_new` transaction opened
148
+ # OUTSIDE the rescue (wrapping the whole begin/rescue, or an
149
+ # enclosing loop) leaves the rescue body running inside the aborted
150
+ # savepoint — its own first statement raises
151
+ # PG::InFailedSqlTransaction. A do-block's send node is the block's
152
+ # CHILD, so block ancestors are inspected through their send node.
153
+ def requires_new_within_rescue?(write, rescue_node)
154
+ ancestors_within_rescue(write, rescue_node).any? do |ancestor|
145
155
  transaction = enclosing_transaction(ancestor)
146
156
  transaction && requires_new?(transaction)
147
157
  end
@@ -1,5 +1,5 @@
1
1
  module RuboCop
2
2
  module DevDoc
3
- VERSION = "0.20.0".freeze
3
+ VERSION = "0.20.1".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-dev_doc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.0
4
+ version: 0.20.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - dev-doc contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-11-17 00:00:00.000000000 Z
11
+ date: 2026-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport