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
@ -37,6 +37,7 @@ import com.iluwatar.typeobject.Candy.Type;
|
||||
*/
|
||||
|
||||
public class CellPool {
|
||||
private static final Random RANDOM = new Random();
|
||||
ArrayList<Cell> pool;
|
||||
int pointer;
|
||||
Candy[] randomCode;
|
||||
@ -57,8 +58,7 @@ public class CellPool {
|
||||
}
|
||||
for (int i = 0; i < num; i++) {
|
||||
Cell c = new Cell();
|
||||
Random rand = new Random();
|
||||
c.candy = randomCode[rand.nextInt(randomCode.length)];
|
||||
c.candy = randomCode[RANDOM.nextInt(randomCode.length)];
|
||||
this.pool.add(c);
|
||||
}
|
||||
this.pointer = num - 1;
|
||||
|
Reference in New Issue
Block a user