infer icon indicating copy to clipboard operation
infer copied to clipboard

Suppressing false positives in non-android Java project

Open cicirello opened this issue 1 year ago • 0 comments

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

  • Version of infer: I'm using Sonatype Lift to run infer, rather than running directly, so not entirely sure of the specific infer version.
  • OS and version: As above, running indirectly as part of Sonatype Lift. From the logs, it appears to likely be some Linux distribution, but not clear which distribution or version.
  • Command: The Sonatype Lift logs indicates: Called: ['infer', 'analyze', '-r', '--no-parameter-not-null-checked', '--keep-going', '--pulse', '--quandary']

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

Please include the following information:

  • [x] The version of infer from infer --version.
  • [x] Your operating system and version, for example "Debian 9", "MacOS High Sierra", whether you are using Docker, etc.
  • [x] Which command you ran, for example infer -- make.
  • [ ] The full output in a paste, for instance a gist.
  • [ ] If possible, a minimal example to reproduce your problem (for instance, some code where infer reports incorrectly, together with the way you run infer to reproduce the incorrect report).

cicirello avatar Oct 20 '22 14:10 cicirello