Skip to content

JAVA-7343 Exclude enum types from value-based types - #6549

Merged
aurelien-coet-sonarsource merged 1 commit into
masterfrom
ac/JAVA-7343
Nov 20, 2026
Merged

aurelien-coet-sonarsource merged 1 commit into
masterfrom
ac/JAVA-7343

Conversation

@aurelien-coet-sonarsource

@aurelien-coet-sonarsource aurelien-coet-sonarsource commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary by Gitar

  • Bug fix:
    • Excluded enum types from value-based type detection in TypeUtils.isValueBasedType
  • Tests:
    • Added TypeUtilsTest case covering enums such as Month, DayOfWeek, and TimeUnit
    • Added ValueBasedObjectIdentityCheckSample and ValueBasedObjectUsedForLockCheck cases for enum comparison and locking

This will update automatically on new commits.

@gitar-bot

gitar-bot Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved 🟡 Medium risk

Exempting enums from value-based type detection changes identity and lock diagnostics, potentially suppressing findings for enum usages.

Excludes enum types from value-based type detection in TypeUtils.isValueBasedType, so enums such as Month, DayOfWeek, and TimeUnit are no longer flagged by value-based checks. Tests cover the enum cases in TypeUtilsTest, ValueBasedObjectIdentityCheckSample, and ValueBasedObjectUsedForLockCheck. No issues found.

Verification Rules 2/2 met Repos 5 inspected · PRs 1 inspected

Functional validation No results

Rules 2 passed 2 not applicable

✅ Internal artifact registries
✅ Repository license compliance

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

SonarSource/sonarlint-intellij Inspected
SonarSource/sonarlint-vscode Inspected
SonarSource/sonar-iac Inspected
SonarSource/sonarlint-eclipse Inspected
SonarSource/sonar-lits Inspected

Cross-PR 1 PR inspected 0 open impacts

PR 6547: SONARJAVA-7339 Make the Java frontend switchable between ECJ and SemSitter 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 commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

JAVA-7343

@sonarqube-next

Copy link
Copy Markdown
Contributor

@david-schroeter david-schroeter left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR looks good to me.

Should we maybe mention that exception in the RSPEC? Since for now we say all the classes in the java.time package and its sub-packages, except Clock. But that only exclude Clock maybe a mention to enum would clarify the rule. What do you think?

@aurelien-coet-sonarsource

Copy link
Copy Markdown
Contributor Author

This PR looks good to me.

Should we maybe mention that exception in the RSPEC? Since for now we say all the classes in the java.time package and its sub-packages, except Clock. But that only exclude Clock maybe a mention to enum would clarify the rule. What do you think?

Yes, good point. I'll open another PR in RSPEC to update the description 👍

@aurelien-coet-sonarsource
aurelien-coet-sonarsource merged commit ffefac4 into master Nov 20, 2026
21 checks passed
@aurelien-coet-sonarsource
aurelien-coet-sonarsource deleted the ac/JAVA-7343 branch November 20, 2026 12:03
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.

2 participants