fix: resolve 5 SonarQube code quality issues#31
Open
sonarqube-agent[bot] wants to merge 1 commit into
Open
Conversation
Fixed issues: - AZZjJOKu2HDYqP_XXG6z for javascript:S125 rule - AZmd8Pz-uPWA3VN6PKOA for javascript:S7764 rule - AZZjJONQ2HDYqP_XXG7V for javascript:S2392 rule - AZmd8Pw-uPWA3VN6PKN8 for javascript:S7764 rule - AZmd8Pw-uPWA3VN6PKN9 for javascript:S7764 rule Generated by SonarQube Agent (task: 91e65db9-17ed-4340-af75-50a0342a48df)
Contributor
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.



Removed commented-out code, fixed variable scope declaration, and replaced browser-specific window references with standardized globalThis to improve code maintainability and portability across JavaScript environments. These changes address code smells and bring the codebase into compliance with modern JavaScript best practices.
View Project in SonarCloud
Fixed Issues
javascript:S125 - Remove this commented out code. • MAJOR • View issue
Location:
content/assets/js/addOnto.js:144Why is this an issue?
Commented-out code distracts the focus from the actual executed code. It creates a noise that increases maintenance code. And because it is never executed, it quickly becomes out of date and invalid.
What changed
This hunk removes the commented-out jQuery code
//$("#terminologit-search-content-valueset-cld").attr("id","logical-definition-accordion-group");at line 144 of addOnto.js, replacing it with blank lines. This directly addresses the code smell about commented-out code that should be removed, as it creates noise and distracts from actual executed code.javascript:S2392 - Consider moving declaration of 'currentTabIndex' as it is referenced outside current binding context. • MAJOR • View issue
Location:
content/assets/js/tabs.js:2Why is this an issue?
The
varstatement declares variables that are function-scoped or globally-scoped.vardeclarations are hoisted, meaning declaring a variable anywhere in the code is equivalent to declaring it at the top of the function or the script.What changed
Declares 'currentTabIndex' at the top level (outside the try block) so that it is declared in the same scope where it is referenced. This addresses the code smell where 'var currentTabIndex' was declared inside a block (the try block) but referenced outside of that binding context. By hoisting the declaration to the outer scope, the variable is properly scoped to where it is actually used.
javascript:S7764 - Prefer `globalThis` over `window`. • MINOR • View issue
Location:
content/assets/js/window-hash.js:2Why 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
This hunk replaces both occurrences of
windowwithglobalThisin the filecontent/assets/js/window-hash.js. On line 2,window.location.hashis changed toglobalThis.location.hashin the if-condition, fixing the static analysis warning about preferringglobalThisoverwindowat that location. On line 3,window.location.hashis similarly changed toglobalThis.location.hashinside the jQuery selector string, fixing the second warning about preferringglobalThisoverwindow. UsingglobalThisis the standardized ES2020 way to access the global object, making the code more portable across different JavaScript environments (browser, Node.js, Web Workers) instead of relying on the browser-specificwindowreference.javascript:S7764 - Prefer `globalThis` over `window`. • MINOR • View issue
Location:
content/assets/js/window-hash.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
This hunk replaces both occurrences of
windowwithglobalThisin the filecontent/assets/js/window-hash.js. On line 2,window.location.hashis changed toglobalThis.location.hashin the if-condition, fixing the static analysis warning about preferringglobalThisoverwindowat that location. On line 3,window.location.hashis similarly changed toglobalThis.location.hashinside the jQuery selector string, fixing the second warning about preferringglobalThisoverwindow. UsingglobalThisis the standardized ES2020 way to access the global object, making the code more portable across different JavaScript environments (browser, Node.js, Web Workers) instead of relying on the browser-specificwindowreference.javascript:S7764 - Prefer `globalThis` over `window`. • MINOR • View issue
Location:
content/assets/js/topofpage.js:2Why 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
This hunk replaces
windowwithglobalThisin the scroll event handler binding. The static analysis rule flags the use ofwindowas a non-portable way to access the global object, recommendingglobalThisinstead as the standardized ES2020 approach that works consistently across all JavaScript environments (browsers, Node.js, Web Workers). By changing$(window).scroll(...)to$(globalThis).scroll(...), the code follows the preferred practice of usingglobalThisover environment-specific globals.SonarQube Remediation Agent uses AI. Check for mistakes.