Hi, is ktlint the go-to formatter (the 'prettier' ...
# getting-started
a
Hi, is ktlint the go-to formatter (the 'prettier' or gofmt) of kotlin? My team is starting to use kotlin, and such a tool would help a lot to keep things tidy 🙂
a
Is a good tool to use, we use that in our projects because is easy to use and configure
You can also look at this one: https://github.com/arturbosch/detekt
a
Thanks 🙂
m
Detekt uses ktlint under the covers, and I think they're moving away from formatting. If you use Android Studio/IntelliJ, then set the Code Style to pre-defined Kotlin style (details in official docs), and use it for formatting. Can be done as part of committing to Git, assuming you're using Git, and IntelliJ to do commits.
To be clear. Detekt uses ktlint under the covers for formatting. Not the static analysis.
a
😮, i just find out about detekt like two days ago, thanks for the clarification @Mike
btw: i think detekt has an integration with Sonar, which we use here
m
Detekt is amazing for doing static analysis. I rely on IntelliJ for formatting.
There is a plugin for Sonarqube written by the Detekt team. Sonarqube 6.7+ now has a Kotlin specific plugin. I think it can pull in Detekt results. BUT I have my project set for 'failfast', so there are never any unfixed/unsuppressed issues.
👍🏼 1
d
ktlint didn't have some features we needed (until recently?) eg ability to auto fix indentation issues, so we actually set up CI to validate that IntelliJ auto formatting had been applied using an IntelliJ docker image somebody maintains
v
Detekt works great. It also provides a wrapper around Ktlint so you don’t need to pull in both detekt and ktlint