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

AvoidNotShortCircuitOperatorsForBoolean reports multi catch case #559

Closed
george-007 opened this Issue Dec 28, 2016 · 4 comments

Comments

Projects
None yet
3 participants
@george-007

george-007 commented Dec 28, 2016

/var/tmp $ javac Test.java

/var/tmp $ cat Test.java

public class Test {
    public class InnerClass {
        public Runnable getRunnable() {
            return new Runnable() {
                @Override
                public void run() {
                }
                public boolean test() {
                    try {
                    } catch (IllegalArgumentException | NullPointerException e) {
                        return false;
                    }
                    return true;
                }
            };

        }
    }

}

/var/tmp $ cat config.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC
        "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
        "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">

<module name="Checker">
    <module name="TreeWalker">
        <module name="AvoidNotShortCircuitOperatorsForBoolean"/>
    </module>
</module>
/var/tmp $ # java -classpath sevntu-checks-1.23.0.jar:checkstyle-7.3-all.jar com.puppycrawl.tools.checkstyle.Main  -c config.xml Test.java
Starting audit...
[ERROR] /root/checkstyle/Test.java:10:55: Short-circuit operator should be used instead of '|'. [AvoidNotShortCircuitOperatorsForBoolean]
Audit done.
Checkstyle ends with 1 errors.

The following code should not be reported as a violation:

} catch (IllegalArgumentException | NullPointerException e) {
@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani May 12, 2017

Member

fix is merged

Member

romani commented May 12, 2017

fix is merged

@romani romani closed this May 12, 2017

@romani romani added this to the 1.24.0 milestone May 12, 2017

@toli

This comment has been minimized.

Show comment
Hide comment
@toli

toli Apr 10, 2018

This still seems to still fail for me on

      try {
       // do stuff....
        docker.startContainer(docker.createContainer(containerConfig).id());
      } catch (InterruptedException | DockerException ex) {
        logger.info("exception while trying to start docker contaner: {}", ex.getMessage());
        return;
      }

with version 1.29.0 or 1.26.0 - i get an error

[WARN] <path>File.java:598:37: Short-circuit operator should be used instead of '|'. [AvoidNotShortCircuitOperatorsForBoolean]

DockerExcepiton is deifined in https://github.com/spotify/docker-client library

toli commented Apr 10, 2018

This still seems to still fail for me on

      try {
       // do stuff....
        docker.startContainer(docker.createContainer(containerConfig).id());
      } catch (InterruptedException | DockerException ex) {
        logger.info("exception while trying to start docker contaner: {}", ex.getMessage());
        return;
      }

with version 1.29.0 or 1.26.0 - i get an error

[WARN] <path>File.java:598:37: Short-circuit operator should be used instead of '|'. [AvoidNotShortCircuitOperatorsForBoolean]

DockerExcepiton is deifined in https://github.com/spotify/docker-client library

@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani Apr 10, 2018

Member

@toli , please create new issue with all details required in issue template.

Member

romani commented Apr 10, 2018

@toli , please create new issue with all details required in issue template.

@toli

This comment has been minimized.

Show comment
Hide comment
@toli

toli commented Apr 11, 2018

filed #659

kariem added a commit to kariem/sevntu.checkstyle that referenced this issue Jul 26, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment