Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ public List<Tree.Kind> nodesToVisit() {
public void visitNode(Tree tree) {
ClassTree classTree = (ClassTree) tree;
IdentifierTree simpleName = classTree.simpleName();
if (simpleName != null && isNotExtending(classTree) && isEmpty(classTree)) {
reportIssue(simpleName, "Remove this empty class, write its code or make it an \"interface\".");
}
if (simpleName!=null)
reportIssue(simpleName, "Remove this empty class, write its code or make it an \"interface\".");
Comment on lines +39 to +40

@gitar-bot gitar-bot Bot Oct 8, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🚨 Bug: S2094 now reports every named class/record, not just empty ones

The isNotExtending(classTree) && isEmpty(classTree) guard was removed. Now visitNode calls reportIssue for every CLASS and RECORD that has a name, so you'll get a false positive on every class with members, annotations, record components, a superclass or interfaces. The message "Remove this empty class..." is wrong for all of those. Existing expectations in EmptyClassCheck tests (the // Noncompliant markers on compliant classes) will fail, and analysis results across all projects will flood. To fix this, put the original condition back.

Restore the emptiness/non-extending guard:

if (simpleName != null && isNotExtending(classTree) && isEmpty(classTree)) {
  reportIssue(simpleName, "Remove this empty class, write its code or make it an "interface".");
}

Was this helpful? React with 👍 / 👎

}

private static boolean isNotExtending(ClassTree tree) {
Expand Down
Loading