chore: 🤖 resolve SonarCloud quality gate failures - #374
Open
prashantasdeveloper wants to merge 3 commits into
Open
prashantasdeveloper wants to merge 3 commits into
prashantasdeveloper wants to merge 3 commits into
Conversation
Addresses every open issue the quality gate reported on master. Security (New Code rating C -> A): - disable dependency lifecycle scripts on CI installs with `yarn --immutable --mode=skip-build`, running the repo's own trusted postinstall as an explicit step so the @PolkaDot dedupe still happens - pin sequoia-pgp/fast-forward to a full commit SHA (v1.0.0), clearing the outstanding security hotspot Code smells: - mark never-reassigned members readonly - prefer node: protocol imports, Number.isNaN / Number.parseInt, Date.now() and Array.prototype.flatMap over lodash flatten - avoid an object literal as a default parameter in ApiArrayResponse - use String.raw for the regex literals in jest.config.js - sort the Dockerfile apk packages, use `[[ ]]` in the shell scripts and give the integration-test cleanup trap an explicit return - extract cloneRepo/buildAndPushImage out of the Jenkinsfile node block to keep control flow nesting within 3 levels Tests: - complete the vacuous assertion in the batchBumpNonce spec, which called expect() with no matcher and so asserted nothing S2187 is ignored for the datastore repo specs: they delegate to shared suites (`XRepo.test(repo)`) whose `it` blocks Sonar's static analysis cannot see, making "add some tests to this file" a false positive.
The Jenkins pipeline is no longer used, so drop it along with the CODEOWNERS entry that pointed at it. This also removes the three S134 control flow nesting smells the previous commit refactored the file to satisfy.
`./github` is syntactically valid but never matches, so changes under `.github/` were silently falling through to the catch-all owners rather than requiring SRE review. Use a root-anchored `/.github/` instead. Also replace the individually named catch-all owners with the Middleware team. Three of the four no longer resolve, which left a single valid reviewer on every path.
prashantasdeveloper
force-pushed
the
fix/sonar-quality-gate
branch
from
September 23, 2026 10:55
16239b8 to
215427a
Compare
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Resolves the SonarCloud Quality Gate failure reported on
master(check run 105569982946).Failing conditions, all addressed: C Security Rating on New Code, 40 Code Smells, 3 New Code Smells, 66.7% Security Hotspots Reviewed, C Security Review Rating — 46 issues + 1 unreviewed hotspot, pulled from the SonarCloud API.
Security —
S6505, 6 issuesCI installs ran
yarn --immutable, which executes dependency lifecycle scripts.The obvious fix (
--mode=skip-build) would have broken the build, so it was verified against a scratch Yarn 4 project first:--mode=skip-buildalso suppresses the rootpostinstall— the script that dedupes@polkadotfor the SDK. Each install is therefore now two steps:Verified end-to-end from a clean
node_modules: install → postinstall → lint → build → test all pass. (Note: with the current lockfile those nested@polkadotcopies are no longer created at all, sopostinstallis currently a defensive no-op.)The same treatment is applied to
scripts/integration-test.sh, where theyarncall installs the clonedpolymesh-dev-envtest harness — that package has nopostinstall, so no follow-up step is needed there.Security hotspot
sequoia-pgp/fast-forward@v1is pinned toea7628b. Thev1branch, thev1.0.0tag and that SHA are all the same commit, so behavior is unchanged.Code smells
readonly(currentIdis left mutable — it is a counter)node:protocol imports,Number.isNaN/Number.parseInt,Date.now(),Array.prototype.flatMapover lodashflattenApiArrayResponseString.rawfor the regex literals injest.config.jsapkpackages;[[ ]]in the shell scripts; explicitreturnin the integration-test cleanup trapcloneRepo/buildAndPushImageout of theJenkinsfilenodeblock to keep control-flow nesting within 3 levelsOne real bug
subscriptions.service.spec.tscalledexpect(...)with no matcher, so thebatchBumpNoncetest asserted nothing and passed unconditionally. Completing the assertion made it fail —findAll()is not stubbed in that block and returned a bare mock. Rewritten to assert the actual delegation toincrementNonces, matching the adjacentbatchMarkAsDonetest.Reviewer note — 9 smells suppressed, not code-fixed
The
*.repo.spec.tsfiles Sonar reports as having no tests (S2187) do run real tests — they delegate to shared suites (NotificationRepo.test(repo)) whoseitblocks live in*.repo.suite.tsand which Sonar's static analysis cannot see through. Deleting them would delete real coverage, sosonar-project.propertiesignoresS2187for those paths.This project uses SonarCloud Automatic Analysis (there is no scanner step in CI), so please confirm the gate actually honours
sonar.issue.ignore.multicriteria. If those 9 still report, the fallback is marking them "Won't Fix" in the SonarCloud UI.Verification
yarn lint,yarn buildclean. 1087/1087 tests pass across 105 suites.