Skip to content

Commit 7c38e5a

Browse files
authored
style: include DM_NEXTINT_VIA_NEXTDOUBLE (#7282)
1 parent 29ce2ef commit 7c38e5a

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

spotbugs-exclude.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
<Match>
1212
<Bug pattern="RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT" />
1313
</Match>
14-
<Match>
15-
<Bug pattern="DM_NEXTINT_VIA_NEXTDOUBLE" />
16-
</Match>
1714
<Match>
1815
<Bug pattern="EI_EXPOSE_REP" />
1916
</Match>

src/test/java/com/thealgorithms/searches/LinearSearchThreadTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import static org.junit.jupiter.api.Assertions.assertFalse;
44
import static org.junit.jupiter.api.Assertions.assertTrue;
55

6+
import java.util.Random;
67
import org.junit.jupiter.api.Test;
78

89
class LinearSearchThreadTest {
@@ -62,10 +63,11 @@ void testSearcherEmptySegment() throws InterruptedException {
6263
void testSearcherRandomNumbers() throws InterruptedException {
6364
int size = 200;
6465
int[] array = new int[size];
66+
Random random = new Random();
6567
for (int i = 0; i < size; i++) {
66-
array[i] = (int) (Math.random() * 100);
68+
array[i] = random.nextInt(100);
6769
}
68-
int target = array[(int) (Math.random() * size)]; // Randomly select a target that is present
70+
final int target = array[random.nextInt(size)]; // Randomly select a target that is present
6971
Searcher searcher = new Searcher(array, 0, size, target);
7072
searcher.start();
7173
searcher.join();

0 commit comments

Comments
 (0)