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

AvoidNotShortCircuitOperatorsForBoolean reports multi catch case #559

Closed
jiri-pejchal opened this issue Dec 28, 2016 · 4 comments
Closed

AvoidNotShortCircuitOperatorsForBoolean reports multi catch case #559

jiri-pejchal opened this issue Dec 28, 2016 · 4 comments
Labels
Milestone

Comments

@jiri-pejchal
Copy link

@jiri-pejchal jiri-pejchal 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) {
rnveach added a commit to rnveach/sevntu.checkstyle that referenced this issue May 11, 2017
@romani romani added the approved label May 12, 2017
romani added a commit that referenced this issue May 12, 2017
@romani
Copy link
Member

@romani 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
Copy link

@toli 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
Copy link
Member

@romani romani commented Apr 10, 2018

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

@toli
Copy link

@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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants