Skip to content

fix: resolve 5 SonarQube issues in JS files#29

Open
sonarqube-agent[bot] wants to merge 1 commit into
mainfrom
remediate-main-20260508-090128-e3bd238c
Open

fix: resolve 5 SonarQube issues in JS files#29
sonarqube-agent[bot] wants to merge 1 commit into
mainfrom
remediate-main-20260508-090128-e3bd238c

Conversation

@sonarqube-agent
Copy link
Copy Markdown
Contributor

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. • MINORView issue

Location: content/assets/js/addOnto.js:223

Why 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.

--- a/content/assets/js/addOnto.js
+++ b/content/assets/js/addOnto.js
@@ -223,1 +222,0 @@ $(document).ready(function(){
-        var listItem = $('.results'+indextable +' tbody').children('tr');
javascript:S1481 - Remove the declaration of the unused 'listItem' variable. • MINORView issue

Location: content/assets/js/addOnto.js:266

Why 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.

--- a/content/assets/js/addOnto.js
+++ b/content/assets/js/addOnto.js
@@ -266,1 +264,0 @@ $(document).ready(function(){
-        var listItem = $('.results'+indextable +' tbody').children('tr');
javascript:S2486 - Handle this exception or don't catch it at all. • MINORView issue

Location: content/assets/js/tabs.js:3

Why 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.

--- a/content/assets/js/tabs.js
+++ b/content/assets/js/tabs.js
@@ -3,0 +4,1 @@ try {
+  console.log(`Exception while retrieving tab index from sessionStorage: ${exception}`);
javascript:S1481 - Remove the declaration of the unused 'active' variable. • MINORView issue

Location: content/assets/js/tabs.js:12

Why 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.

--- a/content/assets/js/tabs.js
+++ b/content/assets/js/tabs.js
@@ -12,1 +12,0 @@ $( '#tabs' ).tabs({
-    var active = $('.selector').tabs('option', 'active');
javascript:S2486 - Handle this exception or don't catch it at all. • MINORView issue

Location: content/assets/js/tabs.js:17

Why 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.

--- a/content/assets/js/tabs.js
+++ b/content/assets/js/tabs.js
@@ -17,0 +18,1 @@ $( '#tabs' ).tabs({
+      console.log(`Exception while storing tab index to sessionStorage: ${exception}`);

Have a suggestion or found an issue? Share your feedback here.


SonarQube Remediation Agent uses AI. Check for mistakes.

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)
@sonarqube-agent
Copy link
Copy Markdown
Contributor Author

⚠️ This repository does not have a CODEOWNERS file. The PR has been created but has not been automatically assigned to any reviewer. To ensure PRs are reviewed promptly, consider adding a CODEOWNERS file to your repository.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 8, 2026

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.

1 participant