Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False negatives on RV_01_TO_INT #1518

Closed
gloNelson opened this issue Apr 19, 2021 · 3 comments
Closed

False negatives on RV_01_TO_INT #1518

gloNelson opened this issue Apr 19, 2021 · 3 comments

Comments

@gloNelson
Copy link
Contributor

Hi,
I found false negatives on RV_01_TO_INT when reading the source code of SpotBugs in line 1171 of DumbMethods.java

It seems that SpotBugs only checks for several APIs that generate a random value (Math.random() and nextDouble()) but omits the nextFloat() API that can be used for the same purpose.

However, I think that based on its bug description that "nextFloat()" is not mentioned as an exception, the pattern RV_01_TO_INT should provide more support to the method nextFloat().

Here is the demo,

void test(){
    Random random = new Random();
    float f = random.nextFloat() * num; // no warning (false negative)
}
@dejan2609
Copy link

@gloNelson what is your Spotbugs version ?

@gloNelson
Copy link
Contributor Author

@dejan2609 Hi, it is the latest version of Spotbugs. Thank you for your reply.

@gtoison
Copy link
Contributor

gtoison commented Jan 18, 2024

This was fixed by #1851

@gtoison gtoison closed this as completed Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants