Skip to content

fix: replace mutable export with getter function for cache#14

Open
sonarqube-agent[bot] wants to merge 1 commit intomasterfrom
remediate-master-20260330-072027-a49a548d
Open

fix: replace mutable export with getter function for cache#14
sonarqube-agent[bot] wants to merge 1 commit intomasterfrom
remediate-master-20260330-072027-a49a548d

Conversation

@sonarqube-agent
Copy link
Copy Markdown

Refactored direct access of mutable exported variable to use getter function instead, eliminating the CRITICAL SonarQube issue of exporting mutable bindings. This improves code quality by properly encapsulating state and preventing unintended mutations of shared cache data.

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 a getter function call cache.getRetrieveBlueprintChallengeFile(). This is part of the fix for the code smell where a mutable let binding is exported from data/datacache.ts. By refactoring consumers to use a getter function instead of directly accessing the exported mutable variable, the variable in datacache.ts can be changed from an exported let to a non-exported variable encapsulated behind getter/setter functions, eliminating the mutable export.

--- 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: ae504716-b58b-4da2-a9c5-1ea46cbbe466)
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