spotbugs / spotbugs

SpotBugs is FindBugs' successor. A tool for static analysis to look for bugs in Java code.

Home Page:https://spotbugs.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A false negative about the rule NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE

LynnBroe opened this issue · comments

Version: 4.7.3

I found a false negative about the rule NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE. In the example below, SpotBugs should have reported a warning at line 6 because the value of foo is from a method annotated with Nullable. Besides, this annotation is from SpotBugs. Hence, I think this is a false negative.

import edu.umd.cs.findbugs.annotations.Nullable;

public class C {
   public static int h() {
       final C foo = C.something();
       return foo.hashCode();  // should report a warning at this line
   }

   @Nullable
   private static C something() {
       return null;
   }
}

Thanks for opening your first issue here! 😃
Please check our contributing guideline. Especially when you report a problem, make sure you share a Minimal, Complete, and Verifiable example to reproduce it in this issue.