Skip to content

Commit 82f9a6c

Browse files
oconnelciluwatar
authored andcommitted
1010: Fixed the two remaining SonarCloud errors (iluwatar#1023)
The two remaining files were still creating a Random everytime the method was called. These were missed in the previous commit because the previous commit had fixed only one of the methods; in other words, there were multiple methods that were creating the Random object on each call.
1 parent f671f03 commit 82f9a6c

File tree

2 files changed

+2
-4
lines changed
  • hexagonal/src/main/java/com/iluwatar/hexagonal/sampledata
  • typeobjectpattern/src/main/java/com/iluwatar/typeobject

2 files changed

+2
-4
lines changed

hexagonal/src/main/java/com/iluwatar/hexagonal/sampledata/SampleData.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ public static void submitTickets(LotteryService lotteryService, int numTickets)
102102
}
103103

104104
private static PlayerDetails getRandomPlayerDetails() {
105-
Random random = new Random();
106-
int idx = random.nextInt(PLAYERS.size());
105+
int idx = RANDOM.nextInt(PLAYERS.size());
107106
return PLAYERS.get(idx);
108107
}
109108
}

typeobjectpattern/src/main/java/com/iluwatar/typeobject/CellPool.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ Cell getNewCell() {
7171
}
7272

7373
void addNewCell(Cell c) {
74-
Random rand = new Random();
75-
c.candy = randomCode[rand.nextInt(randomCode.length)]; //changing candytype to new
74+
c.candy = randomCode[RANDOM.nextInt(randomCode.length)]; //changing candytype to new
7675
this.pool.add(c);
7776
pointer++;
7877
}

0 commit comments

Comments
 (0)