Skip to content

setup-project.py and validate-repository-naming.py: no row runs step (4) from a folder other than the standard's checkout, LinkSources.__init__ is over SonarCloud's 15, and --link-remedy=openXdox=a/openYdox=b gives openYdox the words b #991

Closed

Description

@brettheap

Goal: #949's three leftovers are closed in one change: a row that fails if step (4) joins a relative SHAPE_PIN_SOURCE_<LINK> to any folder but the standard's checkout, LinkSources.__init__ back under SonarCloud's cognitive complexity of 15, and a hand-typed --link-remedy whose owner part holds = read for the link it names.

Filed by lane openRepoShape-3, from lane 4's RV949 re-check of #949 at ced3d7c2 (its SHOULD-3, NIT-8 and the optional tightening, comment 6254587539), on #949.

State. #949 LANDED while this was being drafted: squash a19d69cb4, merged 2026-10-19T11:49:51Z, with its head still ced3d7c2. So this is read at origin/main ae63d450, and setup-project.py, scripts/validate-repository-naming.py, tests/test_setup_project_py.py and tests/test_chain_remedy_callers.py there are byte-identical to ced3d7c2 (git diff --quiet ced3d7c2 HEAD -- <file> for each). Every file and line below is main's, and is the reviewed head's.

The three items:

  • SHOULD-3, mutant NJ. pin_sources_joined(shape_root, env) (setup-project.py:2554) joins each non-empty SHAPE_PIN_SOURCE_* to shape_root with os.path.join(str(shape_root), value) (:2572); check_names calls it with the standard's checkout (:2650). The row test_step_four_reads_a_relative_variable_where_step_five_does (tests/test_setup_project_py.py:3255, its run_entry call at :3281-3287) starts setup with run_entry, whose working folder is REPO, the standard's checkout, unless cwd= is passed (:110). So the folder setup starts in and the standard's checkout are one folder in the row. The unit test test_only_a_pin_source_variable_that_names_a_path_is_joined (:3301) calls pin_sources_joined(REPO, ...) in process, and pytest's working folder is also REPO. A person who runs setup from another folder is the case no test holds.
  • NIT-8, python:S3776. LinkSources.__init__ (scripts/validate-repository-naming.py:278-358) gained the --link-remedy loop (:302-312). SonarCloud's bot comment on setup-project.py and validate-repository-naming.py: step (4) reads and names what step (5) does, --link-remedy reads a link holding =, strips its words and notes an unused one, and the Windows hand clone passes -c core.autocrlf=false (#907, #926) #949 of 2026-10-18T19:19Z reported "1 New issue" with the quality gate passed, and RV949 names it: python:S3776, CRITICAL, at :278, "Refactor this function to reduce its Cognitive Complexity from 19 to the 15 allowed". By the rule's counting the loop costs 4 (the for, the if one level in, and its and), so the function stood at 15 before it. I could not run Sonar here (the sonarqube MCP did not connect) and did not check whether the issue is open on main after the merge; the figure is the bot's and RV949's.
  • Optional tightening. LinkSources._read_remedy (:360-384) reads a --link-remedy value at its LAST = that leaves a chain link before it and words after it, taking repo_basename of the text before that = (:376-382). repo_basename keeps what follows the last /, so openXdox=a/openYdox=b is read as the link openYdox with the words b.

What happens. Measured on a detached clone at ae63d450, a stub gh (exit 97) first on PATH, GH_TOKEN=bogus, an empty GH_CONFIG_DIR, GIT_SSH_COMMAND=false, /usr/bin/python3 -m pytest -q -p no:cacheprovider --basetemp=<scratch>/bt -o tmp_path_retention_policy=failed.

NJ (os.path.join(str(shape_root), value) changed to os.path.join(os.getcwd(), value) at setup-project.py:2572):

-k "test_step_four_reads_a_relative_variable_where_step_five_does or test_only_a_pin_source_variable_that_names_a_path_is_joined"

unmutated:                                   3 passed, 245 deselected
NJ:                                          3 passed, 245 deselected     <- the mutant survives
the row's run_entry call given cwd=tmp_path:
   unmutated                                 3 passed
   NJ                                        2 failed ([verified], [breaking]), 1 passed

The one test that still passes under NJ is the unit test. A shape_root other than the working folder would fail it too. The files were put back with git checkout and setup-project.py checked by its sha256 (4acf81df..., the digest RV949 gave).

The remedy reading, by calling LinkSources([], <chain>, remedies=[<value>]) on main and on a copy of the gate with the tightening below:

value                        chain                              at main              with the tightening
openXdox=a/openYdox=b        openXdox, openYdox, openInk        openYdox: b          openXdox: a/openYdox=b
opensoft/open=y=words        opensoft/open=y, openInk           open=y: words        open=y: words
open=y=words                 open=y, openInk                    open=y: words        open=y: words

Through the gate end to end, --link-remedy=openXdox=a/openYdox=b: main before #949 (cf66102f) read it at the first = and gave openXdox the words (a/openYdox=b); main now gives openYdox the words (b) and leaves openXdox the gate's own. RV949 accepted that side effect (it happens only by hand: setup's words never hold =), and noted the tightening as optional.

Evidence.

Direction.

  • SHOULD-3. Add cwd=tmp_path to the row's run_entry call (tests/test_setup_project_py.py:3281-3287). In the unit test, pass a shape_root that is not the working folder (for example tmp_path) and expect os.path.join(str(tmp_path), relative). Skip the row where os.path.relpath raises, as it does now.
  • NIT-8. Move the remedy loop into a method, _read_remedies(remedies), that fills self.remedies, self.remedy_reading and self.remedy_replaced; __init__ calls it once. A prototype of that move (the loop lifted whole), made together with the tightening below, kept tests/test_chain_remedy_callers.py at 50 passed (run on the ced3d7c2 tree, which is main's). Recount the complexity with Sonar, not by hand.
  • Tightening. In _read_remedy's loop, skip a candidate whose text before its last / holds = (owner = typed[:at].rpartition("/")[0]; take the candidate only when "=" not in owner). Prototype: the table's right-hand column, and tests/test_chain_remedy_callers.py 50 passed with it and the move together. An owner is never spelled with =, so opensoft/open=y=words still reads right.
  • setup-project.py and validate-repository-naming.py: step (4) reads and names what step (5) does, --link-remedy reads a link holding =, strips its words and notes an unused one, and the Windows hand clone passes -c core.autocrlf=false (#907, #926) #949 has landed, so this is a change of its own. Do NIT-8 and the tightening in one change to the gate, so the pinned copy re-pins once.

Verify.

  • Under NJ the row fails (2 failed) and unmutated it passes; the unit test, given a shape_root that is not the working folder, fails under NJ too, since NJ ignores shape_root. Re-make NJ, and keep the sha256 of setup-project.py before and after.
  • tests/test_setup_project_py.py -k "relative_variable or only_a_pin_source_variable" passes.
  • LinkSources.__init__ no longer appears in SonarCloud's new issues on the pull request.
  • tests/test_chain_remedy_callers.py and tests/test_pinned_copy_text.py pass; a new row holds openXdox=a/openYdox=b giving openXdox its words, and one holds opensoft/open=y=words.
  • tests/test_cli_reference.py passes if the help text changes; one file at a time under a stub gh.

Size: S.

Lane: openreposhape-3 (openRepoShape-3)

Activity

  1. added this to the v1.2.0 milestone on Oct 19, 2026
  2. brettheap commented on Oct 19, 2026

    @brettheap
    ContributorAuthor

    CLAIMED — lane openRepoShape-3, session b30e8b49-f249-4668-adb1-1dbfa93c09e1@Eagle, 2026-10-19T19:02:58Z, for #991

    Logged in lanes/log/openRepoShape-3.md at 3419225f19105daf9b999345e98c3a01d3944c6d.

    The three reads (lane-collision-protocol Rule 1):

    1. existing `CLAIMED —` comments on opensoft/openRepoShape#991:
       none
    2. `gh pr list --repo opensoft/openRepoShape --state all --search "#991"`, kept where the row or its body names `#991`:
       none
    3. `git ls-remote --heads [email protected]:opensoft/openRepoShape` branches naming `991` as a whole token:
       none
    
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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions