Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce quarkus format (or quarkus fmt) #30337

Closed
gastaldi opened this issue Jan 12, 2023 · 8 comments
Closed

Introduce quarkus format (or quarkus fmt) #30337

gastaldi opened this issue Jan 12, 2023 · 8 comments
Labels
area/cli Related to quarkus cli (not maven/gradle/etc.) kind/enhancement New feature or request

Comments

@gastaldi
Copy link
Contributor

Description

Analogous to go fmt, it would be nice if the CLI had a command to automatically format the project sources by running quarkus fmt

Implementation ideas

The command may invoke the mvn formatter:format goal (if configured in the project) otherwise prompt to include it in the project and use the Quarkus IDE Config (io.quarkus:quarkus-ide-config) by default

@gastaldi gastaldi added kind/enhancement New feature or request area/cli Related to quarkus cli (not maven/gradle/etc.) labels Jan 12, 2023
@maxandersen
Copy link
Member

if quarkus format just calls underlying build tools format operation I don't see much value in it.

it should be something that formats code in a consistent way no matter the underlying build tool imo.

@dvsingh9
Copy link

Most of the time formatting is specific to company. Companies creates their custom formatting rules, this may not add much value and if Quarkus is going to add it then it should be configurable.

@gastaldi
Copy link
Contributor Author

Most of the time formatting is specific to company. Companies creates their custom formatting rules, this may not add much value and if Quarkus is going to add it then it should be configurable.

That's precisely why I suggested invoking the formatter plugin instead

@holly-cummins
Copy link
Contributor

I think it needs to be consistent rules, to make sure everyone in a team gets the exact same stuff, without argument and with no option for configuration. In formatting, customisation is what causes pain. So invoking the formatter plugin would have a risk that someone customised it. Our rules seem like good rules to assume.

And then we need to make sure the IDE's formatter agrees with our view of the world, so that the IDE and CLI aren't fighting. That on its own would be worth the price of admission, actually, even if didn't do anything else. I keep tripping over that on projects - most recently I was getting release failures because of formatting mismatches between IDE and CLI.

@holly-cummins
Copy link
Contributor

In particular, go fmt is not configurable. That's why it adds so much value - it's not the speed of invocation, it's the "you will never have to have a discussion about formatting conventions again." (See, for example, golang/go#40028)

"It is an intentional design choice that there are no configuration options for gofmt. The benefit of eliminating bike shed discussion about formatting choices is considered to be more important than the cost of not permitting people to use their preferred style. The usual saying is that gofmt isn't anybody's preferred style, but it's adequate for everybody."

@holly-cummins
Copy link
Contributor

holly-cummins commented Jan 12, 2023

... and if companies feel the position of braces justifies the cost of arguing about formatting rules, they can always not use the quarkus fmt command. The differentiator of this command would have to be that it's massively opinionated, because formatting code on its own is definitely not novel :)

No one needs the cognitive load of another tool to remember, if it behaves exactly like the many tools already out there.

@gastaldi
Copy link
Contributor Author

@holly-cummins that makes sense. I'll prototype something and see how that works out

@geoand
Copy link
Contributor

geoand commented Apr 12, 2023

jbang aliases from the Quarkus catalog are already supported as CLI plugins, so I am going to close this.

@geoand geoand closed this as completed Apr 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cli Related to quarkus cli (not maven/gradle/etc.) kind/enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants