Phase 1 — Mechanical auto-fixes
| PR |
Category |
What |
Count |
Files |
Status |
| #23926 |
PLR5501, PLR1730, C420, PLR1704, C414 |
if/else → early return, useless else, sorted(list()), shadow variable, redundant set literal |
46 |
28 |
✅ Merged |
| #23937 |
PLR6201 |
in (...) → in {...} literal-membership |
608 |
133 |
✅ Merged |
| #23940 |
C401, C416, C408, PLR1722 |
Unnecessary comprehensions, list()/dict() vs literal, class Foo: → class Foo |
21 |
19 |
✅ Merged |
Total auto-fixed: 675 issues across 180 files.
Phase 2 — Structural refactoring (C901 complexity)
codex_responses_adapter.py (4 PRs, stacked)
| PR |
Function |
Complexity |
Status |
| #23951 |
_chat_messages_to_responses_input |
45 → <10 |
Open |
| #23952 |
_preflight_codex_input_items |
51 → <10 |
Open |
| #23954 |
_preflight_codex_api_kwargs |
36 → 21 |
Open |
| #23957 |
_normalize_codex_response |
37 → 18 |
Open |
anthropic_adapter.py
| PR |
Function |
Complexity |
Status |
| #23968 |
convert_messages_to_anthropic |
79 → 10 |
Open |
Total C901 eliminated: ~179 points (248 → ~69) across 5 functions.
Current state
$ ruff check --select C,PLR --statistics
857 PLR2004 magic-value-comparison
807 C901 complex-structure
522 PLR0912 too-many-branches
398 PLR0915 too-many-statements
339 PLR1702 too-many-nested-blocks
320 PLR6301 no-self-use
314 PLR0911 too-many-return-statements
281 PLR0914 too-many-locals
223 PLR0913 too-many-arguments
140 PLR0917 too-many-positional-arguments
25 PLR1714 repeated-equality-comparison
20 PLR6104 non-augmented-assignment
9 PLR0916 too-many-boolean-expressions
7 PLR0904 too-many-public-methods
1 PLR0124 comparison-with-itself
1 PLR6201 literal-membership
─────────────────────────
4,264 total
Remaining C901 elephants
| Complexity |
Function |
File |
| 408 |
run_conversation |
run_agent.py |
| 262 |
_run_agent |
gateway/run.py |
| 168 |
AIAgent.__init__ |
run_agent.py |
| 122 |
_cmd_update_impl |
hermes_cli/main.py |
| 84 |
run_sync |
gateway/run.py |
| 72 |
resolve_provider_client |
agent/auxiliary_client.py |
| 46 |
start_gateway |
gateway/run.py |
| 39 |
_handle_max_iterations |
run_agent.py |
| 37 |
_watch_update_progress + send_progress_messages |
gateway/run.py |
| 36 |
_run_agent_via_proxy |
gateway/run.py |
| 35 |
main |
cli.py |
| 34 |
_get_clarify_display |
cli.py |
| 31 |
build_anthropic_kwargs |
anthropic_adapter.py |
Pending auto-fix categories (low-hanging fruit)
| Category |
Count |
Risk |
| PLR2004 |
857 |
High noise — only file individual issues for domain-significant magic numbers |
| PLR6301 |
320 |
Method → function extraction (no-self-use) |
| PLR1702 |
339 |
Nested block reduction (needs manual refactor, not auto-fix) |
Strategy
- Continue structural refactoring — target the remaining C901 elephants above
- After structural series completes — evaluate PLR6301 (no-self-use) auto-fix batch
- PLR2004 — skip bulk; file individual issues only for domain-significant magic numbers
Phase 1 — Mechanical auto-fixes
if/else→ early return, uselesselse,sorted(list()), shadow variable, redundant set literalin (...)→in {...}literal-membershiplist()/dict()vs literal,class Foo:→class FooTotal auto-fixed: 675 issues across 180 files.
Phase 2 — Structural refactoring (C901 complexity)
codex_responses_adapter.py (4 PRs, stacked)
_chat_messages_to_responses_input_preflight_codex_input_items_preflight_codex_api_kwargs_normalize_codex_responseanthropic_adapter.py
convert_messages_to_anthropicTotal C901 eliminated: ~179 points (248 → ~69) across 5 functions.
Current state
Remaining C901 elephants
run_conversation_run_agentAIAgent.__init___cmd_update_implrun_syncresolve_provider_clientstart_gateway_handle_max_iterations_watch_update_progress+send_progress_messages_run_agent_via_proxymain_get_clarify_displaybuild_anthropic_kwargsPending auto-fix categories (low-hanging fruit)
Strategy