Skip to content

SONARJAVA-7239: Improve S9357 to not raise on GWT versions older than 2.8 - #6399

Draft
romainbrenguier wants to merge 1 commit into
masterfrom
romain/sonarjava-7239
Draft

romainbrenguier wants to merge 1 commit into
masterfrom
romain/sonarjava-7239

Conversation

@romainbrenguier

@romainbrenguier romainbrenguier commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • GWT false positives: GWT has only supported Java 8 lambda expressions since version 2.8, so in projects that depend on an older GWT version, anonymous classes can't be rewritten as lambdas. S9357 now implements DependencyVersionAware and turns itself off when gwt-user, gwt-dev or gwt-servlet is older than 2.8. Projects on GWT 2.8+ and projects without GWT behave as before.
  • RSPEC description: added the missing variable type to the first example (InterfaceImplementation taskVariable = ...) and listed the GWT case under the exceptions. The same change should also go into the RSPEC repository.

Tests

  • New sample AnonymousClassOnFunctionalInterfaceCheckGwtSample, verified against these classpaths: GWT 2.8 (issue raised), GWT 2.7 (no issue), and a mix of gwt-user 2.8 with gwt-dev 2.6 (no issue).

🤖 Generated with Claude Code

Agent workflow

Tool link: https://github.com/SonarSource/languages-experimental-tooling/tree/romain/my-tickets/personal/romain-brenguier
PR created using uv run create_with_claude.py

…WT older than 2.8

GWT supports lambda expressions only since version 2.8, so anonymous
classes cannot be replaced by lambdas in projects depending on an older
GWT version. Also add the missing variable type in the rule description example.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@hashicorp-vault-sonar-prod

hashicorp-vault-sonar-prod Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

SONARJAVA-7239

@gitar-bot

gitar-bot Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved

🟡 Medium risk · Dependency-version gating disables S9357 when an older GWT artifact is present, which could suppress useful findings even if that artifact does not constrain the code.

Makes S9357 skip projects that depend on GWT older than 2.8, since those versions cannot rewrite anonymous classes as lambdas, and updates the RSPEC example accordingly. No issues found.

Verification Rules 2/2 met Repos 5 inspected

Functional validation No results

Rules 2 passed 1 not applicable

✅ Internal artifact registries
✅ Repository license compliance

Broader impact Repos 5 inspected
Cross-repo 5 repositories inspected 0 open impacts

SonarSource/sonarlint-intellij Inspected
SonarSource/sonarlint-language-server Inspected
SonarSource/sonarlint-vscode Inspected
SonarSource/sonar-java-symbolic-execution Inspected
SonarSource/rspec-maven-plugin 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

@sonarqube-next

Copy link
Copy Markdown
Contributor

This branch has not been deployed

No deployments
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