vorburger / ch.vorburger.exec

Java library to launch external processes
Apache License 2.0
30 stars 9 forks source link

Enforce Code Format with Checkstyle and/or Spotless and/or Google Java Format #129

Open vorburger opened 1 year ago

vorburger commented 1 year ago

Given that this project is starting to get PR contributions, it would IMHO be good to enforce a good format.

I'm already working on a PR with Checkstyle - which I'm hoping is quick - because I'll just copy/paste this and the respective lines from the MariaDB4j pom.xml .

This ch.vorburger.exec code historically actually originates from MariaDB4j and used to be formatted like that, so I expect that it should need relatively few changes only.

In #126 @mosesn has raised possibly using https://github.com/diffplug/spotless as a possible alternative. I am personally less motivated for doing the work for that, just because it would take me longer to figure out how to set up. (But years ago I actually was a Google Summer of Code GSoC mentor advising a student to add Spotless to https://github.com/apache/fineract/ and it seemed great, so I have no strong objections to replace Checkstlye with Spotless - if someone else wants to put in the work for it!) I don't suppose Spotless can use a Checkstyle configuration, can it?

An alternative could be using https://github.com/google/google-java-format. I have adopted that in my latest project, for https://github.com/enola-dev/enola, see https://docs.enola.dev, and quite like it too. I haven't looked much into the available Maven plugins, although looking at https://github.com/google/google-java-format#third-party-integrations it seems like Spotless may actually use Google Java Format internally? I'm OK if someone wants to raise a PR for that.

BTW on this sort of things, for Enola.dev I've also had loads of fun with a .pre-commit-config.yaml, and loads of related configuration files like .editorconfig and .prettierrc.yaml and .clang-format and .markdownlint.yaml and .protolint.yaml, but I think for this ch.vorburger.exec project I want to keep the "barrier to entry" lower by sticking to a pure Java and fully Maven integrated approach, only.

Thoughts - anyone?

vorburger commented 1 year ago

132 adds Checkstyle - just because that was the fastest for me to do, and prevents discrepancies.

I'm fairly open to PRs which would propose to remove Checkstyle to replace it with something else.

vorburger commented 3 months ago

I'm fairly open to PRs which would propose to remove Checkstyle to replace it with something else.

https://github.com/google/google-java-format is actually pretty great (I've been using it for Enola).