Skip to content

False positive: UnusedVariable for methods that unconditionally throw #1948

@electrum

Description

@electrum

Description of the problem / feature request:

UnusedVariable triggers for a method like this:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions