From 8466219685e0f98b8c71b21dc8107e4641fec5a8 Mon Sep 17 00:00:00 2001 From: Piotr Idzik <65706193+vil02@users.noreply.github.com> Date: Mon, 20 May 2024 17:09:31 +0200 Subject: [PATCH] style: do not suppress `serial` (#5168) --- pom.xml | 1 - .../java/com/thealgorithms/sorts/TopologicalSort.java | 9 +-------- .../com/thealgorithms/sorts/TopologicalSortTest.java | 3 +-- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index 2c2f640d5..ead4fb6dd 100644 --- a/pom.xml +++ b/pom.xml @@ -79,7 +79,6 @@ -Xlint:all -Xlint:-auxiliaryclass -Xlint:-rawtypes - -Xlint:-serial -Xlint:-try -Xlint:-unchecked -Xlint:-lossy-conversions diff --git a/src/main/java/com/thealgorithms/sorts/TopologicalSort.java b/src/main/java/com/thealgorithms/sorts/TopologicalSort.java index ce664b019..dd3a763bb 100644 --- a/src/main/java/com/thealgorithms/sorts/TopologicalSort.java +++ b/src/main/java/com/thealgorithms/sorts/TopologicalSort.java @@ -73,13 +73,6 @@ public final class TopologicalSort { } } - static class BackEdgeException extends RuntimeException { - - BackEdgeException(String backEdge) { - super("This graph contains a cycle. No linear ordering is possible. " + backEdge); - } - } - /* * Depth First Search * @@ -131,7 +124,7 @@ public final class TopologicalSort { * * In many cases, we will not know u.f, but v.color denotes the type of edge * */ - throw new BackEdgeException("Back edge: " + u.label + " -> " + label); + throw new RuntimeException("This graph contains a cycle. No linear ordering is possible. Back edge: " + u.label + " -> " + label); } }); u.color = Color.BLACK; diff --git a/src/test/java/com/thealgorithms/sorts/TopologicalSortTest.java b/src/test/java/com/thealgorithms/sorts/TopologicalSortTest.java index 9fb0fc06a..de115b458 100644 --- a/src/test/java/com/thealgorithms/sorts/TopologicalSortTest.java +++ b/src/test/java/com/thealgorithms/sorts/TopologicalSortTest.java @@ -4,7 +4,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertIterableEquals; import static org.junit.jupiter.api.Assertions.assertThrows; -import com.thealgorithms.sorts.TopologicalSort.BackEdgeException; import com.thealgorithms.sorts.TopologicalSort.Graph; import java.util.LinkedList; import org.junit.jupiter.api.Test; @@ -55,7 +54,7 @@ class TopologicalSortTest { graph.addEdge("6", "2"); graph.addEdge("7", ""); graph.addEdge("8", ""); - Exception exception = assertThrows(BackEdgeException.class, () -> TopologicalSort.sort(graph)); + Exception exception = assertThrows(RuntimeException.class, () -> TopologicalSort.sort(graph)); String expected = "This graph contains a cycle. No linear ordering is possible. " + "Back edge: 6 -> 2"; assertEquals(exception.getMessage(), expected);