Skip to content

chore(quality): the local SonarQube and IDE findings of 2026-11-29, no behaviour change - #90

Merged
acn-ericlaw merged 1 commit into
mainfrom
chore/sonar-round-2026-11-29
Nov 30, 2026
Merged

acn-ericlaw merged 1 commit into
mainfrom
chore/sonar-round-2026-11-29

Conversation

@acn-ericlaw

Copy link
Copy Markdown
Collaborator

What

The findings of a local SonarQube and IDE inspection round (2026-11-29) on this release's code, with no behaviour change: 432 analyzer rows in 16 files, 398 fixed and 34 kept with their reason on the line. The twin of the Node pack's round.

  • Cognitive complexity (32 rows). Each function over 15 is split along its seams, every check in the order it ran and with the message it raised: 14 in the agent tools, 8 in rest_automation.py, 4 in rest_routing.py, 3 in agent-question, 2 in ask-person, and the attachments loader of the LLM helper.
  • Literals and expressions. A literal repeated three times or more is a constant. The two identifier expressions of the graph tools use \w under re.ASCII. The Cypher pattern over the regex limit is built from three named parts with the same pattern and flags. A # noqa carries its code alone, the reason on the line above. A list() copy stays only where the loop changes the size of what it walks.
  • Tests (332 rows). Every composite assertion is split into single ones, a pytest.raises block holds the one call that must raise, and a module global is patched through monkeypatch.
  • PyCharm's own findings are taken where a local beside the existing guard, a @staticmethod or a rename settles them.
  • Kept, each with # NOSONAR - <reason> on its line (34 rows). 32 methods that are async because their interface is (the in-memory stores beside their PostgreSQL and Redis siblings, a callback the host awaits), the copy in the memory store's unaudited(), and one false positive on dataclasses.replace.

Why

The code quality sprint before release 4.12.31. The files are the ones this release added or changed, so a finding left in them ships as new code.

A finding kept on purpose now says why on its line, the maintainer's ruling in this round, so the next scan shows only what is new.

For the reviewer

  1. The one hard requirement was no behaviour change. Every message a refactored function raises is the one it raised, and the shared vector files pass unchanged. Each refactored module was compared, old against new, on generated input. For the agent tools that was 270,237 comparisons of results, refusals, log lines and the calls made on a fake backend, with no difference, and 47 one-line changes planted in copies were all caught.
  2. \w needs re.ASCII. Without the flag it matches about 143,000 characters where the class had 63. With it the verdict is the same on every code point.
  3. A marker sits only where the analyzer reports. PyCharm's own inspections do not read it, so a finding of that kind is fixed or left, never marked.
  4. Every extracted helper was checked for a name that was a local where the code stood and is the module's where it stands now. None is.
  5. Not in this pull request: behaviours the reading showed that are wrong, or that differ from the Node twin. Each is a behaviour change and gets a pull request of its own.

Upgrade note

None.

Verification

  • ruff check . clean, basedpyright 0 errors and 0 warnings, pytest 921 passed and 76 skipped, the totals before the change.
  • With a live Redis, PostgreSQL and Neo4j in throwaway local containers, the 68 tests that are skipped without them run too: 989 passed, 8 skipped. CI has no such services and skips them, so this is their only run. The 8 left need the live MCP recipe servers.
  • The floor: no Python 3.11 is installed on the machine, so the suite ran on 3.14. In its place basedpyright --pythonversion 3.11 reports 0 errors and ruff's py311 target is clean, each after a control file with 3.12 syntax and library calls was flagged. This pull request's 3.11 job is the first run on the floor.
  • The analyzer bundled in SonarQube for IDE (the sonar-python jar of the PyCharm plugin), run headless with the 407 checks of its default profile, reproduces the 432 rows on the files as they were and reports none on the nine source files now outside the 34 marked lines. None of the scan's four test rules is left in the test files.
  • Not run: PyCharm itself, so its own inspections are as the scan showed them except where a fix is named above.

Beside this pull request

  • The Node twin is raised beside this one in mercury-nodejs, on a branch of the same name.
  • The session's memory files are not in this pull request.

Co-Authored-By: Claude Fable 5.2 noreply@anthropic.com

🤖 Generated with Claude Code

…o behaviour change

A local SonarQube and IDE inspection round over this release's code, before 4.12.31: 432 analyzer rows in 16
files, 398 fixed and 34 kept with their reason on the line. In lockstep with the Node pack.

Cognitive complexity (32 rows): each function over 15 is split along its seams, every check in the order it ran
and with the message it raised - 14 in the agent tools (the listing, the search, the page ranges, the HTML
reader's start tag, the address resolution, a fetch, the crawl, the database's errors, the value renderer, a
node's properties, the ingest plan, the schema, the boot, describe's states), 8 in rest_automation.py, 4 in
rest_routing.py, 3 in agent-question, 2 in ask-person, and the attachments loader of the LLM helper.

Literals and expressions: a literal repeated three times or more is a constant; the two identifier expressions
of the graph tools use \w under re.ASCII, which keeps them to the characters the class spelled out; the Cypher
pattern over the regex limit is built from three named parts with the same pattern and flags; a "# noqa"
carries its code alone, the reason on the line above; a list() copy stays only where the loop changes the size
of what it walks.

Tests (332 rows): every composite assertion is split into single ones, a pytest.raises block holds the one call
that must raise, and a module global is patched through monkeypatch.

PyCharm's own findings are taken where a local beside the existing guard, a @staticmethod or a rename settles
them.

Kept, each with "# NOSONAR - <reason>" on its line: 32 methods that are async because their interface is (the
in-memory stores beside their PostgreSQL and Redis siblings, a callback the host awaits), the copy in the memory
store's unaudited(), and one false positive on dataclasses.replace.

ruff and basedpyright clean; pytest 921 passed, 76 skipped, as before. The IDE's own analyzer, run headless,
reproduces the 432 rows on the files as they were and reports none on the scanned sources now outside the 34
marked lines; none of the scan's four test rules is left in the tests.

CHANGELOG Unreleased Changed 11.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@acn-ericlaw acn-ericlaw self-assigned this Nov 30, 2026
@acn-ericlaw
acn-ericlaw merged commit d2d40bd into main Nov 30, 2026
6 checks passed
@acn-ericlaw
acn-ericlaw deleted the chore/sonar-round-2026-11-29 branch November 30, 2026 03:50
acn-ericlaw added a commit that referenced this pull request Nov 30, 2026
…90) and the defect round (#91), both merged; a kept finding says why on its line; the round's defects thread closed

Two session logs: the round with no behaviour change (432 analyzer rows, 398 fixed and 34 kept with their reason)
and the round that fixed what it had written down, in lockstep with the Node pack - one address table and one
glob grammar for the agent tools with a matcher bounded in time, one rule for a number in the LLM helper, one for
a ticket and for a row id, rest.yaml flags as the Java engine reads them, the engines' error body at the edge.

Continuity: the rule for a kept finding and for re-scanning a round with the IDE's own analyzer, the
maintainer's ruling of 2026-11-29. The thread that held the first round's findings is closed with #91.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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.

1 participant