Skip to content

Add explanatory comments to empty test stub methods#719

Open
sonarqube-agent[bot] wants to merge 1 commit into
masterfrom
remediate-master-20260608-050249-d52b72f9
Open

Add explanatory comments to empty test stub methods#719
sonarqube-agent[bot] wants to merge 1 commit into
masterfrom
remediate-master-20260608-050249-d52b72f9

Conversation

@sonarqube-agent

Copy link
Copy Markdown
Contributor

This PR was automatically created by the Remediation Agent's Scheduled backlog remediation feature.

Why these issues? All 5 issues were located in test files (AbstractLanguageServerMediumTests.java) which are commonly excluded from strict production code standards. Adding comments to intentionally empty test stub methods is a low-risk, high-value improvement that clarifies intent and resolves critical quality violations without affecting production code behavior.

Fixed 5 SonarQube S1186 critical issues by adding explanatory comments to intentionally empty methods in the test fake client class. Empty methods in test code now clearly document why they are no-op stubs, satisfying code quality standards.

View Project in SonarCloud


Fixed Issues

java:S1186 - Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation. • CRITICALView issue

Location: sonarlint-language-server:src/test/java/org/sonarsource/sonarlint/ls/mediumtests/AbstractLanguageServerMediumTests.java:602

Why is this an issue?

An empty method is generally considered bad practice and can lead to confusion, readability, and maintenance issues. Empty methods bring no functionality and are misleading to others as they might think the method implementation fulfills a specific and identified requirement.

What changed

Adds a nested comment inside the empty showHotspot() method at line 602, explaining that it is intentionally empty because it is not needed for tests using this fake client. This satisfies the rule requiring empty methods to have a comment explaining why they are empty.

--- a/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/AbstractLanguageServerMediumTests.java
+++ b/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/AbstractLanguageServerMediumTests.java
@@ -602,0 +603,1 @@ public abstract class AbstractLanguageServerMediumTests {
+      // Intentionally empty: not needed for tests using this fake client
java:S1186 - Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation. • CRITICALView issue

Location: sonarlint-language-server:src/test/java/org/sonarsource/sonarlint/ls/mediumtests/AbstractLanguageServerMediumTests.java:620

Why is this an issue?

An empty method is generally considered bad practice and can lead to confusion, readability, and maintenance issues. Empty methods bring no functionality and are misleading to others as they might think the method implementation fulfills a specific and identified requirement.

What changed

Adds a nested comment inside the empty maybeShowWiderLanguageSupportNotification() method at line 620, explaining that it is intentionally empty because it is not needed for tests using this fake client. This satisfies the rule requiring empty methods to have a comment explaining why they are empty.

--- a/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/AbstractLanguageServerMediumTests.java
+++ b/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/AbstractLanguageServerMediumTests.java
@@ -621,1 +623,1 @@ public abstract class AbstractLanguageServerMediumTests {
-
+      // Intentionally empty: not needed for tests using this fake client
java:S1186 - Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation. • CRITICALView issue

Location: sonarlint-language-server:src/test/java/org/sonarsource/sonarlint/ls/mediumtests/AbstractLanguageServerMediumTests.java:571

Why is this an issue?

An empty method is generally considered bad practice and can lead to confusion, readability, and maintenance issues. Empty methods bring no functionality and are misleading to others as they might think the method implementation fulfills a specific and identified requirement.

What changed

Adds a nested comment inside the empty doNotShowMissingRequirementsMessageAgain() method at line 571, explaining that it is intentionally empty as a no-op stub for tests. This satisfies the rule requiring empty methods to have a comment explaining why they are empty.

--- a/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/AbstractLanguageServerMediumTests.java
+++ b/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/AbstractLanguageServerMediumTests.java
@@ -572,1 +572,1 @@ public abstract class AbstractLanguageServerMediumTests {
-
+      // Intentionally empty: no-op stub for tests
java:S1186 - Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation. • CRITICALView issue

Location: sonarlint-language-server:src/test/java/org/sonarsource/sonarlint/ls/mediumtests/AbstractLanguageServerMediumTests.java:611

Why is this an issue?

An empty method is generally considered bad practice and can lead to confusion, readability, and maintenance issues. Empty methods bring no functionality and are misleading to others as they might think the method implementation fulfills a specific and identified requirement.

What changed

Adds a nested comment inside the empty showIssueOrHotspot() method at line 611, explaining that it is a no-op in the fake client used for tests. This satisfies the rule requiring empty methods to have a comment explaining why they are empty.

--- a/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/AbstractLanguageServerMediumTests.java
+++ b/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/AbstractLanguageServerMediumTests.java
@@ -611,0 +613,1 @@ public abstract class AbstractLanguageServerMediumTests {
+      // No-op in fake client used for tests
java:S1186 - Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation. • CRITICALView issue

Location: sonarlint-language-server:src/test/java/org/sonarsource/sonarlint/ls/mediumtests/AbstractLanguageServerMediumTests.java:625

Why is this an issue?

An empty method is generally considered bad practice and can lead to confusion, readability, and maintenance issues. Empty methods bring no functionality and are misleading to others as they might think the method implementation fulfills a specific and identified requirement.

What changed

Adds a nested comment inside the empty showFirstSecretDetectionNotification() method at line 625, explaining that it is a no-op in the fake client used for testing. This satisfies the rule requiring empty methods to have a comment explaining why they are empty.

--- a/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/AbstractLanguageServerMediumTests.java
+++ b/src/test/java/org/sonarsource/sonarlint/ls/mediumtests/AbstractLanguageServerMediumTests.java
@@ -625,0 +628,1 @@ public abstract class AbstractLanguageServerMediumTests {
+      // No-op in fake client used for testing

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


SonarQube Remediation Agent uses AI. Check for mistakes.

Fixed issues:
- AZjRjd2C592amupb0FPg for java:S1186 rule
- AZjRjd2C592amupb0FPe for java:S1186 rule
- AZjRjd2C592amupb0FPh for java:S1186 rule
- AZjRjd2C592amupb0FPf for java:S1186 rule
- AZjRjd2C592amupb0FPd for java:S1186 rule

Generated by SonarQube Agent (task: 1efd7c88-8b38-472b-ad40-ec9f4b8365bd)
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