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

Enforce code formatting style #274

Open
kriegaex opened this issue Jan 20, 2024 · 0 comments
Open

Enforce code formatting style #274

kriegaex opened this issue Jan 20, 2024 · 0 comments

Comments

@kriegaex
Copy link
Contributor

kriegaex commented Jan 20, 2024

Establish a code formatting style and make sure that it is enforced during the build, maybe using tools like Spotless and/or Checkstyle.

I was thinking about this topic for at least two years on and off, always putting it off, as I am basically the only regular committer. OTOH, that would be the perfect opportunity to introduce such tooling without disrupting other developers. If anyone would on-board to AspectJ in the future, the infrastructure would just be in place already, including the infamous big commit (BC) reformatting everything.

But that same BC was what I wanted to avoid or put off for a while, because it would mean that git annotate|blame would become a bit more tedious in the future. The good news are:

  • git blame -w ignores whitespace changes
  • Git config option blame.ignoreRevsFile can ignore revisions such as the BC. It might be possible to add the option to a config file committed right into the repository, I have not verified that yet. Otherwise, at least locally it could be used.
  • IDEs like IntelliJ IDEA have options to handle certain types of changes (whitespace, moved blocks) intelligently when annotating files:
    image

I am quite opinionated about what code style I like. Being the sole committer would also mean that I would impose that style on future developers. But at least, it would be a clear guideline. I could just use default settings or well-known code styles for Maven plugins or IDE settings, but those are exactly what I sometimes dislike and perceive as ugly in other projects I contribute to. Spotless often just gets on my nerves - not so much, because it forces me to reformat to make a build pass but rather because it tends to destroy carefully crafted code looking good to my own eyes. Each tool has options to deactivate format enforcement for sections of code, and we should allow for that, but not make it a quasi standard to be used as an excuse to get around the formatting check. E.g., the reviewer for PRs would also decide whether or not to accept any exceptions in the PR. That would give some leeway to developers in cases where reformatting woud make the code less readable. The goal, however, should be to find settings covering most code in most situations in an acceptable way. If reformatting displeases me, but not so much that it causes "eye cancer" when reading it, it should be OK. Otherwise, a formatting exception in the source code might be the better alternative.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant