google / google-java-format

Reformats Java source code to comply with Google Java Style.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Formatting results don't fit the google style guide

zxeoc opened this issue · comments

commented

I'm using intellij plugin for formatting code and using checkstyle plugin with google style guide to check code style. But usually, they give different results.

For example, the code formatted by google-java-format plugin is:

    list.addAll(performanceTestCases.stream().map(
            c -> closure1.toItemList(env, pid, key, c.getDataSetCollections(),
                c.getBusinessModule(), c.getCaseId()))
        .flatMap(Collection::stream)
        .collect(Collectors.toList()));

But checkstyle with google style guide reports "'lambda arguments' has incorrect indentation level 12, expected level should be one of the following: 6, 8. (98:0) [Indentation]".

I don't think you have the plugin enabled, google-java-format would do something like:

    list.addAll(
        performanceTestCases.stream()
            .map(
                c ->
                    closure1.toItemList(
                        env,
                        pid,
                        key,
                        c.getDataSetCollections(),
                        c.getBusinessModule(),
                        c.getCaseId()))
            .flatMap(Collection::stream)
            .collect(Collectors.toList()));
commented

Sorry, my mistake. You are right, the plugin is not enabled. Enabling it solved the problem.