From c5f3d85cf4a069054a79da7588b32f5e424df79f Mon Sep 17 00:00:00 2001 From: vil02 Date: Thu, 9 May 2024 11:39:39 +0200 Subject: [PATCH] style: include `VA_FORMAT_STRING_USES_NEWLINE` --- spotbugs-exclude.xml | 3 --- .../hashmap/hashing/HashMapCuckooHashing.java | 2 +- .../datastructures/hashmap/hashing/MainCuckooHashing.java | 2 +- .../datastructures/lists/CreateAndDetectLoop.java | 2 +- src/main/java/com/thealgorithms/others/TowerOfHanoi.java | 2 +- .../com/thealgorithms/searches/MonteCarloTreeSearch.java | 2 +- src/main/java/com/thealgorithms/sorts/InsertionSort.java | 6 +++--- 7 files changed, 8 insertions(+), 11 deletions(-) diff --git a/spotbugs-exclude.xml b/spotbugs-exclude.xml index d8c83fb7ba08..3f87cfef8725 100644 --- a/spotbugs-exclude.xml +++ b/spotbugs-exclude.xml @@ -8,9 +8,6 @@ - - - diff --git a/src/main/java/com/thealgorithms/datastructures/hashmap/hashing/HashMapCuckooHashing.java b/src/main/java/com/thealgorithms/datastructures/hashmap/hashing/HashMapCuckooHashing.java index 053751ebbc51..3fa6a812ec53 100644 --- a/src/main/java/com/thealgorithms/datastructures/hashmap/hashing/HashMapCuckooHashing.java +++ b/src/main/java/com/thealgorithms/datastructures/hashmap/hashing/HashMapCuckooHashing.java @@ -213,7 +213,7 @@ public boolean checkTableContainsKey(int key) { public double checkLoadFactor() { double factor = (double) size / tableSize; if (factor > .7) { - System.out.printf("Load factor is %.2f , rehashing table\n", factor); + System.out.printf("Load factor is %.2f , rehashing table%n", factor); reHashTableIncreasesTableSize(); } return factor; diff --git a/src/main/java/com/thealgorithms/datastructures/hashmap/hashing/MainCuckooHashing.java b/src/main/java/com/thealgorithms/datastructures/hashmap/hashing/MainCuckooHashing.java index f4e0f594de8f..6681253d7844 100644 --- a/src/main/java/com/thealgorithms/datastructures/hashmap/hashing/MainCuckooHashing.java +++ b/src/main/java/com/thealgorithms/datastructures/hashmap/hashing/MainCuckooHashing.java @@ -54,7 +54,7 @@ public static void main(String[] args) { break; } case 6: { - System.out.printf("Load factor is: %.2f\n", h.checkLoadFactor()); + System.out.printf("Load factor is: %.2f%n", h.checkLoadFactor()); break; } case 7: { diff --git a/src/main/java/com/thealgorithms/datastructures/lists/CreateAndDetectLoop.java b/src/main/java/com/thealgorithms/datastructures/lists/CreateAndDetectLoop.java index 38133ad3491f..441c95702050 100644 --- a/src/main/java/com/thealgorithms/datastructures/lists/CreateAndDetectLoop.java +++ b/src/main/java/com/thealgorithms/datastructures/lists/CreateAndDetectLoop.java @@ -81,7 +81,7 @@ public static void main(String[] args) { System.out.println("Enter the number of elements to be inserted: "); int n = sc.nextInt(); - System.out.printf("Enter the %d elements: \n", n); + System.out.printf("Enter the %d elements: %n", n); while (n-- > 0) { singlyLinkedList.insert(sc.nextInt()); } diff --git a/src/main/java/com/thealgorithms/others/TowerOfHanoi.java b/src/main/java/com/thealgorithms/others/TowerOfHanoi.java index 8969c002cb22..2216799b987a 100644 --- a/src/main/java/com/thealgorithms/others/TowerOfHanoi.java +++ b/src/main/java/com/thealgorithms/others/TowerOfHanoi.java @@ -12,7 +12,7 @@ public static void shift(int n, String startPole, String intermediatePole, Strin // Shift function is called in recursion for swapping the n-1 disc from the startPole to // the intermediatePole shift(n - 1, startPole, endPole, intermediatePole); - System.out.format("Move %d from %s to %s\n", n, startPole, endPole); // Result Printing + System.out.format("Move %d from %s to %s%n", n, startPole, endPole); // Result Printing // Shift function is called in recursion for swapping the n-1 disc from the // intermediatePole to the endPole shift(n - 1, intermediatePole, startPole, endPole); diff --git a/src/main/java/com/thealgorithms/searches/MonteCarloTreeSearch.java b/src/main/java/com/thealgorithms/searches/MonteCarloTreeSearch.java index 58afc8dfc00d..268c33cef610 100644 --- a/src/main/java/com/thealgorithms/searches/MonteCarloTreeSearch.java +++ b/src/main/java/com/thealgorithms/searches/MonteCarloTreeSearch.java @@ -78,7 +78,7 @@ public Node monteCarloTreeSearch(Node rootNode) { winnerNode = getWinnerNode(rootNode); printScores(rootNode); - System.out.format("\nThe optimal node is: %02d\n", rootNode.childNodes.indexOf(winnerNode) + 1); + System.out.format("%nThe optimal node is: %02d%n", rootNode.childNodes.indexOf(winnerNode) + 1); return winnerNode; } diff --git a/src/main/java/com/thealgorithms/sorts/InsertionSort.java b/src/main/java/com/thealgorithms/sorts/InsertionSort.java index 285755c3fcbc..3b8c286515bc 100644 --- a/src/main/java/com/thealgorithms/sorts/InsertionSort.java +++ b/src/main/java/com/thealgorithms/sorts/InsertionSort.java @@ -71,13 +71,13 @@ public static void main(String[] args) { InsertionSort insertionSort = new InsertionSort(); double insertionTime = measureApproxExecTime(insertionSort::sort, randomArray); - System.out.printf("Original insertion time: %5.2f sec.\n", insertionTime); + System.out.printf("Original insertion time: %5.2f sec.%n", insertionTime); double insertionSentinelTime = measureApproxExecTime(insertionSort::sentinelSort, copyRandomArray); - System.out.printf("Sentinel insertion time: %5.2f sec.\n", insertionSentinelTime); + System.out.printf("Sentinel insertion time: %5.2f sec.%n", insertionSentinelTime); // ~ 1.5 time sentinel sort is faster, then classical Insertion sort implementation. - System.out.printf("Sentinel insertion is %f3.2 time faster than Original insertion sort\n", insertionTime / insertionSentinelTime); + System.out.printf("Sentinel insertion is %f3.2 time faster than Original insertion sort%n", insertionTime / insertionSentinelTime); } private static double measureApproxExecTime(Function sortAlgorithm, Double[] randomArray) {