google / google/google-java-format

Block-like array initializers are not preserved

Aperta
#572 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Java
Stelle
6.2k
Fork
937
Merge medio
6m
PR unite (30g)
3

Descrizione

The [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html#s4.8.3-arrays) specifies that arrays may be formatted in a block-like fashion, however google-java-format clobbers this to one line per element.

For example, the following:

```
protected static final byte[] TEST_ARRAY =
new byte[] {
(byte) 0x31, (byte) 0x32, (byte) 0x33, (byte) 0x34, (byte) 0x35, (byte) 0x36, (byte) 0xFF, (byte) 0xFF
};
```
becomes
```
protected static final byte[] TEST_ARRAY =
new byte[] {
(byte) 0x31,
(byte) 0x32,
(byte) 0x33,
(byte) 0x34,
(byte) 0x35,
(byte) 0x36,
(byte) 0xFF,
(byte) 0xFF
};
```

For larger formatted constant definitions, formatting is essential to preserving understanding of the structure. It seems like preserving formatting should either be default behaviour, or an option.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.