Skip to content

Commit

Permalink
Group by Class/Package shows bugs for other class/package JetBrains#1628
Browse files Browse the repository at this point in the history
  • Loading branch information
skirge committed Sep 11, 2024
1 parent ee89c4c commit a671622
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/main/java/org/jetbrains/plugins/spotbugs/core/Bug.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,13 @@ public static boolean equalsBugType(@NotNull final Bug bugA, @NotNull final Bug
}
return true;
}

public static boolean equalsBugClass(@NotNull final Bug bugA, @NotNull final Bug bugB) {
final BugInstance a = bugA.getInstance();
final BugInstance b = bugB.getInstance();
if (!StringUtil.equals(a.getPrimaryClass().getClassName(), b.getPrimaryClass().getClassName())) {
return false;
}
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public BugInstanceGroupNode findChildNode(final RecurseVisitCriteria recurseVisi

@Override
public void visitGroupNode(@NotNull final BugInstanceGroupNode node) {
if (Bug.equalsBugType(_recurseVisitCriteria.getBug(), node.getBug()) && _recurseVisitCriteria.getDepth() == node.getDepth() && _recurseVisitCriteria.getGroupName().equals(node.getGroupName())) {
if (Bug.equalsBugType(_recurseVisitCriteria.getBug(), node.getBug()) && Bug.equalsBugClass(_recurseVisitCriteria.getBug(), node.getBug()) && _recurseVisitCriteria.getDepth() == node.getDepth() && _recurseVisitCriteria.getGroupName().equals(node.getGroupName())) {
_resultNode = node;
} else {
_resultNode = node.findChildNode(_recurseVisitCriteria.getBug(), _recurseVisitCriteria.getDepth(), _recurseVisitCriteria.getGroupName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public void addChild(final VisitableTreeNode node) {

@Nullable
public BugInstanceGroupNode findChildNode(final Bug bug, final int depth, final String groupName) {
if (Bug.equalsBugType(this.bug, bug) && depth == _depthFromRoot && groupName.equals(_groupName)) {
if (Bug.equalsBugType(this.bug, bug) && Bug.equalsBugClass(this.bug, bug) && depth == _depthFromRoot && groupName.equals(_groupName)) {
return this;
}
final RecurseVisitCriteria criteria = new RecurseVisitCriteria(bug, depth, groupName);
Expand Down

0 comments on commit a671622

Please sign in to comment.