facebook / infer

A static analyzer for Java, C, C++, and Objective-C
http://fbinfer.com/
MIT License
14.83k stars 2k forks source link

INTERFACE_NOT_THREAD_SAFE should not apply to dependencies #1733

Open dsmiley opened 1 year ago

dsmiley commented 1 year ago

I have a Java class annotated with @ThreadSafe and it uses the pervasive SLF4j Logger for logging. Infer/RacerD complains that Logger should be declared ThreadSafe -- INTERFACE_NOT_THREAD_SAFE :-)
Obviously it's not within my power to do that; it's in a dependency of my project.

ngorogiannis commented 1 year ago

You may find the --external-java-packages option useful, it should suppress reports in external packages.

dsmiley commented 1 year ago

I tried to use external-java-packages vis-a-vis Sonatype Lift (whom I am also in contact with for support). But the results (of Lift invoking Infer) show that ThreadSafe annotated classes which use SLF4J (despite me trying to tell RacerD to ignore SLF4J) are still reporting the problem. Does anything jump out at you as a problem? Well never mind; I think configuring package-by-package is a losing strategy anyway. Realistically I'm going to have to just configure Lift to ignore all INTERFACE_NOT_THREADSAFE. I find RacerD's default mode here with respect to this issue type very surprising; it seems to not recognize what an "external" package is by itself (which it should be able to do based source file availability of course). A TODO for a better RacerD.

ngorogiannis commented 1 year ago

If you can produce a minimal repro I'd be happy to look into it.

SolomonSun2010 commented 1 year ago

Good.