Find raw try/catch smells

Proprietary

Search-only bundle for try/catch shapes worth reviewing: collapse-to-null and collapse-to-default branches (candidates for runCatching { }.getOrNull() / .getOrDefault(...)), empty catches that lose every detail of the failure, broad catch (Exception) / catch (Throwable) clauses, catches that absorb the exception without logging or rethrowing, e.printStackTrace() calls that should be logger calls, nested try/catch trees, and catch parameters that are bound but never read.

org.openrewrite.kotlin.functional.FindTryCatchSmells$KtRecipe
mod run . --recipe='org.openrewrite.kotlin.functional.FindTryCatchSmells$KtRecipe'

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.

Recipe list

It runs these recipes, in this order.

  1. Find try { x } catch (e: Exception) { null } patterns
  2. Find try { x } catch (e: Exception) { default } patterns
  3. Find empty catch blocks
  4. Find broad catch (e: Exception) / catch (e: Throwable) clauses
  5. Find non-empty catch blocks that neither log nor rethrow
  6. Find e.printStackTrace() calls inside a catch block
  7. Find try { } catch { } nested inside another try { } catch { }
  8. Find catch (e: Exception) clauses whose body never references e