facebook / infer

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

Suppressing false positives in non-android Java project #1693

Open cicirello opened 1 year ago

cicirello commented 1 year ago

Summary of the Problem

Currently, in an android project, it is possible to use @SuppressLint to suppress false positives. This annotation is only available in android Java projects, but not Java more generally. Perusing infer's changelog, it appears that there once was support for using @SuppressWarnings("infer"), introduced in version 0.8.0. However, that support was removed in version 0.10.0.

Here is an excerpt from the changelog for version 0.10.0: "[Java] @SuppressWarnings support removed. Use @SuppressLint instead. android.annotation.SuppressLint is only available on Android, but do let us know if that is an issue for you."

Unless it is an Android project, there doesn't appear to currently be any way to suppress false positives for Java at the level of a method or a class, other than to disable in the configuration for an entire file. Disabling for an entire file is undesirable since actual bugs may be introduced after disabling infer to deal with cases that have been determined by careful inspection to be false positives.

Desired Solution

It doesn't need to be a reintroduction of @SuppressWarnings, since I'm assuming there was likely a technical reason for eliminating support for it in version 0.10.0. However, it would be nice if it was possible to suppress false positives at the level of a method in a Java project (that isn't limited to android projects).

Background Information

Please make sure your issue is not addressed in the FAQ.

Please include the following information: