Skip to content

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

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

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
Copy link
Copy Markdown
Contributor

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


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
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 2, 2026

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
Copy link
Copy Markdown
Contributor

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

SONARJAVA-6434

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

sonarqube-next Bot commented Jun 2, 2026

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
Copy link
Copy Markdown

gitar-bot Bot commented Jun 2, 2026

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