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

ReturnCount: unclear message when only max property is specified #5306

Closed
romani opened this Issue Nov 30, 2017 · 3 comments

Comments

Projects
None yet
2 participants
@romani
Member

romani commented Nov 30, 2017

/var/tmp$ javac Test.java 

/var/tmp$ cat config.xml 
<?xml version="1.0"?>
 <!DOCTYPE module PUBLIC
   "-//Puppy Crawl//DTD Check Configuration 1.2//EN"
   "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
<module name="Checker">
    <module name="TreeWalker">
        <module name="ReturnCount">
          <property name="max" value="0"/>
        </module>
    </module>
</module>

/var/tmp$ cat Test.java 
public final class Test {

  public void foo1() {
        if (true) {
            return;
        } else {
            return;
        }
  }
  public boolean foo2() {
        if (true) {
            return true;
        } else {
            return false;
        }
  }

}

/var/tmp$ java -jar checkstyle-8.4-all.jar -c config.xml Test.java 
Starting audit...
[ERROR] /var/tmp/Test.java:3:3: Return count is 2 (max allowed is 1). [ReturnCount]
[ERROR] /var/tmp/Test.java:10:3: Return count is 2 (max allowed is 0). [ReturnCount]
Audit done.
Checkstyle ends with 2 errors.

Not clear why user defined "1" but in output there is also "0" ((max allowed is 1) vs max allowed is 0).

All violations are expected but, wording of message should be changed to be

[ERROR] /var/tmp/Test.java:3:3: Return count is 2 (max allowed is 1). [ReturnCount]
[ERROR] /var/tmp/Test.java:10:3: Return count is 2 (max allowed for void methods is 0). [ReturnCount]

Attention: such change should be applied to all languages.

FYI: originally detected at #5305 5305

@rnveach

This comment has been minimized.

Show comment
Hide comment
@rnveach

rnveach Nov 30, 2017

Member

Return count is 2 (max allowed is 1). [ReturnCount]

Should this say max allowed for non-void methods is 1?

Member

rnveach commented Nov 30, 2017

Return count is 2 (max allowed is 1). [ReturnCount]

Should this say max allowed for non-void methods is 1?

@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani Nov 30, 2017

Member

Make sense

Member

romani commented Nov 30, 2017

Make sense

vaano94 added a commit to epam/checkstyle that referenced this issue Dec 20, 2017

vaano94 added a commit to epam/checkstyle that referenced this issue Dec 20, 2017

vaano94 added a commit to epam/checkstyle that referenced this issue Dec 20, 2017

vaano94 added a commit to epam/checkstyle that referenced this issue Dec 21, 2017

vaano94 added a commit to epam/checkstyle that referenced this issue Dec 21, 2017

vaano94 added a commit to epam/checkstyle that referenced this issue Dec 21, 2017

romani added a commit that referenced this issue Dec 22, 2017

@romani romani added the bug label Dec 22, 2017

@romani romani added this to the 8.6 milestone Dec 22, 2017

@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani Dec 22, 2017

Member

Fix is merged

Member

romani commented Dec 22, 2017

Fix is merged

@romani romani closed this Dec 22, 2017

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