-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add checkstyle #3229
base: master
Are you sure you want to change the base?
Add checkstyle #3229
Conversation
…so completely per comments
I suspect the Personally I have a mild preference to avoid start imports simply because
...but this is a weakly held view -- any advocates for star imports are welcome to comment and we can roll that bit back! 👍 😄 |
Nitpick 😇: There should be an ADR (refs #2714) on using custom checkstyle rules versus Google Java Style Guide. Besides the two spaces rule, I personally like it, because there is good tooling: Google Java Format: Formats the code, ... |
This PR adds checkstyle to the build, to help minimise the amount of churn of e.g. import statements. The config is adapted from the default Sun style, with changes made to match our current codebase.
Where I have been able to get a "quick win" to adopt a consistent style then that is included within this PR (e.g. adding comments to
public static final
fields and making themUPPER_CASE
, tweaking whitespace around operators, tweaking imports).Where it's not feasible to apply the rule yet or the rule is in default sun style but might not be relevant / applicable to our project, I have added it to the suppressions (exceptions) file. Preferably these suppressions are limited to the relevant files, but there are some rules added as a global supression.
It's a TODO for future PRs to investigate whether the remaining "suppressed" checks are applicable or if they definitely don't apply / we don't care.
For example, there are lots of warnings about magic numbers where we use
31
in thehashCode()
methods - maybe one day we will convert them all to useObjects.hashCode(...)
but perhaps not right now and certainly not within this PR. Ditto for ensuring there is javadoc for all public methods/classes - this is something we probably should be doing, but there are too many places we don't have this that it's a substantial piece of work (assuming we want to do it - again a separate discussion / PR 👍 ).