Replace window references with globalThis in game.js#2
Open
sonarqube-agent[bot] wants to merge 1 commit into
Open
Replace window references with globalThis in game.js#2sonarqube-agent[bot] wants to merge 1 commit into
sonarqube-agent[bot] wants to merge 1 commit into
Conversation
Fixed issues: - AZ7RDO5qEdyOuX9cXX5B for javascript:S7764 rule - AZ7RDO5qEdyOuX9cXX47 for javascript:S7764 rule Generated by SonarQube Agent (task: 3fe0e437-6a46-4b41-8510-f11aa1410b4f)
Author
|
|
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.
Fixed two SonarQube static analysis warnings (javascript:S7764) by replacing
window.prompt()andwindow.alert()with theirglobalThisequivalents. UsingglobalThisinstead ofwindowimproves code portability across different JavaScript environments, including Node.js and browser contexts.View Project in SonarCloud
Fixed Issues
javascript:S7764 - Prefer `globalThis` over `window`. • MINOR • View issue
Location:
public/game.js:142Why is this an issue?
globalThisis the standardized way to access the global object across all JavaScript environments. BeforeglobalThis, developers had to use different global references depending on the environment:What changed
Replaces
window.prompt(...)withglobalThis.prompt(...)at line 142 of public/game.js, fixing the static analysis warning that prefersglobalThisoverwindowfor accessing the global object. This makes the code more portable across JavaScript environments.javascript:S7764 - Prefer `globalThis` over `window`. • MINOR • View issue
Location:
public/game.js:476Why is this an issue?
globalThisis the standardized way to access the global object across all JavaScript environments. BeforeglobalThis, developers had to use different global references depending on the environment:What changed
Replaces
window.alert(...)withglobalThis.alert(...)at line 476 of public/game.js, fixing the static analysis warning that prefersglobalThisoverwindowfor accessing the global object. This makes the code more portable across JavaScript environments.SonarQube Remediation Agent uses AI. Check for mistakes.