Skip to content

Inconistent spacing with type annotations, varargs, and arrays #282

Closed
@mernst

Description

@mernst

Consider the following code, which has been formatted with google-java-format version 1.5:

public class ArrayVsVarargs {

  void anArrayParam1(String[] arg) {}

  void varargsParam1(String... arg) {}

  void anArrayParam2(String @Nullable [] arg) {}

  void varargsParam2(String @Nullable... arg) {}
}

In the first two methods, when there are no type annotations, google-java-format is consistent about putting no space between the element type and the array indicator [] or ....

When there is a type annotation, google-java-format is inconsistent about the following space: it puts space before [] but no space bofore ....

I think that google-java-format should be consistent, and should always put spaces on both sides of a type annotation.
This is how it worked in version 1.3, so it would be nice to revert to that behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions