Skip to content

Clear the SonarCloud findings the 1.1.0 release PR reported - #546

Merged
JE-Chen merged 12 commits into
devfrom
fix/sonar-release-1.1.0
Nov 2, 2026
Merged

JE-Chen merged 12 commits into
devfrom
fix/sonar-release-1.1.0

Conversation

@JE-Chen

@JE-Chen JE-Chen commented Nov 2, 2026

Copy link
Copy Markdown
Member

SonarCloud listed 2,087 open maintainability findings in the new code of #538. The quality gate passed, but the list was noise for every later review.

Tests (1,616)

  • S9073 (1,208): each flagged assert a and b is now one assert per condition, so a failure names the condition that broke. Done by an AST rewrite of the flagged lines only.
  • S5778 (400): each pytest.raises block now holds only the call under test. Setup calls are hoisted, and branching bodies moved into a local function. Where the hoisted call was itself the one that raised, it stayed inside.
  • S3415, S8714, S9081, S9100, S5906: fixed in place.

Package, scripts, examples (471)

  • S1192 (292): scripts/generate_facade_exports.py now emits one constant per owner module that the generated bindings repeat (249 findings). The remaining 43 are named constants. A generated owner named like a credential carries a justified nosec B105.
  • Redundant except-tuple classes (checked against the real MRO), \d/\w regexes kept ASCII-only with re.ASCII, nested conditionals and with statements, cognitive-complexity splits, empty blocks given a reason.
  • The Script Builder table's 34 append runs became extend. The built spec list is byte-identical, and most of that file's diff is re-indentation.
  • 33 findings are intended or false positives and are left in the code: 15 S5754 (BaseException handlers that re-raise through a helper or hand the error to another thread), 12 S5886 (dataclasses.replace inferred as DataclassInstance), 4 S7504 (list() snapshots of a dict the loop mutates), 1 S5655, and 1 kotlin S6624.

Verification

  • Full headless suite: 17,667 passed, 147 skipped, 0 failed.
  • ruff, bandit (no findings), radon cc -nc, generate_facade_exports.py --check, and typing_contract_verify.py in both modes all pass.
  • Doc-count and budget tests pass, and the architecture_explore.md line counts were re-measured.
  • Update log: U-20261102-02.

… broke

Sonar S9073: an assert joining several conditions with 'and' reports
only that the whole expression was false. One assert per condition keeps
the failing check visible in the pytest output.
The generated tables repeated every owner's dotted path once per exported
name, up to 58 times for agent_runtime. The generator now emits one
module-level constant per owner that more than one binding shares and
refers to it, so a moved module is one line in the diff.
Hoisting the setup calls out of the block means it can only pass when the call under test raises.
Hoisting the setup calls out of the block means it can only pass for the call under test.
Hoisting the setup calls out of the block means it can only pass for the call under test.
Hoisting the setup calls out of the block means it can only pass for the call under test.
…tion

The command schema registered each spec with its own append call and
repeated the same placeholder strings across many fields; group each run
of registrations into one extend call and give the shared placeholders a
name, as the schema already does for its other hints. The Japanese
catalogue and two sync examples get the same treatment for their
repeated literals. The built spec list is byte-for-byte unchanged.
Drop exception classes that an except tuple already covers through a
base class (AgentTaskError is a ValueError, AuthorizationError an
OSError, UnicodeError a ValueError), keeping a note of what the base
covers. Name repeated messages and SQL statements, merge nested with
statements, replace nested conditional expressions with helpers, and
split request_json, merge_buckets, the MCP task handler and the file
receiver binding into smaller functions without changing behaviour.

Regexes moved to \d / \w are compiled with re.ASCII so they still accept
only ASCII digits and identifier characters.
Each contract check (attribute definition, alias resolution, optional loader
shape, child collisions, baseline comparison) now lives in its own function,
so every step reads on its own and no function exceeds the cognitive
complexity budget. The generated bindings are byte-identical and --check
still passes.
… modules

Name repeated messages, SQL and literals once; drop exception classes an
except tuple already covers through a base class; unfold nested conditional
expressions and merge directly nested with statements; extract the skill
proposal step from the task loop and the config route bodies from their
registration so both stay within the complexity budget.

Character-class shorthands keep their ASCII-only meaning through re.ASCII,
subset tests use issubset() instead of a negated <=, and every intentionally
empty authorization scope block now says that entering it is the check.
No behaviour changes.
…e-measure the map

The owner constant for utils.secret_ref matched bandit's B105 name test.
The generator now marks such a constant with a justified nosec, since it
binds a module path. architecture_explore.md line counts follow the
Sonar cleanup's changes.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

The loginctl reader's pair comprehension traded S7494 for S7500; a plain
partition loop satisfies both. asset_references returned a one-element,
an empty or a sorted tuple; every path now ends in the same sorted return.
@sonarqubecloud

sonarqubecloud Bot commented Nov 2, 2026

Copy link
Copy Markdown

@JE-Chen
JE-Chen merged commit 4c174a1 into dev Nov 2, 2026
7 checks passed
@JE-Chen JE-Chen mentioned this pull request Nov 2, 2026
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