style: include DM_NEXTINT_VIA_NEXTDOUBLE (#7282)

This commit is contained in:
Piotr Idzik
2026-02-20 20:48:12 +01:00
committed by GitHub
parent 29ce2ef666
commit 7c38e5acd2
2 changed files with 4 additions and 5 deletions

View File

@@ -11,9 +11,6 @@
<Match>
<Bug pattern="RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT" />
</Match>
<Match>
<Bug pattern="DM_NEXTINT_VIA_NEXTDOUBLE" />
</Match>
<Match>
<Bug pattern="EI_EXPOSE_REP" />
</Match>

View File

@@ -3,6 +3,7 @@ package com.thealgorithms.searches;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Random;
import org.junit.jupiter.api.Test;
class LinearSearchThreadTest {
@@ -62,10 +63,11 @@ class LinearSearchThreadTest {
void testSearcherRandomNumbers() throws InterruptedException {
int size = 200;
int[] array = new int[size];
Random random = new Random();
for (int i = 0; i < size; i++) {
array[i] = (int) (Math.random() * 100);
array[i] = random.nextInt(100);
}
int target = array[(int) (Math.random() * size)]; // Randomly select a target that is present
final int target = array[random.nextInt(size)]; // Randomly select a target that is present
Searcher searcher = new Searcher(array, 0, size, target);
searcher.start();
searcher.join();