Skip to content

Add linting and formatting pre-commit/CI checks #406

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

Closed
bpkroth opened this issue Dec 6, 2023 · 0 comments · Fixed by #416
Closed

Add linting and formatting pre-commit/CI checks #406

bpkroth opened this issue Dec 6, 2023 · 0 comments · Fixed by #416

Comments

@bpkroth
Copy link
Collaborator

bpkroth commented Dec 6, 2023

This is more a convenience to developers and reviewers.

Often changes include some tweaks from an IDE's opinion on reformatting that reviewers have to adjust or ask for revisions on.

We can (should) automate this with pre-commit hooks and CI checks to remove a burden on both developers and reviewers.

Introducing these changes however will likely reformat a large portion of the codebase, so should be kept to a separate PR.

bpkroth added a commit that referenced this issue Dec 13, 2023
This change enforces javac compiler warnings and linting as errors as a
part of #406.
bpkroth added a commit that referenced this issue Dec 13, 2023
Uses [fmt-maven-plugin](https://github.com/spotify/fmt-maven-plugin) to
automatically (locally) apply [Google Java
Style](https://google.github.io/styleguide/javaguide.html) formatting
via the
[google-java-format](https://github.com/google/google-java-format)
plugin during `mvn compile` time.

During CI time, it checks for incorrect formatting on files *prior* to
compile to automatically reject failing commits so that reviewers have
fewer things to nit over and code style is more standardized.
- [x] Those file changes are initially omitted in order to validate this
part and make the PR easier to review. Will commit those once initial
review is done.

This is not *yet* enforced by a git pre-commit however, so developers
will have to add the changes that the `compile` stage applied after the
fact.

Additionally, it adds settings for
[VSCode](https://code.visualstudio.com/docs/java/java-linting#_applying-formatter-settings)
to apply these formattings during editing.
- [ ] Similar settings for Eclipse are currently missing.

Followup PR can also exclude this squashed PR from the `git blame`
analysis using a [`.git-blame-ignore-revs`
file](https://docs.github.com/en/repositories/working-with-files/using-files/viewing-a-file#ignore-commits-in-the-blame-view)

Closes #406
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

Successfully merging a pull request may close this issue.

1 participant