brandon-patterson / chemist

A virtual lab assistant
MIT License
0 stars 0 forks source link

Enforce a style guide #28

Open brandon-patterson opened 5 years ago

brandon-patterson commented 5 years ago
zspatter commented 5 years ago

I'm interested in looking into this issue, but I have no experience with enforcing style guides. Do you have any suggestiong on where to start? I image the easiest solution would be creating project-level styles in IntelliJ/Android Studio. I'm not sure how easily those configurations can be shared, and I imagine that's less than ideal in the event that a new contributor is trying to get started with the style guide.

I know within our IDEs we can set the styles and have those updated on save. I have absolutely no experience here, but I know git hooks could be used for this (I'm not sure if that's a good decision or not though).

brandon-patterson commented 5 years ago

The path of least resistance is probably to just enforce a well-known style guide (e.g. the google java style guide). Those guides should have implementations for pretty much any common editor. It's also totally reasonable for us to designate "supported IDEs" and have a policy that alternative IDEs are of course allowed, but users are responsible for their own style configs in that case.

I haven't dug deep, but it looks like gradle has some built-in style checking options, so you might start the investigation from the CI side. I'm guessing that's a configurable function, but if one styleguide is easier to implement than another, that could inform our choice. (Ultimately I don't care much about the specific style guide, just that it's reasonable, relatively common, and automatically enforceable!)

In general, I think git hooks that modify code are frowned upon. It could lead to very weird behavior when the code you commit doesn't match what ends up in the repo. A hook that blocked submission of poorly-formatted code would be more reasonable, but is likely overkill. (per-PR should be plenty frequent)