Skip to content

fix: replace mutable let export with getter function in datacache#32

Open
sonarqube-agent[bot] wants to merge 1 commit intomasterfrom
remediate-master-20260331-033604-568b6a46
Open

fix: replace mutable let export with getter function in datacache#32
sonarqube-agent[bot] wants to merge 1 commit intomasterfrom
remediate-master-20260331-033604-568b6a46

Conversation

@sonarqube-agent
Copy link
Copy Markdown

Fixes a critical SonarQube issue by encapsulating the mutable cache.retrieveBlueprintChallengeFile variable behind a getter function instead of directly exporting it as a mutable binding. This improves code safety by preventing accidental mutations of the exported variable and follows TypeScript best practices for immutable exports.

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 changes direct access of the exported mutable variable cache.retrieveBlueprintChallengeFile to use a getter function cache.getRetrieveBlueprintChallengeFile() instead. This is part of the fix for the code smell where a mutable let binding is exported from data/datacache.ts. By switching consumers to use a getter function, the underlying variable in datacache.ts no longer needs to be directly exported as a mutable let — it can be encapsulated behind accessor functions, eliminating the exported mutable binding.

--- 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.getRetrieveBlueprintChallengeFile()) })

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: f6446641-872e-4bac-81a0-29ef8e5c0001)
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