Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnnecessaryParentheses: no violation on parenthesis in if statement between || and && #5779

Closed
rnveach opened this issue May 6, 2018 · 2 comments · Fixed by #9334
Closed

Comments

@rnveach
Copy link
Member

rnveach commented May 6, 2018

Identified at #5778 (comment) ,

$ cat TestClass.java
public class TestClass {
    void method(String sectionName) {
        if ("Content".equals(sectionName) || "Overview".equals(sectionName)
                // suppression list
                || (!"AbbreviationAsWordInName".equals(sectionName)
                        && !"AbstractClassName".equals(sectionName)
                        )) {
             continue;
         }
    }
}

$ cat TestConfig.xml
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
          "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
          "http://www.puppycrawl.com/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-8.10-all.jar -c TestConfig.xml TestClass.java
Starting audit...
Audit done.

Every other CI complains about parenthesis at line 5 except our check. There should be a violation there.

@romani romani added the approved label May 8, 2018
yaziza added a commit to yaziza/checkstyle that referenced this issue Apr 11, 2020
…rentheses

Signed-off-by: Yasser Aziza <yasser.aziza@gmail.com>
yaziza added a commit to yaziza/checkstyle that referenced this issue Apr 13, 2020
@Vyom-Yadav
Copy link
Member

I am on it

@romani
Copy link
Member

romani commented Apr 1, 2021

merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants