diffplug / diffplug/spotless

Groovy formatting is very limited - possible idea

Aperta
#2,513 6 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Java
Stelle
5.6k
Fork
559
Merge medio
1g 14h
PR unite (30g)
43

Descrizione

The current Groovy formatting using the Eclipse formatter is very limited. It can't even format `apply({println it })` into something stringent. Let alone Spock tests written in Groovy.

The ways to format Groovy code are very limited. There is a npm-groovy-lint. That works better as the Eclipse formatter but has it own flaws (multi-line strings, ...). And fails on Spock tests, too.

My idea would be to use the IntelliJ formatter of the freely available community edition.

Here's the catch.
That's a command line tool that has the necessary two working options.
`dry-run` - just like `spotless:check` - checks a file or the files in a folder if they conform the expected formatting. If not, the files are reported.
`format` - just like `spotless:apply` - formats a file or the files in a folder.

After reading the contribution guideline I think this IntelliJ approach fits hardly into the Spotless Formatter approach, where one single file is given into the method and the formatted result is returned.

Of course it's possible to write the file content into a temporary file, call IntelliJ format on that temporary file, read the file again and return it's result.
I believe that's very cumbersome - especially on Windows with limited NTFS.

The necessary IntelliJ files could be packaged and provided as Maven dependency and then started as external process.

Is there a way to achieve better Groovy formation with Spotless?

(Of course, IntelliJ could format many other file types, too, but I'm mainly interested in Groovy.)

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia leggendo le linee guida per i contributi e il formatter Groovy esistente che utilizza Eclipse formatter. Confronta il suo contratto di formattazione di un singolo file con le modalità da riga di comando proposte dry-run e format di IntelliJ Community Edition, comprese le problematiche relative ai file temporanei e ai processi esterni. Il lavoro sarà completato quando sarà stata concordata una modalità manutenibile per migliorare la formattazione di Groovy e Spock in Spotless.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
groovy, java
Ambito
tooling
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.