Skip to content

SONARJAVA-6434 S1186 Do not report on annotated compact constructors in records#5647

Closed
tomasz-tylenda-sonarsource wants to merge 1 commit into
masterfrom
tt/comm-S1186-record-compact-ctor
Closed

SONARJAVA-6434 S1186 Do not report on annotated compact constructors in records#5647
tomasz-tylenda-sonarsource wants to merge 1 commit into
masterfrom
tt/comm-S1186-record-compact-ctor

Conversation

@tomasz-tylenda-sonarsource

@tomasz-tylenda-sonarsource tomasz-tylenda-sonarsource commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Summary by Gitar

  • Bug fixes:
    • Modified EmptyMethodsCheck to ignore annotated compact constructors in Java records.
    • Added isAnnotatedCompactConstructor helper to verify constructor annotations and record syntax.

This will update automatically on new commits.

@sonarqubecloud

sonarqubecloud Bot commented Jun 2, 2026

Copy link
Copy Markdown

Agentic Analysis: Early Results

Agentic Analysis and Context Augmentation are available on your project. Here are some issues that could have been prevented. Follow the links to learn how to put them into action.

3 issue(s) found across 1 file(s):

Rule File Line Message
java:S1186 java-checks-test-sources/default/src/main/java/checks/EmptyMethodsCheckSample.java 14 Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation.
java:S1186 java-checks-test-sources/default/src/main/java/checks/EmptyMethodsCheckSample.java 20 Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation.
java:S6207 java-checks-test-sources/default/src/main/java/checks/EmptyMethodsCheckSample.java 20 Remove this redundant constructor which is the same as a default one.

Analyzed by SonarQube Agentic Analysis in 5.7 s

@hashicorp-vault-sonar-prod

hashicorp-vault-sonar-prod Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

SONARJAVA-6434

Comment thread java-checks/src/main/java/org/sonar/java/checks/EmptyMethodsCheck.java Outdated
@sonarqube-next

sonarqube-next Bot commented Jun 2, 2026

Copy link
Copy Markdown

Quality Gate failed Quality Gate failed

Failed conditions
4 New issues

See analysis details on SonarQube

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE SonarQube for IDE

@gitar-bot

gitar-bot Bot commented Jun 8, 2026

Copy link
Copy Markdown
CI failed: The build experienced one integration test failure in `JavaRulingTest` due to updated analyzer behavior, along with a transient infrastructure failure caused by a 503 error from the SonarQube server.

Overview

This build failure includes one change-related test regression and one transient infrastructure issue. The primary blocking issue is an assertion failure in the integration test suite, while the secondary issue is a temporary connectivity problem with the SonarQube server.

Failures

JavaRulingTest failure (confidence: high)

  • Type: test
  • Affected jobs: 79070553281
  • Related to change: yes
  • Root cause: The PR change to S1186 (skipping annotation checks on compact constructors) caused the Java analyzer to produce fewer findings than expected by the existing eclipse_jetty_incremental test case.
  • Suggested fix: Verify if the change in behavior is intentional. If so, update the baseline expectation in its/ruling/src/test/resources to match the new analysis output.

SonarQube Server 503 (confidence: high)

  • Type: infrastructure
  • Affected jobs: Not specified (Template 1)
  • Related to change: no
  • Root cause: A transient HTTP 503 Service Unavailable error occurred while the scanner attempted to query the SonarQube server version.
  • Suggested fix: This is an infrastructure-related failure. Re-run the CI job; if the issue persists, check the health of the SonarQube server.

Summary

  • Change-related failures: 1 (Test baseline needs update due to intentional change in rule behavior).
  • Infrastructure/flaky failures: 1 (Transient 503 server error).
  • Recommended action: First, update the test baselines to reflect the code change in EmptyMethodsCheck.java. If the build still fails after that, re-run the pipeline to clear the transient infrastructure 503 error.
Code Review ✅ Approved 1 resolved / 1 findings

Modifies EmptyMethodsCheck to ignore annotated compact constructors in Java records. Cleanup of unused field and local variable findings ensures code cleanliness.

✅ 1 resolved
Quality: Unused field line and local variable text left in code

📄 java-checks/src/main/java/org/sonar/java/checks/EmptyMethodsCheck.java:56 📄 java-checks/src/main/java/org/sonar/java/checks/EmptyMethodsCheck.java:60 📄 java-checks/src/main/java/org/sonar/java/checks/EmptyMethodsCheck.java:123
Two pieces of code were added that are never used:

  1. private int line = -1; (line 56) is assigned in visitNode but never read anywhere.
  2. var text = QuickFixHelper.contentForTree(methodTree, context); (line 123) is computed in checkMethod but the result is never referenced.

These appear to be debugging leftovers that should be removed before merge.

Tip

Comment Gitar fix CI or enable auto-apply: gitar auto-apply:on

Options

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

Comment with these commands to change:

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

Was this helpful? React with 👍 / 👎 | Gitar

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