facebook / facebook/infer

Suppressing false positives in non-android Java project

Open
#1,693 0 comments 1 reaction 0 assignees View on GitHub
false-positive java
Dominant language
OCaml
Stars
15.7k
Forks
2.1k
Avg merge
19h 36m
Merged PRs (30d)
13

Description

## 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](https://fbinfer.com/docs/support#troubleshooting).

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](https://gist.github.com/).
- [ ] 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).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.