Skip to content

SONARJAVA-6119 S3078 report on compact source files#5456

Merged
tomasz-tylenda-sonarsource merged 2 commits intomasterfrom
tt/S3078_volatile_compact_source
Feb 12, 2026
Merged

SONARJAVA-6119 S3078 report on compact source files#5456
tomasz-tylenda-sonarsource merged 2 commits intomasterfrom
tt/S3078_volatile_compact_source

Conversation

@tomasz-tylenda-sonarsource
Copy link
Copy Markdown
Contributor

No description provided.

@hashicorp-vault-sonar-prod hashicorp-vault-sonar-prod Bot changed the title S3078 report on compact source files SONARJAVA-6119 S3078 report on compact source files Feb 12, 2026
@hashicorp-vault-sonar-prod
Copy link
Copy Markdown
Contributor

hashicorp-vault-sonar-prod Bot commented Feb 12, 2026

SONARJAVA-6119

Copy link
Copy Markdown
Contributor

@rombirli rombirli left a comment

Choose a reason for hiding this comment

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

This PR looks good. just small comments about initial implementation of this rule

Comment on lines +128 to +129
CLASS,
IMPLICIT_CLASS:
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.

I think that interfaces (with default implementation) and records should also be checked here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Comment on lines 92 to 102
private void checkBooleanToggling(Tree tree, Symbol identifierSymbol) {
Tree parent = tree.parent();
if (parent.is(Tree.Kind.PARENTHESIZED_EXPRESSION)) {
checkBooleanToggling(parent, identifierSymbol);
} else if (parent.is(Tree.Kind.ASSIGNMENT)) {
IdentifierTree variableIdentifier = getVariableIdentifier(((AssignmentExpressionTree) parent).variable());
if (variableIdentifier != null && identifierSymbol.equals(variableIdentifier.symbol())) {
reportIssueIfNotInExcludedContext(tree, "AtomicBoolean");
}
}
}
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.

I know you didn't write it, but i dont see why boolean toggling is a specific case and I believe that any assignation should be checked (instead of only boolean togglings)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Discussed offline: this is out of scope for this PR, but I created https://sonarsource.atlassian.net/browse/SONARJAVA-6125.

@sonarqube-next
Copy link
Copy Markdown

@tomasz-tylenda-sonarsource tomasz-tylenda-sonarsource merged commit 4ff6e79 into master Feb 12, 2026
32 of 33 checks passed
@tomasz-tylenda-sonarsource tomasz-tylenda-sonarsource deleted the tt/S3078_volatile_compact_source branch February 12, 2026 16:55
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