diff --git a/Contributing.md b/Contributing.md index 0317099..2c02b5c 100644 --- a/Contributing.md +++ b/Contributing.md @@ -13,6 +13,28 @@ Variable naming: * Statics are named `ourFoo` * Constants are named `FOO_CONSTANT` + + +# Code Formatting + +HAPI-FHIR uses the maven `spotless` plugin. Code is formatted with [palantir java format](https://github.com/palantir/palantir-java-format) as our repository format, due to its line length of 120, along with its focus on formatting code specifically to be easier to code review. + +Only production code is auto-linted, test code is omitted currently, due to certain whitespace requirements for test asserts. Eventually this will be rectified. + +Code is automatically formatted any time you either run: + +- `mvn clean install -DskipTests` +- `mvn spotless:apply` + +You can also make use of the [pre-commit project](https://pre-commit.com/) to add an optional pre-push hook. This can be setup by installing pre-commit as indicated on their website, and then running `pre-commit install --hook-type pre-push`. After that, any time you attempt a push, spotless will apply all formatting changes automatically on push. Note that while the installation of this pre-push hook is optional for developers, the pipeline will fail if formatting has not been done. + + +If your code is not formatted by the time it hits the pipeline, the new github action will fail. + + + + + The project also uses an [`.editorconfig`](https://editorconfig.org/) file to avoid ever worrying about tabs vs. spaces issues. There are plugins for most IDEs (and IntelliJ has built in support) for this format, so it is highly recommended to use it. Test naming: