google / google/google-java-format

Records with annotations on components are formatted pretty badly

Open
#921 3 comments 14 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
6.2k
Forks
937
Avg merge
6m
Merged PRs (30d)
3

Description

Example output by `google-java-format` on a record:

```java
public record MyRecord(
@NotNull String firstName,
String lastName,
@NotEmpty List friends,
@MyAnnotation(
propA = "The brown fox jumps over the lazy cat......",
propB = 11,
type = java.lang.Object.class)
@HelloWorld
String hello,
String world,
@Positive int numberA,
@MyAnnotation(propA = "The brown fox jumps over the lazy cat", type = java.lang.Object.class)
@HelloWorld
String hello) {}
```

Compare to if it was a class:

```java
public class MyClass {

@NotNull String firstName;

String lastName;

@NotEmpty List friends;

@MyAnnotation(
propA = "The brown fox jumps over the lazy cat......",
propB = 11,
type = Object.class)
@HelloWorld
String hello;

String world;

@Positive int numberA;

@MyAnnotation(propA = "The brown fox jumps over the lazy cat", type = Object.class)
@HelloWorld
String hello;
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.