Skip to content

RightCurly with option alone false negative for class, method and constructor #6345

Closed
@robertpainsi

Description

@robertpainsi
/var/tmp $ javac MyClass.java

/var/tmp $ cat config.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="RightCurly">
            <property name="option" value="alone"/>
            <property name="tokens" value="CLASS_DEF, METHOD_DEF, CTOR_DEF"/>
        </module>
    </module>
</module>

/var/tmp $ cat MyClass.java
public final class MyClass {
    public MyClass() {} // Doesn't warn - incorrect
    
    public void main() {} // Doesn't warn - incorrect
    
    class Foo {} // Doesn't warn - incorrect
}

/var/tmp $ RUN_LOCALE="-Duser.language=en -Duser.country=US"
/var/tmp $ java $RUN_LOCALE -jar checkstyle-8.16-all.jar -c config.xml MyClass.java
Starting audit...
Audit done.

In all three cases (constructor, method, class), the right curly brace is on the same line as the left curly brace. However, the option alone should force the right curly brace to be on it's own line,

Correct:

public final class MyClass {
    public MyClass() {
    }
    
    public void main() {
    }
    
    class Foo {
    }
}

https://groups.google.com/forum/#!topic/checkstyle/q_kVS42ITt0

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions