Skip to content

JAVA-7374 Document intentionally empty visitor overrides in SQLInjectionCheck - #6546

Closed
sonarqube-next[bot] wants to merge 3 commits into
masterfrom
remediation/dd238b16-ce6f-4ec5-b878-9d501053ac6d
Closed

sonarqube-next[bot] wants to merge 3 commits into
masterfrom
remediation/dd238b16-ce6f-4ec5-b878-9d501053ac6d

Conversation

@sonarqube-next

Copy link
Copy Markdown
Contributor

This PR was automatically created by the Remediation Agent.

Added explanatory comments to the empty visitClass and visitLambdaExpression overrides clarifying that return statements from nested classes and lambdas are deliberately not collected. This resolves two java:S1186 violations and makes the intent of the visitor clear to future maintainers.

View Project in SonarQube


Fixed Issues

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

Location: java:java-checks/src/main/java/org/sonar/java/checks/SQLInjectionCheck.java:500

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

Added a nested comment in the empty visitLambdaExpression override explaining it intentionally does not collect return statements from nested lambdas.

Added a nested comment in the empty visitClass override explaining it intentionally does not collect return statements from nested classes.

diff --git a/java-checks/src/main/java/org/sonar/java/checks/SQLInjectionCheck.java b/java-checks/src/main/java/org/sonar/java/checks/SQLInjectionCheck.java
index 6ce4867..7df893e 100644
--- a/java-checks/src/main/java/org/sonar/java/checks/SQLInjectionCheck.java
+++ b/java-checks/src/main/java/org/sonar/java/checks/SQLInjectionCheck.java
@@ -498,10 +498,12 @@ public class SQLInjectionCheck extends IssuableSubscriptionVisitor {
 
     @Override
     public void visitLambdaExpression(LambdaExpressionTree lambdaExpressionTree) {
+      // intentionally empty: do not collect return statements from nested lambdas
     }
 
     @Override
     public void visitClass(ClassTree tree) {
+      // intentionally empty: do not collect return statements from nested classes
     }
   }

SonarQube Remediation Agent uses AI. Check for mistakes.

Luqmansonar and others added 3 commits November 19, 2026 15:38
…ts reach the query

Do not report queries built from provably fixed content: nCopies and stream
joins of constants, same-class non-overridable helpers returning constants or
constant-only StringBuilders, and format/formatted over constants.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… a read-only builder usage

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@sonarqube-next
sonarqube-next Bot requested a review from Luqmansonar November 20, 2026 08:24
@gitar-bot

gitar-bot Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved 🟢 Low risk

The two comments clarify intentionally empty visitor overrides; executable behavior and SQL-injection analysis remain unchanged, limiting impact to maintainability.

Adds explanatory comments to the empty visitLambdaExpression and visitClass overrides in SQLInjectionCheck.java, documenting that return statements from nested lambdas and classes are intentionally not collected. No issues found.

Verification Rules 2/2 met PRs 2 inspected

Functional validation No results

Rules 2 passed 2 not applicable

✅ Internal artifact registries
✅ Repository license compliance

Broader impact PRs 2 inspected
Cross-PR 2 PRs inspected 0 open impacts

PR 6536: SONARJAVA-7025 S2077 should not raise when only fixed literal fragments reach the query Inspected
PR 6545: JAVA-7373 Document intentionally empty visitor overrides in SQLInjectionCheck Inspected

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@hashicorp-vault-sonar-prod hashicorp-vault-sonar-prod Bot changed the title Document intentionally empty visitor overrides in SQLInjectionCheck JAVA-7374 Document intentionally empty visitor overrides in SQLInjectionCheck Nov 20, 2026
@hashicorp-vault-sonar-prod

hashicorp-vault-sonar-prod Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

JAVA-7374

@sonarqube-next

Copy link
Copy Markdown
Contributor Author

Base automatically changed from sonarjava-7025-s2077-fixed-fragments to master November 20, 2026 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant