Skip to content

fix: replace mutable let export with const getter function#29

Open
sonarqube-agent[bot] wants to merge 1 commit intomasterfrom
remediate-master-20260331-030624-1300d078
Open

fix: replace mutable let export with const getter function#29
sonarqube-agent[bot] wants to merge 1 commit intomasterfrom
remediate-master-20260331-030624-1300d078

Conversation

@sonarqube-agent
Copy link
Copy Markdown

Fixes a critical SonarQube issue (S6861) by replacing a mutable 'let' binding export with a 'const' getter function in datacache.ts. Updated the call site to invoke the function rather than access it as a property, improving code maintainability and eliminating the static analysis warning about exporting mutable bindings.

View Project in SonarCloud


Fixed Issues

typescript:S6861 - Exporting mutable 'let' binding, use 'const' instead. • CRITICALView issue

Location: data/datacache.ts:33

Why is this an issue?

In JavaScript, a mutable variable is one whose value can be changed after it has been initially set. This is in contrast to immutable variables, whose values cannot be changed once they are set.

What changed

This hunk updates a consumer of the exported mutable 'let' variable retrieveBlueprintChallengeFile in data/datacache.ts. By changing cache.retrieveBlueprintChallengeFile (direct property access) to cache.retrieveBlueprintChallengeFile() (function call), it adapts the call site to work with a refactored version of the export where the mutable let variable is replaced by a const getter function. This supports fixing the static analysis warning about exporting a mutable let binding by allowing the underlying variable to be encapsulated behind a function and exported as a const.

--- a/routes/verify.ts
+++ b/routes/verify.ts
@@ -72,1 +72,1 @@ exports.accessControlChallenges = () => ({ url }: Request, res: Response, next:
-  challengeUtils.solveIf(challenges.retrieveBlueprintChallenge, () => { return utils.endsWith(url, cache.retrieveBlueprintChallengeFile) })
+  challengeUtils.solveIf(challenges.retrieveBlueprintChallenge, () => { return utils.endsWith(url, cache.retrieveBlueprintChallengeFile()) })

Have a suggestion or found an issue? Share your feedback here.


SonarQube Remediation Agent uses AI. Check for mistakes.

Fixed issues:
- AZWU-tZlYJSZqVQVbSd5 for typescript:S6861 rule

Generated by SonarQube Agent (task: 4b31b389-6296-4c12-8b5f-319cb684f1e8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants