Closed Richargh closed 5 years ago
We have looked at the following options:
ktlint https://ktlint.github.io/
Is a linter for kotlin. It can be added to the build.gradle as a task. It supports to check the project for conformity with the code style as well as automatic re-formating (by using gradlew ktlint
and gradlew ktlintFormat
respectively). There are not a lot of configuration possibilities, however theoretically new rulesets could be added https://github.com/pinterest/ktlint#creating-a-ruleset. A major downside is that there is not really an option to disable certain rules for the project, instead directives would need to be included in the code.
.editorconfig An .editorconfig file could be added to the project. IntelliJ recognizes such a file and applies the specified settings on "Reformate code". The range of supported properties by .editorconfig is relatively small and can be found here: https://editorconfig.org/ https://github.com/ec4j/editorconfig-gradle-plugin is a gradle plugin which allows to check the project for conformity with the rules defined in .editorconfig
IntelliJ Code Style XML IntelliJ supports the export of the Code Style Settings as .xml file. This file must then be imported to intelliJ by all developers (that is a downside). However in contrast to the .editorconfig-file, here a wide range of properties can be stored.
Use preconfigured IntelliJ Code Style for Kotlin IntelliJ supports two Code Style Settings by default. Enforcing the developer to use one can only be done by telling him/her to do so.
https://github.com/JetBrains/inspection-plugin this one seems to be similar to ktlint
Decisions: we'll use IntelliJ Code Style XML=IntelliJ supports the export of the Code Style Settings as .xml file.
Add a tool for the Analysis Code that auto-formats code.