Skip to content

Add ruff BLE001 as a swallowed-exception smell#62

Merged
devill merged 1 commit into
devill:mainfrom
LiinaSuoniemi:swallowed-exception
Jun 25, 2026
Merged

Add ruff BLE001 as a swallowed-exception smell#62
devill merged 1 commit into
devill:mainfrom
LiinaSuoniemi:swallowed-exception

Conversation

@LiinaSuoniemi

Copy link
Copy Markdown
Contributor

What

Adds ruff's BLE001 (blind-except) as a new swallowed-exception smell, with a coaching prompt that tells the agent what to do instead of just reporting the rule.

Why

A broad except that swallows the error is a silent-failure risk. ruff already flags it; this turns the bare "Do not catch blind exception" into actionable guidance, in the habit-hooks style.

Design note

swallowed-exception is the first smell sourced only from ruff, with no TypeScript twin (the existing ruff smells reuse an eslint or knip smell). So Rule.source needed a new value. I added 'ruff' to RuleSource and to config validation, mirroring how knip is a spec-driven source. Happy to take a different approach if you'd prefer.

Severity is suggested, not enforced: blind-except has legitimate top-level uses (request handlers, worker loops), so it coaches rather than failing the run. Easy to flip.

Changes

  • src/config/tool-smells.ts (RUFF_SPEC): add BLE001 to --select, produces, and the map.
  • src/config/catalogue.ts: new swallowed-exception rule (source: 'ruff').
  • src/types.ts and src/config/validate.ts: add the 'ruff' source.
  • src/prompts/swallowed-exception.md: the coaching prompt.
  • docs/smell-vocabulary.md and docs/DECISIONS.md: catalogue row, ruff mapping row, decision record.
  • src/python-acceptance.test.ts: a test that BLE001 fires swallowed-exception and that a specific, named except does not. Gated on ruff like the other Python tests (skipped on CI without the toolchain).

Testing

Full suite green locally with ruff and deptry installed (503 passed). typecheck and lint clean.

Map ruff's blind-except rule to a new swallowed-exception smell with a coaching prompt. Add 'ruff' as a Rule source (first ruff-only smell, mirroring knip). Severity suggested.

@devill devill left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleanly wired: new 'ruff' source is metadata-only (no double-emit), prompt auto-registers via the catalogue, changedFilesOnly/severity consistent with sibling smells. TS swallowed-exception equivalent is a separate, narrower concern (no BLE001 analog in untyped JS catch).

@devill devill merged commit 55e5529 into devill:main Jun 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants