Android and Detekt: Aligning .idea CodeStyle with detekt

1.5k views Asked by At

I have an Android project that i've set up with Detekt.

I'm currently using:

  • io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.19.0 (Root build.gradle)
  • io.gitlab.arturbosch.detekt:detekt-formatting:1.19.0 (in my modules).

Running gradle detekt works fine and it's correctly formats code in regards to ktlint rules and I've added logic to run detekt on compile successfully, with the built in ktlint rules in detekt-formatting. :)

My question is: I can't seem to find anything about how to align the auto formatting in Android Studio (Code > Reformat file), which, in my case, is set to be a specific one for my project ({root}/.idea/codeStyles/...), with the formatting used by Detekt. Reason for wanting this, is that i now have to maintain two formatting style files and keep them aligned, instead of being able to make both formatters point to the same config file.

1

There are 1 answers

0
Phehaz On BEST ANSWER

Did not find a straight forward way to do this, but got 2 good suggestions from one of the Detekt maintainers:

https://github.com/detekt/detekt/discussions/4663