Stream: dev

Topic: code formatting (Spotless, Checkstyle, etc.)


view this post on Zulip Philip Durbin ๐Ÿš€ (Apr 12 2024 at 20:05):

@Oliver Bertuch introduced us to Spotless for formatting code in https://github.com/gdcc/xoai

From the README:

mvn spotless:apply
# - or to just check for consistency use -
mvn spotless:check

It works great! Should we use it with the main code base?

view this post on Zulip Philip Durbin ๐Ÿš€ (Apr 12 2024 at 20:06):

And the logo is awesome:

spotless_logo.png

view this post on Zulip Oliver Bertuch (Apr 12 2024 at 20:07):

What did I do? :see_no_evil:

view this post on Zulip Oliver Bertuch (Apr 12 2024 at 20:08):

I have to admit, Spotless has its flaws...

view this post on Zulip Oliver Bertuch (Apr 12 2024 at 20:09):

You don't want it to apply on the main codebase...

view this post on Zulip Oliver Bertuch (Apr 12 2024 at 20:09):

Really you don't

view this post on Zulip Philip Durbin ๐Ÿš€ (Apr 12 2024 at 20:09):

D'oh! Why not? :doh:

view this post on Zulip Oliver Bertuch (Apr 12 2024 at 20:09):

Same thing as getting rid of all the tab chars and other mistakes in styling

view this post on Zulip Oliver Bertuch (Apr 12 2024 at 20:09):

It's gonna be an ginormous blob of changes

view this post on Zulip Philip Durbin ๐Ÿš€ (Apr 12 2024 at 20:10):

What if it was a brand new Java project? Use Spotless?

view this post on Zulip Oliver Bertuch (Apr 12 2024 at 20:10):

Not sure. Spotless is very opinionated

view this post on Zulip Oliver Bertuch (Apr 12 2024 at 20:11):

It might be fine just using stuff like Sonarcloud or Checkstyle

view this post on Zulip Oliver Bertuch (Apr 12 2024 at 20:11):

And enforce it some more

view this post on Zulip Oliver Bertuch (Apr 12 2024 at 20:11):

At least Checkstyle is configurable...

view this post on Zulip Oliver Bertuch (Apr 12 2024 at 20:11):

Spotless is more or less not

view this post on Zulip Philip Durbin ๐Ÿš€ (Apr 12 2024 at 20:12):

We already have a Checkstyle config: https://guides.dataverse.org/en/6.2/developers/coding-style.html#checking-your-formatting-with-checkstyle

view this post on Zulip Oliver Bertuch (Apr 12 2024 at 20:12):

Yeah

view this post on Zulip Oliver Bertuch (Apr 12 2024 at 20:12):

We do :melting_face:

view this post on Zulip Oliver Bertuch (Apr 12 2024 at 20:13):

The rules we have in there are never being applied...

view this post on Zulip Oliver Bertuch (Apr 12 2024 at 20:13):

No review is looking at this stuff

view this post on Zulip Oliver Bertuch (Apr 12 2024 at 20:14):

Not many people on the core team care about this... :face_with_hand_over_mouth:

view this post on Zulip Philip Durbin ๐Ÿš€ (Apr 12 2024 at 20:14):

Should use use Sonar instead? We do have this issue: Set up Sonar #9846

view this post on Zulip Philip Durbin ๐Ÿš€ (Apr 12 2024 at 20:14):

I really don't care which tool we use.

view this post on Zulip Philip Durbin ๐Ÿš€ (Apr 12 2024 at 20:14):

And I'll adapt to whatever opinionated style.

view this post on Zulip Oliver Bertuch (Apr 12 2024 at 20:15):

Sure thing. All of the gdcc things I started use Sonarcloud

view this post on Zulip Philip Durbin ๐Ÿš€ (Apr 12 2024 at 20:15):

Are you using Sonarcloud for code formatting in any of those projects?

view this post on Zulip Oliver Bertuch (Apr 12 2024 at 20:15):

But no tool will get something moving. It's a social problem, no tech is gonna solve that.

view this post on Zulip Oliver Bertuch (Apr 12 2024 at 20:16):

Nope, I'm just using it for annotations and recommendations

view this post on Zulip Oliver Bertuch (Apr 12 2024 at 20:16):

You could make it more enforcing

view this post on Zulip Oliver Bertuch (Apr 12 2024 at 20:16):

Matter of configuration

view this post on Zulip Philip Durbin ๐Ÿš€ (Apr 12 2024 at 20:16):

Well, the problem is solved in our xoai library, right?

view this post on Zulip Oliver Bertuch (Apr 12 2024 at 20:17):

Which problem? Formatting?

view this post on Zulip Oliver Bertuch (Apr 12 2024 at 20:17):

We did use spotless on it... after a huge rewrite and on a much smaller codebase with far less folks involved

view this post on Zulip Philip Durbin ๐Ÿš€ (Apr 12 2024 at 20:19):

The social problem. I'm seeing some back and forth at https://github.com/gdcc/xoai/pull/119 about formatting. It looks like you ran Spotless here: https://github.com/gdcc/xoai/pull/119/commits/a70ea5d0b021a9b06eb65559fee8685ca54c67e2

view this post on Zulip Oliver Bertuch (Apr 12 2024 at 20:20):

See what it did to the codebase? Crazy!

view this post on Zulip Philip Durbin ๐Ÿš€ (Apr 12 2024 at 20:20):

That a70ea commit? Looks fine.

view this post on Zulip Oliver Bertuch (Jun 28 2024 at 19:05):

Came across https://github.com/revelc/formatter-maven-plugin today. Sounds interesting. Enables definition of custom rules, not just adapting what others use like spotless.

view this post on Zulip Philip Durbin ๐Ÿš€ (Jul 01 2024 at 17:57):

Nice. Should we play around with it in a low-risk repo like https://github.com/gdcc/hello or https://github.com/gdcc/exporter-debug ?

view this post on Zulip Philip Durbin ๐Ÿš€ (Nov 20 2024 at 21:58):

Some new comments from @Steven Winship: https://github.com/IQSS/dataverse/pull/11016#discussion_r1850852625

view this post on Zulip Philip Durbin ๐Ÿš€ (Mar 26 2025 at 15:27):

@Oliver Bertuch do you have any ideas on this one? https://github.com/gdcc/exporter-croissant/issues/11

view this post on Zulip Oliver Bertuch (Mar 26 2025 at 17:27):

Nope, none except moving away from spotless (see above) or trying to make it exclude xml files.

view this post on Zulip Philip Durbin ๐Ÿš€ (Mar 26 2025 at 18:21):

Sure, but do you have any idea what maven-release-plugin is doing?

view this post on Zulip Oliver Bertuch (Mar 26 2025 at 18:22):

Nope. Lucky guess: it's the XML serialization. The release plugin manipulates the DOM, so maybe this is why.

view this post on Zulip Philip Durbin ๐Ÿš€ (Mar 26 2025 at 18:27):

yeah, maybe the flatten stuff :shrugdog:

view this post on Zulip Philip Durbin ๐Ÿš€ (Mar 26 2025 at 18:28):

So you're suggesting trying https://github.com/revelc/formatter-maven-plugin instead of spotless?

view this post on Zulip Philip Durbin ๐Ÿš€ (Mar 26 2025 at 19:52):

@Oliver Bertuch how does this grab ya as a workaround? https://github.com/gdcc/exporter-croissant/pull/12

view this post on Zulip Philip Durbin ๐Ÿš€ (Oct 27 2025 at 13:26):

From https://github.com/quarkusio/quarkus/discussions/40542 I learned the Quarkus project uses https://github.com/revelc/formatter-maven-plugin to format their code. See https://github.com/quarkusio/quarkus/blob/3.29.0/CONTRIBUTING.md#formatting


Last updated: Nov 01 2025 at 14:11 UTC