Skip to content

scripts/validate-repository-naming.py, render-cli-reference.py, bump-leg.py and family.py: six functions exceed Sonar's cognitive-complexity cap of 15 (python:S3776) #136

Closed

Description

@brettheap

Lane: openreposhape-2 (openRepoShape-2)

What is wrong. SonarCloud has six open python:S3776 issues (cognitive
complexity, limit 15) against four standard-side scripts nothing has started
work on yet. Queried against main at d682127:

$ curl -s 'https://sonarcloud.io/api/issues/search?componentKeys=opensoft_openRepoShape&rules=python:S3776&statuses=OPEN&ps=200'
scripts/validate-repository-naming.py 116  Refactor … Cognitive Complexity from 35 to the 15 allowed.  AaByZVkHSQwNCdYHsGQx
scripts/validate-repository-naming.py 224  Refactor … Cognitive Complexity from 18 to the 15 allowed.  AaByZVkHSQwNCdYHsGQy
scripts/validate-repository-naming.py 271  Refactor … Cognitive Complexity from 39 to the 15 allowed.  AaBkX77ehhjEdvdJLHrT
scripts/render-cli-reference.py       492  Refactor … Cognitive Complexity from 16 to the 15 allowed.  AaCOfKnUH8ceQjdPBeiU
scripts/bump-leg.py                   438  Refactor … Cognitive Complexity from 28 to the 15 allowed.  AaBv6CIRDk5q6SaK6B3r
scripts/family.py                     435  Refactor … Cognitive Complexity from 51 to the 15 allowed.  AaBqXiNMNpHOiCCpi2_A
file function line Sonar cc complexipy cc what it is
scripts/validate-repository-naming.py _describe 116 35 38 the --explain row for one name: a four-way claim/admission ladder, run once per family, with a nested three-way note inside the admission branch
scripts/validate-repository-naming.py _targets_from_project 224 18 18 walks a project.yaml's legs, classifying each and folding its own findings and the manifest's topic check into the one loop
scripts/validate-repository-naming.py main 271 39 50 argument handling, three target sources (CLI names, --project, stdin), the classify-and-print loop and the WARNING/FINDING trailer, in one body
scripts/render-cli-reference.py render 492 16 20 composes the whole docs/cli.md document — orientation paragraph, per-tool sections and subcommands — in one function
scripts/bump-leg.py cmd_bump 438 28 29 the leg-advance refusal ladder, the git plumbing and the one commit, in one body (already carries # noqa: C901 for flake8's separate McCabe check)
scripts/family.py cmd_init 435 51 40 the family-holder landing-path and init refusal ladder, the repository creation and the first commit, in one body (also # noqa: C901 already)

complexipy --max-complexity-allowed 15 against the same four files at
origin/main (d682127) agrees on which six functions are over the line, with
the largest divergence at family.py::cmd_init (Sonar 51, complexipy 40) —
consistent with the two tools weighting some constructs differently, not with
either missing a function.

What would fix it. Extract a helper per decision (a leading-underscore
private function per each file's own convention, with a WHY docstring saying
what it decides and that it was split from its parent for this issue);
early returns over nested if/else; a dispatch table only where one already
suits a closed set. Behaviour stays byte-identical: no message text, exit
code, output order, file written or exception type changes — this is code
motion, not a fix, and a bug noticed along the way is left for a follow-up
issue rather than changed here.

scripts/validate-repository-naming.py is digest-pinned and ships into every
scaffolded project: it must stay Python 3.9-safe (it already carries from __future__ import annotations, so deferred-annotation syntax is fine; no
match, no runtime X | Y). scripts/render-cli-reference.py GENERATES
docs/cli.md; any change to it is followed by
python3 scripts/render-cli-reference.py and
python3 -m pytest -q tests/test_cli_reference.py so the committed copy stays
byte-identical to the generated one. scripts/bump-leg.py::cmd_bump moves the
gitlink, the pin and every workflow @<sha> in one commit and refuses on the
tracking branch or an unpushed commit — every git command and its order stays
exactly as it runs today. scripts/family.py::cmd_init keeps every refusal
text and printed landing path identical, including the doubled
<Family>/<Family> and the --trailer/GITMODULES handling from #112/#125.

Activity

  1. brettheap commented on Sep 12, 2026

    @brettheap
    ContributorAuthor

    (lane openreposhape-2 (openRepoShape-2), 2026-09-12T03:35Z) CLAIMED — session 9c6378ea, on Brett Heap's word 'lets fix the 35 sonar issues' (2026-09-12T02:1xZ). Branch refactor/scripts-cognitive-complexity, worktree ~/projects/openRepoShape--s3776-scripts on Eagle, from origin/main d682127. Scope: the six python:S3776 functions in scripts/validate-repository-naming.py, scripts/render-cli-reference.py, scripts/bump-leg.py and scripts/family.py.

  2. brettheap commented on Sep 12, 2026

    @brettheap
    ContributorAuthor

    (lane openreposhape-2 (openRepoShape-2), 2026-09-12T14:48Z) PULL REQUEST OPEN: #145 (head 73e7201).

  3. brettheap commented on Sep 12, 2026

    @brettheap
    ContributorAuthor

    (lane openreposhape-2 (openRepoShape-2), 2026-09-12T15:23:25Z) MERGED — #145 → 57ddeac (squash), on Brett Heap's word 'go, fan out on all of it, hold the doctor refactor'. scripts: validate-repository-naming.py's _describe, _targets_from_project and main (35/18/39 → 2/6/12; the digest-pinned naming validator, still Python 3.9-safe), render-cli-reference.py's render (16 → 6, docs/cli.md byte-identical), bump-leg.py's cmd_bump (28 → 5) and family.py's cmd_init (51 → 2) — pure extractions in original call order, every refusal id and remediation text, git command and print unchanged, rollback blocks moved whole; PR-scoped Sonar 0; Copilot one typo and two docstring nits taken then clean; 1136 passed / 1 skipped. Object complete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions