RightCurlyCheck: add support for lambda #3546

Closed
rnveach opened this Issue Nov 11, 2016 · 3 comments

Comments

Projects
None yet
3 participants
@rnveach
Member

rnveach commented Nov 11, 2016

Attention!!!! this issue affect Google style 4.1.2 point, it should be reviewed after the fix.

In scope of this issue only part of problem be fixed, please read final comments.

$ cat TestClass.java
public class TestClass {
    void method() {
if (true) { int a = 0; } int a = 0;
Runnable noop = () -> { int a = 0; }; int b = 0;
    }
}

$ 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="LeftCurly">
            <property name="maxLineLength" value="100"/>
        </module>
        <module name="RightCurly">
            <property name="option" value="alone"/>
        </module>
    </module>
</module>

$ java -jar checkstyle-7.2-all.jar -c TestConfig.xml TestClass.java
Starting audit...
[ERROR] TestClass.java:3:11: '{' at column 11 should have line break after. [LeftCurly]
[ERROR] TestClass.java:3:24: '}' at column 24 should be alone on a line. [RightCurly]
[ERROR] TestClass.java:4:23: '{' at column 23 should have line break after. [LeftCurly]
Audit done.
Checkstyle ends with 3 errors.

I expecting a violation at 4:36 for the } (right curly) just like there is one for the if statement at 3:24.
LeftCurly behaves as expected as it gives similar violations.
RightClurly doesn't accept the lambda token, so it is not possible to specify it.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani Dec 9, 2016

Member

@MaksimP , please help to resolve this issue.

Member

romani commented Dec 9, 2016

@MaksimP , please help to resolve this issue.

MaksimP added a commit to MaksimP/checkstyle that referenced this issue Dec 30, 2016

MaksimP added a commit to MaksimP/checkstyle that referenced this issue Jan 9, 2017

MaksimP added a commit to MaksimP/checkstyle that referenced this issue Jan 9, 2017

MaksimP added a commit to MaksimP/checkstyle that referenced this issue Jan 9, 2017

MaksimP added a commit to MaksimP/checkstyle that referenced this issue Jan 9, 2017

MaksimP added a commit to MaksimP/checkstyle that referenced this issue Jan 9, 2017

MaksimP added a commit to MaksimP/checkstyle that referenced this issue Jan 9, 2017

MaksimP added a commit to MaksimP/checkstyle that referenced this issue Jan 9, 2017

MaksimP added a commit to MaksimP/checkstyle that referenced this issue Jan 12, 2017

MaksimP added a commit to MaksimP/checkstyle that referenced this issue Jan 12, 2017

MaksimP added a commit to MaksimP/checkstyle that referenced this issue Jan 18, 2017

MaksimP added a commit to MaksimP/checkstyle that referenced this issue Jan 18, 2017

MaksimP added a commit to MaksimP/checkstyle that referenced this issue Jan 21, 2017

MaksimP added a commit to MaksimP/checkstyle that referenced this issue Jan 21, 2017

MaksimP added a commit to MaksimP/checkstyle that referenced this issue Jan 21, 2017

MaksimP added a commit to MaksimP/checkstyle that referenced this issue Jan 22, 2017

MaksimP added a commit to MaksimP/checkstyle that referenced this issue Jan 22, 2017

MaksimP added a commit to MaksimP/checkstyle that referenced this issue Jan 22, 2017

MaksimP added a commit to MaksimP/checkstyle that referenced this issue Jan 24, 2017

MaksimP added a commit to MaksimP/checkstyle that referenced this issue Jan 26, 2017

MaksimP added a commit to MaksimP/checkstyle that referenced this issue Jan 28, 2017

MaksimP added a commit to MaksimP/checkstyle that referenced this issue Jan 28, 2017

romani added a commit that referenced this issue Jan 28, 2017

romani added a commit that referenced this issue Jan 28, 2017

romani added a commit that referenced this issue Feb 18, 2017

@rnveach rnveach added the medium label Mar 2, 2017

@Vladlis

This comment has been minimized.

Show comment
Hide comment
@Vladlis

Vladlis Mar 4, 2017

Member

I'm on it

Member

Vladlis commented Mar 4, 2017

I'm on it

Vladlis added a commit to Vladlis/checkstyle that referenced this issue Mar 9, 2017

Vladlis added a commit to Vladlis/checkstyle that referenced this issue Mar 9, 2017

Vladlis added a commit to Vladlis/checkstyle that referenced this issue Apr 6, 2017

Vladlis added a commit to Vladlis/checkstyle that referenced this issue Apr 6, 2017

Vladlis added a commit to Vladlis/checkstyle that referenced this issue Apr 6, 2017

Vladlis added a commit to Vladlis/checkstyle that referenced this issue Apr 6, 2017

Vladlis added a commit to Vladlis/checkstyle that referenced this issue Apr 6, 2017

Vladlis added a commit to Vladlis/checkstyle that referenced this issue Apr 9, 2017

@Vladlis Vladlis referenced this issue in google/styleguide Apr 11, 2017

Open

Document lambda formatting for Java 8 #112

Vladlis added a commit to Vladlis/checkstyle that referenced this issue Apr 13, 2017

Issue #3546: Update commentFormat in SuppressWithNearbyCommentFilter …
…to allow suppression of more then one Check

Vladlis added a commit to Vladlis/checkstyle that referenced this issue Apr 13, 2017

Vladlis added a commit to Vladlis/checkstyle that referenced this issue Apr 16, 2017

Issue #3546: Update commentFormat in SuppressWithNearbyCommentFilter …
…to allow suppression of more then one Check

Vladlis added a commit to Vladlis/checkstyle that referenced this issue Apr 16, 2017

romani added a commit that referenced this issue Apr 17, 2017

romani added a commit that referenced this issue Apr 17, 2017

@romani romani added this to the 7.7 milestone Apr 17, 2017

@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani Apr 17, 2017

Member

fix is merged, but it is only first part of fix.

Attention!!! User should NOT use this new token as it will produce number of false-positives.
This token will become use-able only after #4177 #4178 when we create new mode for RightCurlyCheck to properly process anonymous classes and lambdas.

Member

romani commented Apr 17, 2017

fix is merged, but it is only first part of fix.

Attention!!! User should NOT use this new token as it will produce number of false-positives.
This token will become use-able only after #4177 #4178 when we create new mode for RightCurlyCheck to properly process anonymous classes and lambdas.

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