Skip to content

chore(perf): clear ruff PERF401 & PERF203 backlog — closes #490, #495 - #2921

Merged
squid-protocol merged 2 commits into
mainfrom
chore/perf-lint-cleanup
Sep 9, 2026
Merged

squid-protocol merged 2 commits into
mainfrom
chore/perf-lint-cleanup

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

What

Clears the PERF401 (#490) and PERF203 (#495) ruff findings from the #469 lint-baseline epic. Neither rule is a blind mechanical fix, so each site was reviewed against the actual code (via a fan-out of higher-effort review agents).

PERF401 (#490) — 6 sites, rewritten by hand

ruff offers no autofix for these. All are pure for+append mappings (no side effects / filtering / try), so for→comprehension/.extend() is behavior-preserving:
cobol_refractor_controller.py, recorders/audit_recorder.py, recorders/sbom_recorder.py, standards/language_lens.py, tools/cobol_to_cobol/cobol_jcl_forge.py, tools/cobol_to_java/cobol_to_java_agent_forge.py.

PERF203 (#495) — 11 sites, documented not "fixed"

The naive fix (hoist try out of the loop) would destroy fault isolation — turning "skip one bad file, continue the batch" into "abort the whole batch on the first error". Per-site review found:

  • 10 sites are intentional per-iteration isolation → kept, with # noqa: PERF203 -- <why> explaining the isolation.
  • 1 site (terabyte_log_scanner.py) sys.exit()s in its except, so the loop-level try cost is moot → kept + noqa.

Verification

  • python tests/ruff_audit.py --ci → no new findings beyond the regenerated 53-key baseline (was 70); ruff format --check clean. Pinned ruff==0.16.0.
  • Targeted pytest: 7776 passed; the sole failure is a pre-existing security_auditor test needing xgboost (absent from the local venv, unrelated — that file only gained a comment here).

Closes #490, closes #495

🤖 Generated with Claude Code

https://claude.ai/code/session_01QBL6TAMVXRUY7iQyy9Ysvi

Resolves the PERF401 (#490) and PERF203 (#495) findings tracked by the #469
lint-baseline epic. Analysis was done with per-site review (a fan-out of
higher-effort agents over the actual code), because neither rule is a blind
mechanical fix.

- PERF401 (#490): 6 manual `for`+`append` -> comprehension/`.extend()` rewrites.
  All are pure mappings with no side effects/filtering/try, so the rewrites are
  behavior-preserving. ruff offers no autofix for these, so each was written and
  reviewed by hand.
- PERF203 (#495): 11 `try/except`-in-loop sites. 10 are INTENTIONAL per-iteration
  fault isolation (skip a bad file/artifact, continue the batch); hoisting the
  try would turn one bad item into a whole-batch abort. The 11th
  (terabyte_log_scanner.py) exits the process in its `except`, so the loop-level
  try cost is moot. All 11 are kept and documented with `# noqa: PERF203 -- <why>`
  rather than mechanically "fixed".

Lint pinned to ruff==0.16.0. tests/ruff_audit_baseline.json regenerated 70 -> 53;
`python tests/ruff_audit.py --ci` passes (no new findings, format clean).

Closes #490
Closes #495

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QBL6TAMVXRUY7iQyy9Ysvi
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit 2253d3e into main Sep 9, 2026
30 checks passed
@squid-protocol
squid-protocol deleted the chore/perf-lint-cleanup branch September 9, 2026 15:59
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.

Ruff PERF203: try/except-in-loop findings (review fault-isolation semantics first) Ruff PERF401: list-comprehension findings in recorders & tools

1 participant