Skip to content

Commit 45c2308

Browse files
committed
style: include SUI_CONTAINS_BEFORE_ADD
1 parent a2af09c commit 45c2308

File tree

2 files changed

+1
-5
lines changed

2 files changed

+1
-5
lines changed

spotbugs-exclude.xml

-3
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,6 @@
222222
<Match>
223223
<Bug pattern="IMC_IMMATURE_CLASS_BAD_SERIALVERSIONUID" />
224224
</Match>
225-
<Match>
226-
<Bug pattern="SUI_CONTAINS_BEFORE_ADD" />
227-
</Match>
228225
<Match>
229226
<Bug pattern="DRE_DECLARED_RUNTIME_EXCEPTION" />
230227
</Match>

src/main/java/com/thealgorithms/datastructures/graphs/ConnectedComponent.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ public int countGraphs() {
8181
Set<Node> markedNodes = new HashSet<Node>();
8282

8383
for (Node n : nodeList) {
84-
if (!markedNodes.contains(n)) {
85-
markedNodes.add(n);
84+
if (markedNodes.add(n)) {
8685
markedNodes.addAll(depthFirstSearch(n, new ArrayList<Node>()));
8786
count++;
8887
}

0 commit comments

Comments
 (0)