fix: resolve 5 SonarQube issues in JS files#29
Open
sonarqube-agent[bot] wants to merge 1 commit into
Open
Conversation
Fixed issues: - AZZjJONQ2HDYqP_XXG7W for javascript:S2486 rule - AZZjJONQ2HDYqP_XXG7Y for javascript:S1481 rule - AZZjJONQ2HDYqP_XXG7a for javascript:S2486 rule - AZZjJOKu2HDYqP_XXG66 for javascript:S1481 rule - AZZjJOKu2HDYqP_XXG7A for javascript:S1481 rule Generated by SonarQube Agent (task: 90c6a1da-533e-4dab-96dd-63895dd2c44f)
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 3 unused variable declarations and added exception logging in 2 catch blocks in addOnto.js and tabs.js. These changes eliminate code smells related to dead code and unhandled exceptions, improving code quality and maintainability.
View Project in SonarCloud
Fixed Issues
javascript:S1481 - Remove the declaration of the unused 'listItem' variable. • MINOR • View issue
Location:
content/assets/js/addOnto.js:223Why is this an issue?
If a local variable or a local function is declared but not used, it is dead code and should be removed. Doing so will improve maintainability because developers will not wonder what the variable or function is used for.
What changed
This hunk removes the declaration of the unused 'listItem' variable that was assigned the result of '$(".results"+indextable+" tbody").children("tr")' but never used. Removing this dead code eliminates the code smell warning about the unused local variable 'listItem' at line 223.
javascript:S1481 - Remove the declaration of the unused 'listItem' variable. • MINOR • View issue
Location:
content/assets/js/addOnto.js:266Why is this an issue?
If a local variable or a local function is declared but not used, it is dead code and should be removed. Doing so will improve maintainability because developers will not wonder what the variable or function is used for.
What changed
This hunk removes the declaration of the unused 'listItem' variable that was assigned the result of '$(".results"+indextable+" tbody").children("tr")' but never used. Removing this dead code eliminates the code smell warning about the unused local variable 'listItem' at line 266.
javascript:S2486 - Handle this exception or don't catch it at all. • MINOR • View issue
Location:
content/assets/js/tabs.js:3Why is this an issue?
When exceptions occur, it is usually a bad idea to simply ignore them. Instead, it is better to handle them properly, or at least to log them.
What changed
Adds a console.log statement inside the empty catch block that handles exceptions when retrieving tab index from sessionStorage. This fixes the code smell where the exception was being silently ignored — now it is properly logged, satisfying the rule that caught exceptions should be handled or at least logged.
javascript:S1481 - Remove the declaration of the unused 'active' variable. • MINOR • View issue
Location:
content/assets/js/tabs.js:12Why is this an issue?
If a local variable or a local function is declared but not used, it is dead code and should be removed. Doing so will improve maintainability because developers will not wonder what the variable or function is used for.
What changed
Removes the declaration of the unused 'active' variable that was assigned the result of $('.selector').tabs('option', 'active') but never used anywhere. This eliminates the dead code, fixing the code smell about declaring variables that are never referenced.
javascript:S2486 - Handle this exception or don't catch it at all. • MINOR • View issue
Location:
content/assets/js/tabs.js:17Why is this an issue?
When exceptions occur, it is usually a bad idea to simply ignore them. Instead, it is better to handle them properly, or at least to log them.
What changed
Adds a console.log statement inside the empty catch block that handles exceptions when storing tab index to sessionStorage. This fixes the code smell where the exception was being silently ignored — now it is properly logged, satisfying the rule that caught exceptions should be handled or at least logged.
SonarQube Remediation Agent uses AI. Check for mistakes.