fix: replace window with globalThis in swagger-initializer.js#14
Open
sonarqube-agent[bot] wants to merge 1 commit into
Open
fix: replace window with globalThis in swagger-initializer.js#14sonarqube-agent[bot] wants to merge 1 commit into
sonarqube-agent[bot] wants to merge 1 commit into
Conversation
Fixed issues: - AZpHzODgBLcwshDrw6nS for javascript:S7764 rule Generated by SonarQube Agent (task: 4431c35d-4850-4a38-b940-d629cddec7e0)
SonarQube reviewer guide
|
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.




Replaces
window.location.searchwithglobalThis.location.searchto prefer the standardized global object accessor over the browser-specificwindowglobal. This improves code portability across different JavaScript environments such as browsers, Node.js, and Web Workers, addressing the SonarQube javascript:S7764 code smell.View Project in SonarCloud
Fixed Issues
javascript:S7764 - Prefer `globalThis` over `window`. • MINOR • View issue
Location:
swagger/src/main/resources/com/webcohesion/enunciate/modules/swagger/swagger-initializer.js:3Why 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.location.searchwithglobalThis.location.searchon line 3 of swagger-initializer.js, directly fixing the code smell that flags the use of the environment-specificwindowglobal instead of the standardizedglobalThisfor accessing the global object. This makes the code more portable across different JavaScript environments (browser, Node.js, Web Workers) as recommended by the prefer-global-this rule.SonarQube Remediation Agent uses AI. Check for mistakes.