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:
Christopher O'Connell
2019-10-19 13:04:44 -04:00
committed by Ilkka Seppälä
parent 8a4844792f
commit 7c5d5f6b0d
12 changed files with 25 additions and 19 deletions

View File

@ -36,6 +36,7 @@ import java.util.Random;
public class Bubble extends Point<Bubble> {
private static final Logger LOGGER = LoggerFactory.getLogger(Bubble.class);
private static final Random RANDOM = new Random();
final int radius;
@ -45,10 +46,9 @@ public class Bubble extends Point<Bubble> {
}
void move() {
Random rand = new Random();
//moves by 1 unit in either direction
this.x += rand.nextInt(3) - 1;
this.y += rand.nextInt(3) - 1;
this.x += RANDOM.nextInt(3) - 1;
this.y += RANDOM.nextInt(3) - 1;
}
boolean touches(Bubble b) {