From 438bbf54ca8bc4a40ef42e7d26c0027251e5ff30 Mon Sep 17 00:00:00 2001 From: viralpraxis Date: Sun, 26 Oct 2025 15:22:23 +0400 Subject: [PATCH] Avoid `Kernel.suppress(Exception)` ref: https://github.com/rubocop/rubocop-rails/issues/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 --- README.adoc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.adoc b/README.adoc index cf59a43..30485e2 100644 --- a/README.adoc +++ b/README.adoc @@ -1768,6 +1768,23 @@ datetime.to_fs(:db) 42.to_fs(:human) ---- +=== Do not rescue `Exception` via `Kernel.suppress` [[kernel-suppress-exception] + +Using `Kernel.suppress(Exception)` is effectively equivalent to rescuing `Exception`, which is discouraged. + +[source,ruby] +---- +# bad +suppress(Exception) do + do_something +end + +# good +supress(StandardError) do + do_something +end +---- + == Time === Time Zone Config [[tz-config]]