1010: Fixed all of the blocking and critical Sonarcloud errors (#1020)
* 1011: Added SuppressWarnings for SonarCloud errors All of these files are causing SonarCloud to report the following error: Loops should not be infinite Since these instances all require an infinite loop that will never end, these warnings should be disabled so that SonarCloud no longer reports them as error. The rule is: squid:S2189 * 1011: Made all of the randoms static and final According to SonarCloud rule: "Random" objects should be reused, randoms should not be recreated. This commit has taken all of the Randoms and made them constant variables in the files that are using them.
This commit is contained in:
committed by
Ilkka Seppälä
parent
8a4844792f
commit
7c5d5f6b0d
@ -34,6 +34,8 @@ import java.util.Random;
|
||||
public class ArrayUtilityMethods {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ArrayUtilityMethods.class);
|
||||
|
||||
private static final Random RANDOM = new Random();
|
||||
/**
|
||||
* Method arraysSame compares 2 arrays @param a1 and @param a2
|
||||
* and @return whether their values are equal (boolean).
|
||||
@ -86,11 +88,10 @@ public class ArrayUtilityMethods {
|
||||
|
||||
public static int[][] createRandomIntMatrix(int rows, int columns) {
|
||||
int[][] matrix = new int[rows][columns];
|
||||
Random rand = new Random();
|
||||
for (int i = 0; i < rows; i++) {
|
||||
for (int j = 0; j < columns; j++) {
|
||||
//filling cells in matrix
|
||||
matrix[i][j] = rand.nextInt(10);
|
||||
matrix[i][j] = RANDOM.nextInt(10);
|
||||
}
|
||||
}
|
||||
return matrix;
|
||||
|
Reference in New Issue
Block a user