Skip to content

SLLS-545 fix: resolve 5 SonarQube code style violations in tests#707

Closed
sonarqube-agent[bot] wants to merge 1 commit into
masterfrom
remediate-master-20260522-050225-59caa5f9
Closed

SLLS-545 fix: resolve 5 SonarQube code style violations in tests#707
sonarqube-agent[bot] wants to merge 1 commit into
masterfrom
remediate-master-20260522-050225-59caa5f9

Conversation

@sonarqube-agent
Copy link
Copy Markdown
Contributor

Fixed 5 MINOR SonarQube issues including renaming fields and local variables to comply with Java naming conventions, removing an unused variable, and eliminating a superfluous exception declaration. These changes improve code quality and consistency with established Java coding standards.

View Project in SonarCloud


Fixed Issues

java:S116 - Rename this field "LOG" to match the regular expression '^[a-z][a-zA-Z0-9]*$'. • MINORView issue

Location: sonarlint-language-server:src/test/java/testutils/SonarLintLogTester.java:75

Why is this an issue?

A naming convention in software development is a set of guidelines for naming code elements like variables, functions, and classes.

What changed

Renames the field 'LOG' to 'log' to comply with the Java naming convention that field names should match the pattern '^[a-z][a-zA-Z0-9]*$'. The original uppercase name 'LOG' violated this convention as it didn't start with a lowercase letter.

--- a/src/test/java/testutils/SonarLintLogTester.java
+++ b/src/test/java/testutils/SonarLintLogTester.java
@@ -75,1 +75,1 @@ public class SonarLintLogTester implements BeforeTestExecutionCallback, AfterTes
-  private final LanguageClientLogger LOG;
+  private final LanguageClientLogger log;
java:S116 - Rename this field "FILE_PYTHON" to match the regular expression '^[a-z][a-zA-Z0-9]*$'. • MINORView issue

Location: sonarlint-language-server:src/test/java/org/sonarsource/sonarlint/ls/commands/ShowAllLocationsCommandTests.java:52

Why is this an issue?

A naming convention in software development is a set of guidelines for naming code elements like variables, functions, and classes.

What changed

Renames the field FILE_PYTHON to filePython to match the naming convention pattern ^[a-z][a-zA-Z0-9]*$. The original name used uppercase with underscores (constant-style naming), which violates the field naming convention for non-static fields.

--- a/src/test/java/org/sonarsource/sonarlint/ls/commands/ShowAllLocationsCommandTests.java
+++ b/src/test/java/org/sonarsource/sonarlint/ls/commands/ShowAllLocationsCommandTests.java
@@ -52,1 +51,1 @@ class ShowAllLocationsCommandTests {
-  private final String FILE_PYTHON = "myFile.py";
+  private final String filePython = "myFile.py";
java:S1130 - Remove the declaration of thrown exception 'java.util.concurrent.ExecutionException', as it cannot be thrown from method's body. • MINORView issue

Location: sonarlint-language-server:src/test/java/org/sonarsource/sonarlint/ls/commands/ShowAllLocationsCommandTests.java:55

Why is this an issue?

Superfluous exceptions within throws clauses have negative effects on the readability and maintainability of the code. An exception in a throws clause is superfluous if it is:

What changed

Removes the import of java.util.concurrent.ExecutionException, which is no longer needed after removing the superfluous ExecutionException from the throws clause of the prepare() method. This supports the fix for the code smell about declaring a thrown exception that cannot actually be thrown from the method's body.

--- a/src/test/java/org/sonarsource/sonarlint/ls/commands/ShowAllLocationsCommandTests.java
+++ b/src/test/java/org/sonarsource/sonarlint/ls/commands/ShowAllLocationsCommandTests.java
@@ -27,1 +26,0 @@ import java.util.List;
-import java.util.concurrent.ExecutionException;
java:S1481 - Remove this unused "fakeNotebook" local variable. • MINORView issue

Location: sonarlint-language-server:src/test/java/org/sonarsource/sonarlint/ls/notebooks/OpenNotebooksCacheTests.java:68

Why is this an issue?

An unused local variable is a variable that has been declared but is not used anywhere in the block of code where it is defined. It is dead code, contributing to unnecessary complexity and leading to confusion when reading the code. Therefore, it should be removed from your code to maintain clarity and efficiency.

What changed

Removes the unused local variable 'fakeNotebook' which was declared and assigned but never used anywhere in the test method. This directly addresses the code smell about unnecessary local variables that add complexity and reduce readability.

--- a/src/test/java/org/sonarsource/sonarlint/ls/notebooks/OpenNotebooksCacheTests.java
+++ b/src/test/java/org/sonarsource/sonarlint/ls/notebooks/OpenNotebooksCacheTests.java
@@ -68,1 +67,0 @@ class OpenNotebooksCacheTests extends AbstractLanguageServerMediumTests {
-    var fakeNotebook = VersionedOpenNotebook.create(notebookUri, 1, List.of(cell1, cell2), mock(NotebookDiagnosticPublisher.class));
java:S117 - Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'. • MINORView issue

Location: sonarlint-language-server:src/test/java/org/sonarsource/sonarlint/ls/mediumtests/LanguageServerMediumTests.java:958

Why is this an issue?

A naming convention in software development is a set of guidelines for naming code elements like variables, functions, and classes.
Local variables and method parameters hold the meaning of the written code. Their names should be meaningful and follow a consistent and easily recognizable pattern.
Adhering to a consistent naming convention helps to make the code more readable and understandable, which makes it easier to maintain and debug. It also ensures consistency in the code, especially when multiple developers are working on the same project.

What changed

This hunk renames the local variables 'OLD' and 'NEW' to 'oldValue' and 'newValue', respectively. The original names 'OLD' and 'NEW' are uppercase, which violates the naming convention rule requiring local variables to match the pattern '^[a-z][a-zA-Z0-9]*$'. The new names follow camelCase convention and satisfy the required regular expression.

--- a/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/LanguageServerMediumTests.java
+++ b/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/LanguageServerMediumTests.java
@@ -957,2 +957,2 @@ class LanguageServerMediumTests extends AbstractLanguageServerMediumTests {
-    String OLD = "old";
-    String NEW = "new";
+    String oldValue = "old";
+    String newValue = "new";

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


SonarQube Remediation Agent uses AI. Check for mistakes.

Fixed issues:
- AZjRjd54592amupb0FPu for java:S1481 rule
- AZjRjd7G592amupb0FP7 for java:S116 rule
- AZjRjdx3592amupb0FPP for java:S117 rule
- AZjRjduY592amupb0FPF for java:S1130 rule
- AZjRjduY592amupb0FPD for java:S116 rule

Generated by SonarQube Agent (task: c702df97-7b4b-4e29-a108-fbe171892d7e)
@hashicorp-vault-sonar-prod hashicorp-vault-sonar-prod Bot changed the title fix: resolve 5 SonarQube code style violations in tests SLLS-545 fix: resolve 5 SonarQube code style violations in tests May 22, 2026
@hashicorp-vault-sonar-prod
Copy link
Copy Markdown

hashicorp-vault-sonar-prod Bot commented May 22, 2026

SLLS-545

@sonar-review-alpha
Copy link
Copy Markdown

sonar-review-alpha Bot commented May 22, 2026

Summary

⚠️ The PR description exceeded the analysis limit and was truncated. The review may not reflect all context.

This PR fixes 5 MINOR SonarQube violations in test files by renaming 3 fields/variables to comply with Java camelCase conventions, removing a superfluous exception declaration, and deleting an unused variable. All changes are purely stylistic with no functional impact. As a bonus, indentation in a Go code string literal is corrected.

Changes span 4 test files:

  • SonarLintLogTester.java: field LOGlog
  • ShowAllLocationsCommandTests.java: field FILE_PYTHONfilePython, removes ExecutionException from throws clause
  • LanguageServerMediumTests.java: local variables OLD/NEWoldValue/newValue
  • OpenNotebooksCacheTests.java: removes unused fakeNotebook variable

What reviewers should know

Reviewer checklist:

  • All renames are mechanical and complete (check that no orphaned references to old names exist)
  • The removal of ExecutionException is safe—confirm the method's body cannot throw it
  • The removed fakeNotebook variable was indeed unused
  • No functional behavior changes; tests should behave identically before/after

Quick navigation:

  • Most changes are straightforward renames; look for consistency
  • The unused variable removal in OpenNotebooksCacheTests.java (line 68) is the only semantic change
  • Indentation fix in LanguageServerMediumTests.java is whitespace-only and unrelated to other changes

  • Generate Walkthrough
  • Generate Diagram

🗣️ Give feedback

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