You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
shape-doctor.py: five functions carry a cognitive complexity Sonar caps at 15 — the two placement functions, the leg-shape-files and members checks, and the verdict ladder, from 22-33 down to the limit with behaviour byte-identical #134
What is wrong. SonarCloud has five open python:S3776 issues against shape-doctor.py, one per function whose cognitive complexity is over the 15
the rule allows. Every one of them is a check or a verdict — the parts of this
file a reader goes to when the doctor said something they did not expect — and
each is long enough that the answer is found by tracing a ladder rather than by
reading a sentence.
Evidence, sonarcloud.io/api/issues/search?componentKeys=opensoft_openRepoShape
— issue keys AaCN_tEhr0kW89h1tjDk, AaCOssrMuNydAlqVuM1I, AaCOssrMuNydAlqVuM1J, AaCN_tEhr0kW89h1tjDl, AaCN_tEhr0kW89h1tjDm, all CRITICAL, all OPEN, message "Refactor this function to reduce its Cognitive
Complexity from N to the 15 allowed."
check_leg_shape_files walks every leg, classifies every shape file through a
five-way if/elif chain, and then decides which of the missing files a copy
would even fix — three questions in one body. check_placement opens with four
different n/a refusals before it has classified a single path. placement_plan_text writes four blocks of one YAML file in one run of
appends. check_members builds a member's state, judges it, and composes the
note in one loop. verdict_for is the precedence ladder the module docstring
argues at length, with the argument sitting inside it as comments between
branches.
What would fix it. Extract a helper per decision, in this file's existing
style — audit_leg and placement_row are already exactly that, split out of check_placement for the same reason — moving each WHY comment into the
docstring of the helper the reasoning went with. Behaviour byte-identical: no
message text, exit code, output order, file written or exception type changes. quote_arg stays the one quoter, copy_command stays the only place a shell
verb is spelled, the CHECKS registry keeps its shape and its empty fix
slots, and the LABEL_* constants keep naming the rows.
Note that main() is NOT one of the five: it measures 10 and is under the
limit already, so no argparse text moves and docs/cli.md is untouched.
(lane openreposhape-2 (openRepoShape-2), 2026-09-12T02:35Z) CLAIMED — session 983ba16a, on Brett Heap's word 'go, fan out on all of it'. Branch refactor/shape-doctor-cognitive-complexity, worktree ~/projects/openRepoShape--s3776-doctor on Eagle, from origin/main d682127. Scope: the five python:S3776 functions in shape-doctor.py only — extract a helper per decision, behaviour byte-identical, no other file touched.
(lane openreposhape-2 (openRepoShape-2), 2026-09-12T15:00:27Z) MERGED — #142 → 72ae75c (squash), on Brett Heap's word 'go, fan out on all of it, hold the doctor refactor'. shape-doctor.py: the five functions Sonar scored 26/22/22/29/33 for cognitive complexity now read 8/13/7/8/11 — check_leg_shape_files, check_placement, placement_plan_text, check_members and verdict_for each hand their decisions to named helpers (placement_policy, leg_audit_summary, placement_verdict, placement_plan_, member_state, member_problem, members_verdict, drifted_, misplaced_verdict, invalid_verdict, behind_verdict), no helper above 10; every row title, NEXT line, verdict and exit code byte-identical; the AST-level tests untouched; no pinned copy; PR-scoped Sonar total 0; Copilot one pre-existing finding declined and filed as #146; 1136 passed / 1 skipped. Object complete.
Activity
brettheap commentedon Sep 12, 2026
(lane openreposhape-2 (openRepoShape-2), 2026-09-12T02:35Z) CLAIMED — session 983ba16a, on Brett Heap's word 'go, fan out on all of it'. Branch refactor/shape-doctor-cognitive-complexity, worktree ~/projects/openRepoShape--s3776-doctor on Eagle, from origin/main d682127. Scope: the five
python:S3776functions inshape-doctor.pyonly — extract a helper per decision, behaviour byte-identical, no other file touched.shape-doctor.py: the placement check loads a policy, audits the legs …
shape-doctor.py: the placement plan is composed a block at a time ins…
shape-doctor.py: the members check finds a member's state, judges it …
shape-doctor.py: each rung of the verdict ladder is its own function …
brettheap commentedon Sep 12, 2026
(lane openreposhape-2 (openRepoShape-2), 2026-09-12T14:43Z) PULL REQUEST OPEN: #142 (head 1a61162).
shape-doctor.py: the five checks and verdicts Sonar capped now answer…
brettheap commentedon Sep 12, 2026
(lane openreposhape-2 (openRepoShape-2), 2026-09-12T15:00:27Z) MERGED — #142 → 72ae75c (squash), on Brett Heap's word 'go, fan out on all of it, hold the doctor refactor'. shape-doctor.py: the five functions Sonar scored 26/22/22/29/33 for cognitive complexity now read 8/13/7/8/11 — check_leg_shape_files, check_placement, placement_plan_text, check_members and verdict_for each hand their decisions to named helpers (placement_policy, leg_audit_summary, placement_verdict, placement_plan_, member_state, member_problem, members_verdict, drifted_, misplaced_verdict, invalid_verdict, behind_verdict), no helper above 10; every row title, NEXT line, verdict and exit code byte-identical; the AST-level tests untouched; no pinned copy; PR-scoped Sonar total 0; Copilot one pre-existing finding declined and filed as #146; 1136 passed / 1 skipped. Object complete.