Skip to content

[java] UselessParentheses false positive with conditional operator #1673

@Vampire

Description

@Vampire

Affects PMD Version: 6.11.0
Rule: UselessParentheses

Code Sample demonstrating the issue:

throw new IllegalArgumentException(String.format(
        "Unsupported client with class '%s' given",
        (discordClient == null) ? null : discordClient.getClass()));

Additionally, should we add properties to allow whitelisting some scenarios, such as this one?

while ((result instanceof CompletionException) && (cause != null)) {
    result = cause;
    cause = result.getCause();
}

Running PMD through: Gradle

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:false-positivePMD flags a piece of code that is not problematic

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions