Skip to content

Initiative: SonarCloud org-wide debt reduction & rule tuning #593

Open

Description

@don-petry

SonarCloud org-wide debt reduction & rule tuning

Roll-up initiative from the 2026-07-03 org-wide SonarCloud review. 310 open issues, 0 bugs — health is fundamentally good; the volume is maintainability noise concentrated in a few rules, plus supply-chain hardening findings. This initiative tracks the tuning (config) and automation (mechanical fixes) work to drive it down and keep it down.

Snapshot

Dimension Breakdown
Type 258 code smell · 52 vulnerability · 0 bug
Severity 10 critical · 151 major · 145 minor · 4 info
Language 167 js · 71 shell · 50 githubactions · 10 py · 6 ts
Top project google-app-scripts 194 (63%), broodly 29, TalkTerm 18, markets 17, .github 15

Three rules = half the backlog: javascript:S5906 (96), shelldre:S7688 (48), githubactions:S7635 (18).

Scope note: pulled via anonymous SonarCloud API — public projects only. petry-projects_.github-private is not included and should be reviewed separately with a token.


Tier 1 — Tuning (config; ~110 issues, near-zero risk)

  • De-provision the broodminder-export legacy SonarCloud project. It duplicate-scans the same repo as broodminder-export2 (identical fingerprints: S3776×3, S8707×2, S7688, S7682). Inflates org metrics and double-counts 3 CRITICALs. Delete the legacy project in SonarCloud admin. (manual; needs Sonar admin)
  • S5906 test-assertion rewrite → tracked in Rewrite Jest assertions to specific matchers (SonarCloud S5906 ×96) google-app-scripts#416 (rewrite generic Jest assertions to specific matchers; clears all 96). User decision: rewrite tests, not suppress/exclude.

Tier 2 — Automation (mechanical fixes via PRs, per PR-workflow rule)

  • S7635 (secrets:inherit, ×18) — apply the established # NOSONAR(githubactions:S7635) inline marker (see initiative_pipeline_s7635_gap playbook) to the remaining caller stubs: markets×5, broodminder-export2×4, repo-template×4, bmad-bgreat-suite×3, TalkTerm×2.
  • Shell hygiene codemod (~68) — batch per repo: S7688 [ → [[ (48), S7677 redirect-to-stderr >&2 (8), S7682 explicit-return (7), S7679 assign positional to local (5). Repos: broodly, google-app-scripts, TalkTerm, bmad, broodminder.
  • GitHub Actions / dependency hardening (~28) — fix at the source in .github reusables where possible so callers inherit: S6505 --ignore-scripts (9), S8543 exact-version (7), S8541 --only-binary :all: (6), S8544/S8545 lockfile-enforcing install (6). Concentrated in markets and .github.

Tier 3 — Real work (human/agent review, not automatable)

  • S3776 cognitive-complexity refactors (10 CRITICAL) — worst is a broodminder discover.py function at complexity 85 (limit 15); also 4 google-app-scripts functions. Genuine refactors.
  • pythonsecurity:S8707 path-traversal review (×4) — LLM/CLI arg file-system escape in broodminder-export discover.py. Only security findings here needing code judgment; the other 48 "vulnerabilities" are supply-chain lockfile/version hardening (Tier 2).

Keep-it-down (prevent regression)

  • Once counts are low, consider a quality-gate on new code (Sonar's "Clean as You Code") so PRs can't add new S5906/S7688/S7635 debt.
  • Fold the S7635 marker and shell [[ conventions into .github/standards so new repos start clean (repo-template already shows 4 S7635 — the template itself leaks the pattern).

Related memory / playbooks

  • initiative_pipeline_s7635_gap — canonical S7635 NOSONAR-marker fix
  • ring_rollout_870 — S7637 channel-pin exemption context (multicriteria, not sonar.exclusions)
  • rulesets_relocation_575 — SonarCloud config now lives under .github/standards

Activity

  1. added
    dev-leadFor dev-lead agent pickup
    dev-lead:hands-offOpt an item out of the dev-lead persona automation entirely
    on Jul 3, 2026
  2. don-petry commented on Jul 3, 2026

    @don-petry
    ContributorAuthor

    Child issues filed (per-repo-per-workstream)

    The 2026-07-03 review's remaining work is now filed as discrete, dev-lead-pickable issues. Checklist tracks them.

    Tier 1 — Tuning

    • De-provision legacy SonarCloud project ✅ DONE 2026-07-03 (verified removed; org projects 11→10, and the legacy project’s 7 duplicate issues with it) — petry-projects_broodminder-export (display name broodminder-export-legacy) — duplicate scan of the same GitHub repo as the live _broodminder-export2 project. Manual Sonar-admin action, no repo issue.
    • Rewrite Jest assertions to specific matchers (SonarCloud S5906 ×96) google-app-scripts#416 — S5906 test-assertion rewrite (×96)

    Tier 3 — Real work (human/agent judgment)

    Tier 2 — Automation (mechanical / hardening)

    S7635 (secrets: inherit):

    GitHub Actions / dependency hardening:

    Shell script hygiene:

    JavaScript modernization:

    Misc long-tail:


    Note: broodminder-export2 in the tables is a SonarCloud project key; the underlying GitHub repo is petry-projects/broodminder-export — issues were filed there. .github-private is public and has 0 SonarCloud findings (clean), so the 310-issue pull was already org-complete.

  3. don-petry commented on Jul 4, 2026

    @don-petry
    ContributorAuthor

    Config hygiene: enforcement-layer drift (added to scope)

    While confirming the SonarCloud gate is actually blocking, I surveyed how it's enforced. The authoritative layer is the repo-level code-quality ruleset (requires SonarCloud · CodeQL · agent-shield · dependency-audit · build-and-test · coverage). Two drift problems sit alongside it:

    1. repo-template is MISSING the code-quality ruleset ⚠️ (highest-leverage)

    Every other scanned repo has it active; the template that seeds new repos does not. So new repos start unprotected until the ruleset applier catches them — and the template can't model the standard it's supposed to propagate. Compounds the existing repo-template S7635 leak (see #600). Fix the template first.

    2. Legacy classic branch-protection is a partial, inconsistent second layer

    Four repos still carry old classic required_status_checks that disagree with each other and with the ruleset. GitHub takes the union, so SonarCloud is still required everywhere — but the drift is confusing and should be retired in favor of rulesets-only:

    Repo Classic required check (legacy) code-quality ruleset
    markets SonarCloud active
    google-app-scripts build-and-test active
    TalkTerm Analyze (python) active
    ContentTwin SonarCloud active
    .github, broodly, bmad-bgreat-suite, broodminder-export, repo-template (none) active (except repo-template)

    Tasks

    • Add the code-quality ruleset to repo-template so new repos are born protected (coordinate with the ruleset applier / .github/standards/rulesets).
    • Retire the legacy classic branch-protection required-checks on markets, google-app-scripts, TalkTerm, ContentTwin — consolidate enforcement onto the ruleset only.
    • Confirm the ruleset applier covers repo-template going forward (prevent regression).

    Context (not a bug, for the record)

    The gate is "Sonar way" (Clean-as-You-Code) — all conditions are new_* (new security/reliability/maintainability rating, new coverage ≥80%, new dup ≤3%, new hotspots reviewed). It blocks PRs that introduce new findings (new vulns like S7635/S8707 are effectively hard-blocked) but does not block on the pre-existing backlog — which is exactly why the 22 drawdown issues above are needed. Enforcement is correct; no gate change recommended.

    Filed from the 2026-07-03 SonarCloud review follow-up.

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

    dev-leadFor dev-lead agent pickupdev-lead:hands-offOpt an item out of the dev-lead persona automation entirelyenhancementFeature requests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions