Skip to content

Commit f9cab2d

Browse files
committed
style: include SUI_CONTAINS_BEFORE_ADD
1 parent 0e8fed0 commit f9cab2d

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
@@ -225,9 +225,6 @@
225225
<Match>
226226
<Bug pattern="IMC_IMMATURE_CLASS_BAD_SERIALVERSIONUID" />
227227
</Match>
228-
<Match>
229-
<Bug pattern="SUI_CONTAINS_BEFORE_ADD" />
230-
</Match>
231228
<Match>
232229
<Bug pattern="DRE_DECLARED_RUNTIME_EXCEPTION" />
233230
</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)