Skip to content

SLLS-544 fix: resolve 5 SonarQube code quality issues#706

Closed
sonarqube-agent[bot] wants to merge 1 commit into
masterfrom
remediate-master-20260521-050221-e03f7d59
Closed

SLLS-544 fix: resolve 5 SonarQube code quality issues#706
sonarqube-agent[bot] wants to merge 1 commit into
masterfrom
remediate-master-20260521-050221-e03f7d59

Conversation

@sonarqube-agent
Copy link
Copy Markdown
Contributor

This PR fixes 5 SonarQube violations across test files by removing calls to deprecated methods and correcting local variable naming conventions. The changes improve code quality by adhering to Java naming standards and eliminating deprecation warnings in ConnectedModeMediumTests and LanguageServerMediumTests.

View Project in SonarCloud


Fixed Issues

java:S1874 - Remove this use of "setSeverity"; it is deprecated. • MINORView issue

Location: sonarlint-language-server:src/test/java/org/sonarsource/sonarlint/ls/mediumtests/ConnectedModeMediumTests.java:1308

Why is this an issue?

Code is sometimes annotated as deprecated by developers maintaining libraries or APIs to indicate that the method, class, or other programming element is no longer recommended for use. This is typically due to the introduction of a newer or more effective alternative. For example, when a better solution has been identified, or when the existing code presents potential errors or security risks.

What changed

This hunk removes the calls to the deprecated methods setSeverity("MINOR") and setType(Common.RuleType.SECURITY_HOTSPOT). By deleting these two lines, it directly resolves both deprecation warnings: the one about using the deprecated setSeverity method and the one about using the deprecated setType method in the test file ConnectedModeMediumTests.java.

--- a/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/ConnectedModeMediumTests.java
+++ b/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/ConnectedModeMediumTests.java
@@ -1308,2 +1307,0 @@ class ConnectedModeMediumTests extends AbstractLanguageServerMediumTests {
-          .setSeverity("MINOR")
-          .setType(Common.RuleType.SECURITY_HOTSPOT)
java:S1874 - Remove this use of "setType"; it is deprecated. • MINORView issue

Location: sonarlint-language-server:src/test/java/org/sonarsource/sonarlint/ls/mediumtests/ConnectedModeMediumTests.java:1309

Why is this an issue?

Code is sometimes annotated as deprecated by developers maintaining libraries or APIs to indicate that the method, class, or other programming element is no longer recommended for use. This is typically due to the introduction of a newer or more effective alternative. For example, when a better solution has been identified, or when the existing code presents potential errors or security risks.

What changed

This hunk removes the calls to the deprecated methods setSeverity("MINOR") and setType(Common.RuleType.SECURITY_HOTSPOT). By deleting these two lines, it directly resolves both deprecation warnings: the one about using the deprecated setSeverity method and the one about using the deprecated setType method in the test file ConnectedModeMediumTests.java.

--- a/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/ConnectedModeMediumTests.java
+++ b/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/ConnectedModeMediumTests.java
@@ -1308,2 +1307,0 @@ class ConnectedModeMediumTests extends AbstractLanguageServerMediumTests {
-          .setSeverity("MINOR")
-          .setType(Common.RuleType.SECURITY_HOTSPOT)
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:957

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 variable 'OLD' to 'oldValue' and 'NEW' to 'newValue' at line 957-958 in a second test method, fixing the naming convention violation where uppercase local variable names like 'OLD' do not match the required pattern '^[a-z][a-zA-Z0-9]*$'.

--- 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";
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:937

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' (which violate the naming convention requiring names to match '^[a-z][a-zA-Z0-9]*$') to 'oldValue' and 'newValue' respectively at line 937-938. It also updates the usages of these variables in the constructor call and setter call on the following lines.

--- a/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/LanguageServerMediumTests.java
+++ b/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/LanguageServerMediumTests.java
@@ -937,4 +937,4 @@ class LanguageServerMediumTests extends AbstractLanguageServerMediumTests {
-    String OLD = "old";
-    String NEW = "new";
-    SonarLintExtendedLanguageServer.ConnectionCheckParams connectionCheckParams = new SonarLintExtendedLanguageServer.ConnectionCheckParams(OLD);
-    connectionCheckParams.setConnectionId(NEW);
+    String oldValue = "old";
+    String newValue = "new";
+    SonarLintExtendedLanguageServer.ConnectionCheckParams connectionCheckParams = new SonarLintExtendedLanguageServer.ConnectionCheckParams(oldValue);
+    connectionCheckParams.setConnectionId(newValue);
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:938

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' (which violate the naming convention requiring names to match '^[a-z][a-zA-Z0-9]*$') to 'oldValue' and 'newValue' respectively at line 937-938. It also updates the usages of these variables in the constructor call and setter call on the following lines.

--- a/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/LanguageServerMediumTests.java
+++ b/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/LanguageServerMediumTests.java
@@ -937,4 +937,4 @@ class LanguageServerMediumTests extends AbstractLanguageServerMediumTests {
-    String OLD = "old";
-    String NEW = "new";
-    SonarLintExtendedLanguageServer.ConnectionCheckParams connectionCheckParams = new SonarLintExtendedLanguageServer.ConnectionCheckParams(OLD);
-    connectionCheckParams.setConnectionId(NEW);
+    String oldValue = "old";
+    String newValue = "new";
+    SonarLintExtendedLanguageServer.ConnectionCheckParams connectionCheckParams = new SonarLintExtendedLanguageServer.ConnectionCheckParams(oldValue);
+    connectionCheckParams.setConnectionId(newValue);

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


SonarQube Remediation Agent uses AI. Check for mistakes.

Fixed issues:
- AZjr5v0K9TChwHguyc6P for java:S1874 rule
- AZjr5v0K9TChwHguyc6Q for java:S1874 rule
- AZjRjdx3592amupb0FPO for java:S117 rule
- AZjRjdx3592amupb0FPM for java:S117 rule
- AZjRjdx3592amupb0FPN for java:S117 rule

Generated by SonarQube Agent (task: 10508ede-c62a-46ce-8414-5b33dbb97995)
@hashicorp-vault-sonar-prod hashicorp-vault-sonar-prod Bot changed the title fix: resolve 5 SonarQube code quality issues SLLS-544 fix: resolve 5 SonarQube code quality issues May 21, 2026
@hashicorp-vault-sonar-prod
Copy link
Copy Markdown

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

SLLS-544

@sonar-review-alpha
Copy link
Copy Markdown

sonar-review-alpha Bot commented May 21, 2026

Summary

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

This PR removes deprecated API calls and fixes variable naming conventions in two test files, resolving 5 SonarQube violations. Changes are limited to test code only: deprecated setSeverity() and setType() calls removed from a mock rule builder in ConnectedModeMediumTests, and local variables renamed from all-caps OLD/NEW to camelCase oldValue/newValue in LanguageServerMediumTests. The PR also fixes indentation (tabs → spaces) in an embedded Go code snippet.

What reviewers should know

Scope: Test files only—no production code changes.

Changes breakdown:

  • ConnectedModeMediumTests.java (line ~1305-1309): Removes 2 deprecated method calls from a protobuf rule mock setup. These calls were flagged as deprecated and are no longer needed for the test behavior.
  • LanguageServerMediumTests.java: Two test methods updated with proper variable naming (lines ~934-942 and ~954-962). The tab-to-space indentation fix at line ~169 is a side effect of the edits.

No behavior changes — all modifications are code quality cleanups with no functional impact.


  • Generate Walkthrough
  • Generate Diagram

🗣️ Give feedback

Copy link
Copy Markdown

@sonar-review-alpha sonar-review-alpha Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 5 SonarQube fixes are all safe. The removals of setSeverity/setType from mockNoIssuesNoHotspotsForProject are correct — no test that calls that helper asserts those fields from the /api/rules/show.protobuf response (tests verifying rule type/severity set up their own explicit mock before calling the helper). The variable renames are clean and complete.

However, the Go code snippet in analyzeSimpleGoFileOnOpen also had its indentation changed (from \t to two spaces), and this change is not mentioned in the PR description and not related to any of the 5 SonarQube violations being addressed.

🗣️ Give feedback

Comment on lines +172 to +174
if condition1 {
} else if condition1 { // Noncompliant
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This indentation change is unrelated to the 5 SonarQube fixes and alters the actual Go source string passed to the analyzer.

The Java text block strips the common leading whitespace, which is 6 spaces (set by the closing """ on line 176). Before this change, the stripped content was \tif condition1 { (1 tab = 1 char). After this change it is if condition1 { (2 spaces = 2 chars).

This shifts every character position on affected lines by +1, breaking the column-sensitive assertions immediately below:

  • Line 180: tuple(3, 15, ...) — the { in if condition1 { moves from col 15 to col 16.
  • Line 181: tuple(4, 11, 4, 21, ...)condition1 in } else if condition1 moves from col 11–21 to col 12–22.

Either revert this indentation change and keep the original tab, or update the assertions to match the new positions.

Suggested change
if condition1 {
} else if condition1 { // Noncompliant
}
if condition1 {
} else if condition1 { // Noncompliant
}

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