Skip to content

Commit 438bbf5

Browse files
committed
Avoid Kernel.suppress(Exception)
ref: rubocop/rubocop-rails#1547 Using `Kernel.suppress(Exception) { ?? }` is effectively equivalent to: ```ruby begin ?? rescue Exception end ``` Since rescuing `Exception` directly is discouraged by `Lint/RescueException`, it makes sense to discourage this usage as well. See https://rubystyle.guide/#no-blind-rescues
1 parent 86bffd4 commit 438bbf5

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

README.adoc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1768,6 +1768,23 @@ datetime.to_fs(:db)
17681768
42.to_fs(:human)
17691769
----
17701770

1771+
=== Do not rescue `Exception` via `Kernel.suppress` [[kernel-suppress-exception]
1772+
1773+
Using `Kernel.suppress(Exception)` is effectively equivalent to rescuing `Exception`, which is discouraged.
1774+
1775+
[source,ruby]
1776+
----
1777+
# bad
1778+
suppress(Exception) do
1779+
do_something
1780+
end
1781+
1782+
# good
1783+
supress(StandardError) do
1784+
do_something
1785+
end
1786+
----
1787+
17711788
== Time
17721789

17731790
=== Time Zone Config [[tz-config]]

0 commit comments

Comments
 (0)