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
@ -40,6 +40,7 @@ import java.util.Random;
|
||||
public class SampleData {
|
||||
|
||||
private static final List<PlayerDetails> PLAYERS;
|
||||
private static final Random RANDOM = new Random();
|
||||
|
||||
static {
|
||||
PLAYERS = new ArrayList<>();
|
||||
@ -83,10 +84,9 @@ public class SampleData {
|
||||
PLAYERS.add(new PlayerDetails("xavier@google.com", "143-947", "+375245"));
|
||||
PLAYERS.add(new PlayerDetails("harriet@google.com", "842-404", "+131243252"));
|
||||
InMemoryBank wireTransfers = new InMemoryBank();
|
||||
Random random = new Random();
|
||||
for (PlayerDetails player : PLAYERS) {
|
||||
wireTransfers.setFunds(player.getBankAccount(),
|
||||
random.nextInt(LotteryConstants.PLAYER_MAX_BALANCE));
|
||||
RANDOM.nextInt(LotteryConstants.PLAYER_MAX_BALANCE));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user