Skip to content

UnnecessaryParentheses: false negative on unnecessary parenthesis #11643

@rnveach

Description

@rnveach

https://checkstyle.org/config_coding.html#UnnecessaryParentheses

$ cat TestClass.java
public class TestClass {
    public static boolean is(Class<?> clazz) {
        return true
            && (test(clazz)); // no violation
    }

    public static boolean test(Class<?> clazz) {
        return true;
    }
}

$ cat TestConfig.xml
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
          "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
          "https://checkstyle.org/dtds/configuration_1_3.dtd">

<module name="Checker">
    <property name="charset" value="UTF-8"/>

    <module name="TreeWalker">
<module name="UnnecessaryParentheses"/>
    </module>
</module>

$ java -jar checkstyle-10.2-all.jar -c TestConfig.xml TestClass.java
Starting audit...
Audit done.

Expected a violation on line 4.

PMD reported the violation.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions