google / google/error-prone

False positive: UnusedVariable for methods that unconditionally throw

Open
#1,948 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
7.2k
Forks
820
Avg merge
5h 9m
Merged PRs (30d)
50

Description

### Description of the problem / feature request:

*UnusedVariable* triggers for a method like this:

```java
private static boolean compare(int left, int right)
{
throw new AssertionError("this method should not be called");
}
```

We can rename the parameters to `unusedLeft` and `unusedRight`, which is often a good way to signal intent to readers of the code, but that is redundant in this case, since it's immediately obvious that this method will not use the parameters.

### What version of Error Prone are you using?

2.4.0

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.