jhipster / jhipster/prettier-java

Linebreaks in generics

Open
#526 13 comments 1 reaction 0 assignees View on GitHub
Dominant language
Java
Stars
1.2k
Forks
120
Avg merge
1d 14h
Merged PRs (30d)
27

Description

In testing an upgrade to 1.6.1, we're sometimes seeing line breaks introduced into generics. Seems like this is probably a result of #512. I can see this being useful in pathological cases with extremely long generic type lists, but the issue is that we run prettier with a pretty aggressive line length limit, so we end up seeing split generics even in relatively straight-forward code samples. And it's pretty jarring when you first see it, because as far as I know, splitting generics like this isn't an idiomatic way to format Java (at least I haven't seen it in the wild before).

I tested the prettier-java upgrade on ~1,500 of our internal GitHub repos, and it definitely seemed like, in most cases, this generic splitting was hurting the code readability more than it helped. But curious to get your thoughts on how attached you are to this feature.

**Prettier-Java 1.6.1**

```sh
# Options (if any):
```

**Input:**

```java
public abstract class GenericWblGeneratorWithLongName {

public static PagedResult appendCustomOffsets(
Arg arg1,
Arg arg2
) {
// implementation
}
}
```

**Output:**

```java
public abstract class GenericWblGeneratorWithLongName<
OBJECT_TYPE, RECORD_TYPE
> {

public static <
RECORD, OFFSET
> PagedResult appendCustomOffsets(Arg arg1, Arg arg2) {
// implementation
}
}
```

**Expected behavior:**

```java
public abstract class GenericWblGeneratorWithLongName {

public static PagedResult appendCustomOffsets(
Arg arg1,
Arg arg2
) {
// implementation
}
}
```

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.