Skip to content
This repository has been archived by the owner on Mar 8, 2024. It is now read-only.

Tool Setup

Felix W. Dekker edited this page Nov 7, 2018 · 4 revisions

There's a number of peculiarities with Detekt, which initially made it hard to configure. Those issues have been resolved or hacked around.

  • Detekt fails on Windows unless the cache directory is set somewhere outside of the project. To work around this, always run Detekt with a relocated cache: gradlew detektCheck --project-cache-dir=../schaapi-cache. This extra argument should not be necessary on Unix. Yes, this also means that you will get an annoying schaapi-cache directory as a sibling to your schaapi repo directory.
  • Because of the issue above, the check task does not rely on detectCheck. If you want to run all tests and verification, run gradlew detektCheck --project-cache-dir=../schaapi-cache check. Again, the extra argument should not be necessary on Unix.
  • Detekt should be applied only to the root project (in the build.gradle, that is), not to the individual subprojects. It is therefore currently not possible to change the configuration of Detekt per module. This also means that you cannot run gradlew :subproject:detectCheck, but luckily gradlew :detectCheck already checks all the modules, including the subprojects.
  • Detekt creates the directories --config and --config-config-resource for some reason. This is a bug. I have configured Gradle to remove these directories after running Detekt.
  • It doesn't work on Travis for some reason. Luckily, we also have AppVeyor.

ktlint was configured in c47f5d7. The setup uses Spotless, which is a general tool for linters. The reason that Spotless was used is that its Gradle plugin looks way more developed and maintained than ktlint's own (unofficial) plugins.

ktlint enforces the Kotlin style guide. You can configure IntelliJ to conform to this style using the following instructions:

Enforcing Kotling style guide in IntelliJ

Additionally, you should:

  • Disable Kotlin > Wrapping and Braces > Method call arguments > New line after '('.
  • Disable Kotlin > Wrapping and Braces > Method call arguments > Place ')' on new line.

ktlint has two tasks: spotlessCheck and spotlessApply. The former checks that the code conforms to the required style, and the latter changes the code to conform. The spotlessCheck is executed as part of gradlew check, and results in build warnings.

Clone this wiki locally