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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 41a73fb70d0abd2db9c0e14bbc073859f05cadec33494d35c3ef52b60007d8fc
|
|
4
|
+
data.tar.gz: 5608f88d60896a43884829039c94667bcd4001a6d7802c05825478e19d007d42
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
|
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(
|
|
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,
|
|
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,
|
|
129
|
-
candidate
|
|
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
|
|
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
|
-
#
|
|
139
|
-
# the
|
|
140
|
-
#
|
|
141
|
-
# the
|
|
142
|
-
#
|
|
143
|
-
|
|
144
|
-
|
|
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
|
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.
|
|
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-
|
|
11
|
+
date: 2026-11-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|