Skip to content

Indentation: wrapped method name #5655

@pbludov

Description

@pbludov

/var/tmp $ javac TestClass.java:

/var/tmp $ cat TestClass.java:

import java.util.Collections;
import java.util.function.Function;
import java.util.List;

class TestClass {

    public <U> void test(Function<?, ? extends U> f) {
    }

    public void test() {
        this
            .<Function<List<?>, Boolean>>test(
                x -> z -> z.contains(x));
        this.<Function<List<?>, Boolean>>
            test(
                x -> z -> z.contains(x)); // Line 16
        this.<Function<List<?>, Boolean>>
            test(x ->
                z -> z.contains(x));
        this.
            test(
                null);
        this
            .test(
                null);
    }

}

/var/tmp $ cat config.xml:

<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
        "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
        "http://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd">
<module name="Checker">
  <module name="TreeWalker">
    <module name="Indentation"/>
  </module>
</module>

/var/tmp $ java -Duser.language=en -Duser.country=US -jar checkstyle-8.8-all.jar -c config.xml TestClass.java:

Starting audit...
[ERROR] /var/tmp/TestClass.java:16: 'lambda arguments' has incorrect indentation level 16, expected level should be 12. [Indentation]
Audit done.
Checkstyle ends with 1 errors.

The problem is that the IndentationCheck wants

        this.<Function<List<?>, Boolean>>
            test(
            x -> z -> z.contains(x)); // Line 16

as it says:

incorrect indentation level 16, expected level should be 12

this is definitely a mistake. The indentation should be 16 as in other cases.
There should be no violation. The indentation on the line 16 should be 16, as in other cases.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions