slop/swallowed-errors
Errors are not swallowed
| Severity | info |
| Tiers | all |
| Stacks | any |
| Scope | root |
| Kind | expr |
| Source | library v0.5.0 |
| Selected by | fleetlint-slop@v0.5.0 |
Requirement
No empty catch blocks (JavaScript, Java, Kotlin, C#, PHP, Dart), no except: pass, no _ = err, no Ruby rescue nil or rescue; end. Only single-line forms are detected; the stack’s linter covers the rest.
Why
A swallowed error turns a failure with a cause into a wrong result without one.
Check
For each item in:
codegrep("nontest", r'catch\s*(\([^)]*\))?\s*\{\s*\}|except[^:]*:\s*pass\b|\b_\s*=\s*err\b|\.catch\(\s*\(\)\s*=>\s*(\{\s*\}|null|undefined)\s*\)|catch \(_\)|\brescue\s+nil\b|\brescue(\s+[\w:]+)?(\s*=>\s*\w+)?\s*;\s*end\b')falseFix
Handle the error, wrap and return it, or log it where it is handled.
Agent instruction: Propagate the error with context unless the surrounding code shows it is safe to ignore; then say why in a comment.
Sources
- https://go.dev/wiki/CodeReviewComments (guidance, Handle Errors)
- https://docs.astral.sh/ruff/rules/try-except-pass/ (check, S110)
- https://eslint.org/docs/latest/rules/no-empty (check, no-empty)
- https://detekt.dev/docs/rules/empty-blocks/ (check, EmptyCatchBlock)
- https://docs.rubocop.org/rubocop/latest/cops_lint.html (check, Lint/SuppressedException)
- https://fleetlint.org/baseline/#slop
- https://fleetlint.org/slop/#errors-types-and-robustness
Generated by fleetlint docs from catalog v0.5.0.