We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
SUI_CONTAINS_BEFORE_ADD
1 parent 0e8fed0 commit f9cab2dCopy full SHA for f9cab2d
spotbugs-exclude.xml
@@ -225,9 +225,6 @@
225
<Match>
226
<Bug pattern="IMC_IMMATURE_CLASS_BAD_SERIALVERSIONUID" />
227
</Match>
228
- <Match>
229
- <Bug pattern="SUI_CONTAINS_BEFORE_ADD" />
230
- </Match>
231
232
<Bug pattern="DRE_DECLARED_RUNTIME_EXCEPTION" />
233
src/main/java/com/thealgorithms/datastructures/graphs/ConnectedComponent.java
@@ -81,8 +81,7 @@ public int countGraphs() {
81
Set<Node> markedNodes = new HashSet<Node>();
82
83
for (Node n : nodeList) {
84
- if (!markedNodes.contains(n)) {
85
- markedNodes.add(n);
+ if (markedNodes.add(n)) {
86
markedNodes.addAll(depthFirstSearch(n, new ArrayList<Node>()));
87
count++;
88
}
0 commit comments