SQSCANGHA-141 fix: resolve 9 SonarQube issues in gpg-verification files from #235#236
Conversation
…ipt:S2486 Commit 1 of SonarQube suggestions Fully fixed issues: - [javascript:S7773] AZ3Pp_T3hKtKf9aAx2tr: Prefer `Number.parseInt` over `parseInt`. - [javascript:S7773] AZ3Pp_T3hKtKf9aAx2ts: Prefer `Number.parseInt` over `parseInt`. - [javascript:S7772] AZ3Pp_T3hKtKf9aAx2tn: Prefer `node:fs` over `fs`. - [javascript:S7772] AZ3Pp_T3hKtKf9aAx2to: Prefer `node:path` over `path`. - [javascript:S7772] AZ3Pp_T3hKtKf9aAx2tp: Prefer `node:os` over `os`. - [javascript:S2486] AZ3Pp_T3hKtKf9aAx2tq: Handle this exception or don't catch it at all. Generated by SonarQube Agent
Commit 2 of SonarQube suggestions Fully fixed issues: - [javascript:S7772] AZ3Pp_V9hKtKf9aAx2tt: Prefer `node:fs` over `fs`. - [javascript:S7772] AZ3Pp_V9hKtKf9aAx2tu: Prefer `node:os` over `os`. - [javascript:S7772] AZ3Pp_V9hKtKf9aAx2tv: Prefer `node:path` over `path`. Generated by SonarQube Agent
|
Summary
This PR resolves 9 SonarQube code quality issues in the GPG verification module by modernizing Node.js best practices:
No functional changes — all modifications are code quality improvements. What reviewers should knowReview scope: Changes are isolated to two files (main module + tests) and are purely about code style/quality. What to check:
Low-risk PR: No logic changes, no new dependencies, no breaking changes. Safe to approve once the changes are verified.
|
There was a problem hiding this comment.
LGTM! ✅
Clean PR — the changes are correct and safe.
One thing worth knowing: 8 other source files under src/ still use bare specifiers without the node: prefix — run-sonar-scanner.js, sanity-checks.js, install-sonar-scanner.js, and the install-build-wrapper module. The scope here is intentionally limited to the files flagged in #235, but those remaining files will likely surface the same S7772 rule on the next scan and need a follow-up.



Addresses quality gate issues from #235.
Updated Node.js built-in module imports to use the
node:protocol prefix (fs, os, path) in both gpg-verification.js and its test file, replaced globalparseIntwithNumber.parseInt, and added error logging to an empty catch block. These changes align with modern Node.js best practices, improve code clarity and security, and ensure exceptions are properly handled rather than silently ignored.View Project in SonarCloud
Fixed Issues
javascript:S7772 - Prefer `node:fs` over `fs`. • MINOR • View issue
Location:
src/main/gpg-verification.js:23What changed
This hunk adds the
node:protocol prefix to three Node.js built-in module imports insrc/main/gpg-verification.js. It changes"fs"to"node:fs","os"to"node:os", and"path"to"node:path". This directly resolves the static analysis warnings about preferring thenode:protocol for built-in module imports, which improves clarity (making it obvious these are core Node.js modules rather than third-party packages), enhances security (preventing potential confusion with similarly-named npm packages), and aligns with modern Node.js best practices.javascript:S7772 - Prefer `node:os` over `os`. • MINOR • View issue
Location:
src/main/gpg-verification.js:24What changed
This hunk adds the
node:protocol prefix to three Node.js built-in module imports insrc/main/gpg-verification.js. It changes"fs"to"node:fs","os"to"node:os", and"path"to"node:path". This directly resolves the static analysis warnings about preferring thenode:protocol for built-in module imports, which improves clarity (making it obvious these are core Node.js modules rather than third-party packages), enhances security (preventing potential confusion with similarly-named npm packages), and aligns with modern Node.js best practices.javascript:S7772 - Prefer `node:path` over `path`. • MINOR • View issue
Location:
src/main/gpg-verification.js:25What changed
This hunk adds the
node:protocol prefix to three Node.js built-in module imports insrc/main/gpg-verification.js. It changes"fs"to"node:fs","os"to"node:os", and"path"to"node:path". This directly resolves the static analysis warnings about preferring thenode:protocol for built-in module imports, which improves clarity (making it obvious these are core Node.js modules rather than third-party packages), enhances security (preventing potential confusion with similarly-named npm packages), and aligns with modern Node.js best practices.javascript:S7772 - Prefer `node:fs` over `fs`. • MINOR • View issue
Location:
src/main/__tests__/gpg-verification.test.js:23What changed
This hunk adds the
node:protocol prefix to three Node.js built-in module imports:fsbecomesnode:fs,pathbecomesnode:path, andosbecomesnode:os. This makes it explicitly clear that these are core Node.js modules rather than potentially third-party npm packages, improving clarity, security, and alignment with modern Node.js best practices.javascript:S7772 - Prefer `node:path` over `path`. • MINOR • View issue
Location:
src/main/__tests__/gpg-verification.test.js:24What changed
This hunk adds the
node:protocol prefix to three Node.js built-in module imports:fsbecomesnode:fs,pathbecomesnode:path, andosbecomesnode:os. This makes it explicitly clear that these are core Node.js modules rather than potentially third-party npm packages, improving clarity, security, and alignment with modern Node.js best practices.javascript:S7772 - Prefer `node:os` over `os`. • MINOR • View issue
Location:
src/main/__tests__/gpg-verification.test.js:25What changed
This hunk adds the
node:protocol prefix to three Node.js built-in module imports:fsbecomesnode:fs,pathbecomesnode:path, andosbecomesnode:os. This makes it explicitly clear that these are core Node.js modules rather than potentially third-party npm packages, improving clarity, security, and alignment with modern Node.js best practices.javascript:S2486 - Handle this exception or don't catch it at all. • MINOR • View issue
Location:
src/main/__tests__/gpg-verification.test.js:42What changed
This hunk fixes the empty catch block that silently swallowed exceptions during test cleanup. Instead of just having a comment saying 'Ignore cleanup errors', it now logs the error via
console.error, ensuring the exception is properly handled rather than completely ignored. This satisfies the rule that caught exceptions should be handled or logged rather than silently discarded.javascript:S7773 - Prefer `Number.parseInt` over `parseInt`. • MINOR • View issue
Location:
src/main/__tests__/gpg-verification.test.js:67What changed
This hunk replaces both usages of the global
parseIntfunction withNumber.parseInt. The first occurrence on the line computingmodefromstats.mode & parseInt('777', 8)is changed toNumber.parseInt('777', 8), fixing the first warning about preferringNumber.parseIntover the globalparseInt. The second occurrence on the assertion lineassert.equal(mode, parseInt('700', 8))is changed toNumber.parseInt('700', 8), fixing the second warning about preferringNumber.parseIntover the globalparseInt. Both changes align with modern ES2015+ best practices by using theNumbernamespace equivalent instead of the global function.javascript:S7773 - Prefer `Number.parseInt` over `parseInt`. • MINOR • View issue
Location:
src/main/__tests__/gpg-verification.test.js:68What changed
This hunk replaces both usages of the global
parseIntfunction withNumber.parseInt. The first occurrence on the line computingmodefromstats.mode & parseInt('777', 8)is changed toNumber.parseInt('777', 8), fixing the first warning about preferringNumber.parseIntover the globalparseInt. The second occurrence on the assertion lineassert.equal(mode, parseInt('700', 8))is changed toNumber.parseInt('700', 8), fixing the second warning about preferringNumber.parseIntover the globalparseInt. Both changes align with modern ES2015+ best practices by using theNumbernamespace equivalent instead of the global function.SonarQube Remediation Agent uses AI. Check for mistakes.
DISCLAIMER: Remediation Agent will not be triggered again on this (self authored) PR