diff --git a/spotbugs-exclude.xml b/spotbugs-exclude.xml index 97c4e760..c2f9593a 100644 --- a/spotbugs-exclude.xml +++ b/spotbugs-exclude.xml @@ -126,9 +126,6 @@ - - - diff --git a/src/main/java/com/thealgorithms/ciphers/a5/CompositeLFSR.java b/src/main/java/com/thealgorithms/ciphers/a5/CompositeLFSR.java index 12e93717..3cac5582 100644 --- a/src/main/java/com/thealgorithms/ciphers/a5/CompositeLFSR.java +++ b/src/main/java/com/thealgorithms/ciphers/a5/CompositeLFSR.java @@ -26,10 +26,10 @@ public abstract class CompositeLFSR implements BaseLFSR { private boolean getMajorityBit() { Map bitCount = new TreeMap<>(); - bitCount.put(false, 0); - bitCount.put(true, 0); + bitCount.put(Boolean.FALSE, 0); + bitCount.put(Boolean.TRUE, 0); registers.forEach(lfsr -> bitCount.put(lfsr.getClockBit(), bitCount.get(lfsr.getClockBit()) + 1)); - return bitCount.get(false) <= bitCount.get(true); + return bitCount.get(Boolean.FALSE) <= bitCount.get(Boolean.TRUE); } } diff --git a/src/main/java/com/thealgorithms/datastructures/graphs/DIJSKSTRAS_ALGORITHM.java b/src/main/java/com/thealgorithms/datastructures/graphs/DIJSKSTRAS_ALGORITHM.java index 59f0d011..3eff999b 100644 --- a/src/main/java/com/thealgorithms/datastructures/graphs/DIJSKSTRAS_ALGORITHM.java +++ b/src/main/java/com/thealgorithms/datastructures/graphs/DIJSKSTRAS_ALGORITHM.java @@ -34,7 +34,7 @@ class dijkstras { for (int i = 0; i < k; i++) { dist[i] = Integer.MAX_VALUE; - Set[i] = false; + Set[i] = Boolean.FALSE; } dist[src] = 0; @@ -42,7 +42,7 @@ class dijkstras { for (int c = 0; c < k - 1; c++) { int u = minDist(dist, Set); - Set[u] = true; + Set[u] = Boolean.TRUE; for (int v = 0; v < k; v++) { if (!Set[v] && graph[u][v] != 0 && dist[u] != Integer.MAX_VALUE && dist[u] + graph[u][v] < dist[v]) { diff --git a/src/main/java/com/thealgorithms/datastructures/graphs/PrimMST.java b/src/main/java/com/thealgorithms/datastructures/graphs/PrimMST.java index e61e2b6a..24fcbe7f 100644 --- a/src/main/java/com/thealgorithms/datastructures/graphs/PrimMST.java +++ b/src/main/java/com/thealgorithms/datastructures/graphs/PrimMST.java @@ -50,7 +50,7 @@ class PrimMST { // Initialize all keys as INFINITE for (int i = 0; i < V; i++) { key[i] = Integer.MAX_VALUE; - mstSet[i] = false; + mstSet[i] = Boolean.FALSE; } // Always include first 1st vertex in MST. @@ -65,7 +65,7 @@ class PrimMST { int u = minKey(key, mstSet); // Add the picked vertex to the MST Set - mstSet[u] = true; + mstSet[u] = Boolean.TRUE; // Update key value and parent index of the adjacent // vertices of the picked vertex. Consider only those diff --git a/src/main/java/com/thealgorithms/greedyalgorithms/JobSequencing.java b/src/main/java/com/thealgorithms/greedyalgorithms/JobSequencing.java index 69d52530..ceb664a3 100644 --- a/src/main/java/com/thealgorithms/greedyalgorithms/JobSequencing.java +++ b/src/main/java/com/thealgorithms/greedyalgorithms/JobSequencing.java @@ -31,7 +31,7 @@ public final class JobSequencing { // Function to print the job sequence public static String findJobSequence(ArrayList jobs, int size) { Boolean[] slots = new Boolean[size]; - Arrays.fill(slots, false); + Arrays.fill(slots, Boolean.FALSE); int[] result = new int[size]; @@ -40,7 +40,7 @@ public final class JobSequencing { for (int j = jobs.get(i).deadline - 1; j >= 0; j--) { if (!slots[j]) { result[j] = i; - slots[j] = true; + slots[j] = Boolean.TRUE; break; } } diff --git a/src/main/java/com/thealgorithms/sorts/CircleSort.java b/src/main/java/com/thealgorithms/sorts/CircleSort.java index 756534a8..25c308b1 100644 --- a/src/main/java/com/thealgorithms/sorts/CircleSort.java +++ b/src/main/java/com/thealgorithms/sorts/CircleSort.java @@ -25,7 +25,7 @@ public class CircleSort implements SortAlgorithm { boolean swapped = false; if (left == right) { - return false; + return Boolean.FALSE; } int low = left; diff --git a/src/test/java/com/thealgorithms/bitmanipulation/IsEvenTest.java b/src/test/java/com/thealgorithms/bitmanipulation/IsEvenTest.java index 674b79e5..0b2bfb0b 100644 --- a/src/test/java/com/thealgorithms/bitmanipulation/IsEvenTest.java +++ b/src/test/java/com/thealgorithms/bitmanipulation/IsEvenTest.java @@ -1,14 +1,17 @@ package com.thealgorithms.bitmanipulation; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; class IsEvenTest { @Test void testIsEven() { - assertEquals(true, IsEven.isEven(2)); - assertEquals(true, IsEven.isEven(-12)); - assertEquals(false, IsEven.isEven(21)); + assertTrue(IsEven.isEven(0)); + assertTrue(IsEven.isEven(2)); + assertTrue(IsEven.isEven(-12)); + assertFalse(IsEven.isEven(21)); + assertFalse(IsEven.isEven(-1)); } } diff --git a/src/test/java/com/thealgorithms/dynamicprogramming/SumOfSubsetTest.java b/src/test/java/com/thealgorithms/dynamicprogramming/SumOfSubsetTest.java index 53c34937..9df35447 100644 --- a/src/test/java/com/thealgorithms/dynamicprogramming/SumOfSubsetTest.java +++ b/src/test/java/com/thealgorithms/dynamicprogramming/SumOfSubsetTest.java @@ -1,6 +1,7 @@ package com.thealgorithms.dynamicprogramming; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; @@ -8,10 +9,10 @@ class SumOfSubsetTest { @Test void basicCheck() { - assertEquals(false, SumOfSubset.subsetSum(new int[] {1, 2, 7, 10, 9}, 4, 14)); - assertEquals(false, SumOfSubset.subsetSum(new int[] {2, 15, 1, 6, 7}, 4, 4)); - assertEquals(true, SumOfSubset.subsetSum(new int[] {7, 3, 2, 5, 8}, 4, 14)); - assertEquals(true, SumOfSubset.subsetSum(new int[] {4, 3, 2, 1}, 3, 5)); - assertEquals(true, SumOfSubset.subsetSum(new int[] {1, 7, 2, 9, 10}, 4, 13)); + assertFalse(SumOfSubset.subsetSum(new int[] {1, 2, 7, 10, 9}, 4, 14)); + assertFalse(SumOfSubset.subsetSum(new int[] {2, 15, 1, 6, 7}, 4, 4)); + assertTrue(SumOfSubset.subsetSum(new int[] {7, 3, 2, 5, 8}, 4, 14)); + assertTrue(SumOfSubset.subsetSum(new int[] {4, 3, 2, 1}, 3, 5)); + assertTrue(SumOfSubset.subsetSum(new int[] {1, 7, 2, 9, 10}, 4, 13)); } } diff --git a/src/test/java/com/thealgorithms/maths/PythagoreanTripleTest.java b/src/test/java/com/thealgorithms/maths/PythagoreanTripleTest.java index 2dc2643c..1834c6e0 100644 --- a/src/test/java/com/thealgorithms/maths/PythagoreanTripleTest.java +++ b/src/test/java/com/thealgorithms/maths/PythagoreanTripleTest.java @@ -1,6 +1,7 @@ package com.thealgorithms.maths; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; @@ -8,14 +9,14 @@ public class PythagoreanTripleTest { @Test public void Testpythagoreantriple() { - assertEquals(true, PythagoreanTriple.isPythagTriple(3, 4, 5)); - assertEquals(true, PythagoreanTriple.isPythagTriple(6, 8, 10)); - assertEquals(true, PythagoreanTriple.isPythagTriple(9, 12, 15)); - assertEquals(true, PythagoreanTriple.isPythagTriple(12, 16, 20)); - assertEquals(true, PythagoreanTriple.isPythagTriple(15, 20, 25)); - assertEquals(true, PythagoreanTriple.isPythagTriple(18, 24, 30)); - assertEquals(false, PythagoreanTriple.isPythagTriple(5, 20, 30)); - assertEquals(false, PythagoreanTriple.isPythagTriple(6, 8, 100)); - assertEquals(false, PythagoreanTriple.isPythagTriple(-2, -2, 2)); + assertTrue(PythagoreanTriple.isPythagTriple(3, 4, 5)); + assertTrue(PythagoreanTriple.isPythagTriple(6, 8, 10)); + assertTrue(PythagoreanTriple.isPythagTriple(9, 12, 15)); + assertTrue(PythagoreanTriple.isPythagTriple(12, 16, 20)); + assertTrue(PythagoreanTriple.isPythagTriple(15, 20, 25)); + assertTrue(PythagoreanTriple.isPythagTriple(18, 24, 30)); + assertFalse(PythagoreanTriple.isPythagTriple(5, 20, 30)); + assertFalse(PythagoreanTriple.isPythagTriple(6, 8, 100)); + assertFalse(PythagoreanTriple.isPythagTriple(-2, -2, 2)); } } diff --git a/src/test/java/com/thealgorithms/others/TwoPointersTest.java b/src/test/java/com/thealgorithms/others/TwoPointersTest.java index 8cadb031..e8fe41b0 100644 --- a/src/test/java/com/thealgorithms/others/TwoPointersTest.java +++ b/src/test/java/com/thealgorithms/others/TwoPointersTest.java @@ -1,6 +1,7 @@ package com.thealgorithms.others; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; @@ -10,34 +11,34 @@ public class TwoPointersTest { void twoPointersFirstTestCase() { int[] arr = {2, 6, 9, 22, 121}; int key = 28; - assertEquals(true, TwoPointers.isPairedSum(arr, key)); + assertTrue(TwoPointers.isPairedSum(arr, key)); } @Test void twoPointersSecondTestCase() { int[] arr = {-1, -12, 12, 0, 8}; int key = 0; - assertEquals(true, TwoPointers.isPairedSum(arr, key)); + assertTrue(TwoPointers.isPairedSum(arr, key)); } @Test void twoPointersThirdTestCase() { int[] arr = {12, 35, 12, 152, 0}; int key = 13; - assertEquals(false, TwoPointers.isPairedSum(arr, key)); + assertFalse(TwoPointers.isPairedSum(arr, key)); } @Test void twoPointersFourthTestCase() { int[] arr = {-2, 5, -1, 52, 31}; int key = -3; - assertEquals(true, TwoPointers.isPairedSum(arr, key)); + assertTrue(TwoPointers.isPairedSum(arr, key)); } @Test void twoPointersFiftiethTestCase() { int[] arr = {25, 1, 0, 61, 21}; int key = 12; - assertEquals(false, TwoPointers.isPairedSum(arr, key)); + assertFalse(TwoPointers.isPairedSum(arr, key)); } } diff --git a/src/test/java/com/thealgorithms/strings/ValidParenthesesTest.java b/src/test/java/com/thealgorithms/strings/ValidParenthesesTest.java index 6b7e04e9..22deb4b1 100644 --- a/src/test/java/com/thealgorithms/strings/ValidParenthesesTest.java +++ b/src/test/java/com/thealgorithms/strings/ValidParenthesesTest.java @@ -1,6 +1,7 @@ package com.thealgorithms.strings; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; @@ -8,16 +9,16 @@ public class ValidParenthesesTest { @Test void testOne() { - assertEquals(true, ValidParentheses.isValid("()")); + assertTrue(ValidParentheses.isValid("()")); } @Test void testTwo() { - assertEquals(true, ValidParentheses.isValid("()[]{}")); + assertTrue(ValidParentheses.isValid("()[]{}")); } @Test void testThree() { - assertEquals(false, ValidParentheses.isValid("(]")); + assertFalse(ValidParentheses.isValid("(]")); } }