chasm
chasm copied to clipboard
Code Style
We are in desperate need to get some uniform code style, at least for this repository.
Requirements would be:
- Automated checks possible (ideally via gradle)
- Integration in Intellij
- Integration in Eclipse
Checkstyle comes to mind, I think it has good support and should be sufficient. We don't need anything super specific, but just having standards on general formatting and imports would be good.
I've added a checkstyle file and the gradle plugin. This should probably be mentioned in a CONTRIBUTING.md file.
I would still like to add a github workflow to check the style of prs. If anyone could help with that, that'd be great!
Also the checkstyle right now is a sliightly modified version of the google style from the checkstyle repo. If anyone who knows what they are doing would like to modify that, please do!
Lastly, no promises that the editorconfig matches the checkstyle.
How do we want to handle boxing and unboxing? I like to explicitly use Integer.valueOf and .intValue(), but I've also seen casting to Object and casting to int, or leaving the (un)boxing implicit.
I think that implicit unboxing, like I used everywhere else in the project, is absolutely fine.
Streams are probably fine until they're in a performance-critical area, then it should be benchmarked. I'll put them back in my PR. Unless they're not more readable than for loops?
Until we have any idea how critical performance is we should just choose whatever is more readable. And I highly doubt streams will matter in chasm, in terms of performance.
I think streams are good to read if the operations are fairly short:
- Filter and get first
- Filter and collect
- Map and collect
I've added a checkstyle file and the gradle plugin. This should probably be mentioned in a CONTRIBUTING.md file.
I would still like to add a github workflow to check the style of prs. If anyone could help with that, that'd be great!
Also the checkstyle right now is a sliightly modified version of the google style from the checkstyle repo. If anyone who knows what they are doing would like to modify that, please do!
Lastly, no promises that the editorconfig matches the checkstyle.
This is sadly an annoyance of the entire java tooling ecosystem not having any real good formatters beyond the IDEs, which is something that will raise controversy if we force everyone to use some specific IDE.
Yeah I keep forgetting about the CONTRIBUTING.md file.
In other notes, I added an action that automatically builds PRs, which also runs checkstyle. Sorry for not mentioning that here before.
We don't want to use var
for Java 8 compat, right?
Should we use this.this
because I think it's more explicit, so you can tell whether you're using a local variable or a field.