Skip to content

style: include OCP_OVERLY_CONCRETE_PARAMETER #5833

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions spotbugs-exclude.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@
<Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE" />
</Match>
<!-- fb-contrib -->
<Match>
<Bug pattern="OCP_OVERLY_CONCRETE_PARAMETER" />
</Match>
<Match>
<Bug pattern="LSC_LITERAL_STRING_COMPARISON" />
</Match>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.thealgorithms.backtracking;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
Expand Down Expand Up @@ -95,7 +96,7 @@ public static void removeWord(char[][] puzzle, String word, int row, int col, bo
* @param words The list of words to be placed.
* @return true if the crossword is solved, false otherwise.
*/
public static boolean solveCrossword(char[][] puzzle, List<String> words) {
public static boolean solveCrossword(char[][] puzzle, Collection<String> words) {
// Create a mutable copy of the words list
List<String> remainingWords = new ArrayList<>(words);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public int getEstimated() {
}

// Initializes the graph with edges defined in the input data
static void initializeGraph(Graph graph, ArrayList<Integer> data) {
static void initializeGraph(Graph graph, List<Integer> data) {
for (int i = 0; i < data.size(); i += 4) {
graph.addEdge(new Edge(data.get(i), data.get(i + 1), data.get(i + 2)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private EdmondsBlossomAlgorithm() {
* @param vertexCount The number of vertices in the graph.
* @return A list of matched pairs of vertices.
*/
public static List<int[]> maximumMatching(List<int[]> edges, int vertexCount) {
public static List<int[]> maximumMatching(Iterable<int[]> edges, int vertexCount) {
List<List<Integer>> graph = new ArrayList<>(vertexCount);

// Initialize each vertex's adjacency list.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.thealgorithms.datastructures.lists;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
Expand Down Expand Up @@ -38,7 +39,7 @@ public static void main(String[] args) {
* @param listB the second list to merge
* @param listC the result list after merging
*/
public static void merge(List<Integer> listA, List<Integer> listB, List<Integer> listC) {
public static void merge(List<Integer> listA, List<Integer> listB, Collection<Integer> listC) {
int pa = 0;
/* the index of listA */
int pb = 0;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/thealgorithms/geometry/ConvexHull.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.thealgorithms.geometry;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
Expand Down Expand Up @@ -89,7 +90,7 @@ public static List<Point> convexHullRecursive(List<Point> points) {
return result;
}

private static void constructHull(List<Point> points, Point left, Point right, Set<Point> convexSet) {
private static void constructHull(Collection<Point> points, Point left, Point right, Set<Point> convexSet) {
if (!points.isEmpty()) {
Point extremePoint = null;
int extremePointDistance = Integer.MIN_VALUE;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.thealgorithms.maths;

import java.util.ArrayList;
import java.util.Collection;

/**
* Class for circular convolution of two discrete signals using the convolution
Expand All @@ -19,7 +20,7 @@ private CircularConvolutionFFT() {
* @param x The signal to be padded.
* @param newSize The new size of the signal.
*/
private static void padding(ArrayList<FFT.Complex> x, int newSize) {
private static void padding(Collection<FFT.Complex> x, int newSize) {
if (x.size() < newSize) {
int diff = newSize - x.size();
for (int i = 0; i < diff; i++) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/thealgorithms/maths/ConvolutionFFT.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.thealgorithms.maths;

import java.util.ArrayList;
import java.util.Collection;

/**
* Class for linear convolution of two discrete signals using the convolution
Expand All @@ -19,7 +20,7 @@ private ConvolutionFFT() {
* @param x The signal to be padded.
* @param newSize The new size of the signal.
*/
private static void padding(ArrayList<FFT.Complex> x, int newSize) {
private static void padding(Collection<FFT.Complex> x, int newSize) {
if (x.size() < newSize) {
int diff = newSize - x.size();
for (int i = 0; i < diff; i++) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/thealgorithms/maths/FFT.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.thealgorithms.maths;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;

/**
Expand Down Expand Up @@ -274,7 +275,7 @@ private static int reverseBits(int num, int log2n) {
*
* @param x The ArrayList to be padded.
*/
private static void paddingPowerOfTwo(ArrayList<Complex> x) {
private static void paddingPowerOfTwo(Collection<Complex> x) {
int n = 1;
int oldSize = x.size();
while (n < oldSize) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/thealgorithms/maths/FFTBluestein.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.thealgorithms.maths;

import java.util.ArrayList;
import java.util.List;

/**
* Class for calculating the Fast Fourier Transform (FFT) of a discrete signal
Expand All @@ -25,7 +26,7 @@ private FFTBluestein() {
* IFFT of signal x.
* @param inverse True if you want to find the inverse FFT.
*/
public static void fftBluestein(ArrayList<FFT.Complex> x, boolean inverse) {
public static void fftBluestein(List<FFT.Complex> x, boolean inverse) {
int n = x.size();
int bnSize = 2 * n - 1;
int direction = inverse ? -1 : 1;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/thealgorithms/maths/Gaussian.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package com.thealgorithms.maths;

import java.util.ArrayList;
import java.util.List;

public final class Gaussian {
private Gaussian() {
}

public static ArrayList<Double> gaussian(int matSize, ArrayList<Double> matrix) {
public static ArrayList<Double> gaussian(int matSize, List<Double> matrix) {
int i;
int j = 0;

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/thealgorithms/maths/NthUglyNumber.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import org.apache.commons.lang3.tuple.MutablePair;

/**
Expand Down Expand Up @@ -64,7 +65,7 @@ private void updatePositions() {
}
}

private long computeCandidate(final MutablePair<Integer, Integer> entry) {
private long computeCandidate(final Map.Entry<Integer, Integer> entry) {
return entry.getKey() * uglyNumbers.get(entry.getValue());
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/thealgorithms/misc/MedianOfMatrix.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public final class MedianOfMatrix {
private MedianOfMatrix() {
}

public static int median(List<List<Integer>> matrix) {
public static int median(Iterable<List<Integer>> matrix) {
// Flatten the matrix into a 1D list
List<Integer> linear = new ArrayList<>();
for (List<Integer> row : matrix) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.thealgorithms.misc;

import com.thealgorithms.datastructures.lists.SinglyLinkedList;
import java.util.Stack;

/**
Expand All @@ -15,8 +14,8 @@ public final class PalindromeSinglyLinkedList {
private PalindromeSinglyLinkedList() {
}

public static boolean isPalindrome(final SinglyLinkedList linkedList) {
Stack<Integer> linkedListValues = new Stack<>();
public static boolean isPalindrome(final Iterable linkedList) {
var linkedListValues = new Stack<>();

for (final var x : linkedList) {
linkedListValues.push(x);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/thealgorithms/others/KochSnowflake.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.imageio.ImageIO;

/**
Expand Down Expand Up @@ -125,7 +126,7 @@ public static BufferedImage getKochSnowflake(int imageWidth, int steps) {
* applied.
* @return The transformed vectors after the iteration-step.
*/
private static ArrayList<Vector2> iterationStep(ArrayList<Vector2> vectors) {
private static ArrayList<Vector2> iterationStep(List<Vector2> vectors) {
ArrayList<Vector2> newVectors = new ArrayList<Vector2>();
for (int i = 0; i < vectors.size() - 1; i++) {
Vector2 startVector = vectors.get(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.thealgorithms.devutils.entities.ProcessDetails;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;
Expand All @@ -15,7 +16,7 @@ public class PreemptivePriorityScheduling {
protected final List<ProcessDetails> processes;
protected final List<String> ganttChart;

public PreemptivePriorityScheduling(List<ProcessDetails> processes) {
public PreemptivePriorityScheduling(Collection<ProcessDetails> processes) {
this.processes = new ArrayList<>(processes);
this.ganttChart = new ArrayList<>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.thealgorithms.devutils.entities.ProcessDetails;
import java.util.ArrayList;
import java.util.List;

/**
* Implementation of Shortest Job First Algorithm: The algorithm allows the waiting process with the
Expand Down Expand Up @@ -87,7 +88,7 @@ public void scheduleProcesses() {
* @return returns the process' with the shortest burst time OR NULL if there are no ready
* processes
*/
private ProcessDetails findShortestJob(ArrayList<ProcessDetails> readyProcesses) {
private ProcessDetails findShortestJob(List<ProcessDetails> readyProcesses) {
if (readyProcesses.isEmpty()) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.thealgorithms.scheduling.diskscheduling;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
Expand All @@ -24,7 +25,7 @@ public SSFScheduling(int currentPosition) {
this.currentPosition = currentPosition;
}

public List<Integer> execute(List<Integer> requests) {
public List<Integer> execute(Collection<Integer> requests) {
List<Integer> result = new ArrayList<>(requests);
List<Integer> orderedRequests = new ArrayList<>();

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/thealgorithms/sorts/BucketSort.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private <T extends Comparable<T>> void distributeElementsIntoBuckets(T[] array,
* @param <T> the type of elements in the array
* @return the sorted array
*/
private <T extends Comparable<T>> T[] concatenateBuckets(List<List<T>> buckets, T[] array) {
private <T extends Comparable<T>> T[] concatenateBuckets(Iterable<List<T>> buckets, T[] array) {
int index = 0;
for (List<T> bucket : buckets) {
Collections.sort(bucket);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/thealgorithms/sorts/PatienceSort.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private static <T extends Comparable<T>> List<List<T>> formPiles(final T[] array
* @param <T> the type of elements in the piles, must be comparable
* @return a priority queue containing the top element of each pile
*/
private static <T extends Comparable<T>> PriorityQueue<PileNode<T>> mergePiles(final List<List<T>> piles) {
private static <T extends Comparable<T>> PriorityQueue<PileNode<T>> mergePiles(final Iterable<List<T>> piles) {
PriorityQueue<PileNode<T>> pq = new PriorityQueue<>();
for (List<T> pile : piles) {
pq.add(new PileNode<>(pile.removeLast(), pile));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private static void populatePigeonHoles(int[] array, List<List<Integer>> pigeonH
* @param array the array to be sorted
* @param pigeonHoles the populated pigeonholes
*/
private static void collectFromPigeonHoles(int[] array, List<List<Integer>> pigeonHoles) {
private static void collectFromPigeonHoles(int[] array, Iterable<List<Integer>> pigeonHoles) {
int index = 0;
for (final var pigeonHole : pigeonHoles) {
for (final int element : pigeonHole) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/thealgorithms/sorts/TreeSort.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private <T extends Comparable<T>> T[] doTreeSortArray(T[] unsortedArray) {
return unsortedArray;
}

private <T extends Comparable<T>> List<T> doTreeSortList(List<T> unsortedList) {
private <T extends Comparable<T>> List<T> doTreeSortList(Iterable<T> unsortedList) {
// create a generic BST tree
BSTRecursiveGeneric<T> tree = new BSTRecursiveGeneric<T>();

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/thealgorithms/strings/WordLadder.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.thealgorithms.strings;

import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Set;

Expand All @@ -22,7 +22,7 @@ private WordLadder() {
* @param wordList a list of words that can be used in the transformation sequence
* @return the number of words in the shortest transformation sequence, or 0 if no such sequence exists
*/
public static int ladderLength(String beginWord, String endWord, List<String> wordList) {
public static int ladderLength(String beginWord, String endWord, Collection<String> wordList) {
Set<String> wordSet = new HashSet<>(wordList);

if (!wordSet.contains(endWord)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ void testEdgesRange() {
* @param result list of edges in the Minimum Spanning Tree
* @return the total weight of the Minimum Spanning Tree
*/
int computeTotalWeight(final List<BoruvkaAlgorithm.Edge> result) {
int computeTotalWeight(final Iterable<BoruvkaAlgorithm.Edge> result) {
int totalWeight = 0;
for (final var edge : result) {
totalWeight += edge.weight;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.junit.jupiter.api.Test;
Expand All @@ -25,7 +26,7 @@ public class EdmondsBlossomAlgorithmTest {
* @param matching List of matched pairs returned by the algorithm.
* @return A sorted 2D array of matching pairs.
*/
private int[][] convertMatchingToArray(List<int[]> matching) {
private int[][] convertMatchingToArray(Collection<int[]> matching) {
// Convert the list of pairs into an array
int[][] result = matching.toArray(new int[0][]);

Expand Down
3 changes: 2 additions & 1 deletion src/test/java/com/thealgorithms/misc/WordBoggleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.stream.Stream;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -44,7 +45,7 @@ private static Stream<Arguments> provideTestCases() {

@ParameterizedTest
@MethodSource("provideSpecialCases")
void testBoggleBoardSpecialCases(char[][] specialBoard, String[] words, List<String> expectedWords, String testDescription) {
void testBoggleBoardSpecialCases(char[][] specialBoard, String[] words, Collection<String> expectedWords, String testDescription) {
List<String> result = WordBoggle.boggleBoard(specialBoard, words);
assertEquals(expectedWords.size(), result.size(), "Test failed for: " + testDescription);
assertTrue(expectedWords.containsAll(result), "Test failed for: " + testDescription);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;

import com.thealgorithms.devutils.entities.ProcessDetails;
import java.util.Collection;
import java.util.List;
import java.util.stream.Stream;
import org.junit.jupiter.params.ParameterizedTest;
Expand All @@ -17,7 +18,7 @@
class PreemptivePrioritySchedulingTest {
@ParameterizedTest
@MethodSource("provideProcessesAndExpectedSchedules")
void testPreemptivePriorityScheduling(List<ProcessDetails> processes, List<String> expectedSchedule) {
void testPreemptivePriorityScheduling(Collection<ProcessDetails> processes, List<String> expectedSchedule) {
PreemptivePriorityScheduling scheduler = new PreemptivePriorityScheduling(processes);
scheduler.scheduleProcesses();
assertEquals(expectedSchedule, scheduler.ganttChart);
Expand Down
Loading