Does anyone have any tips on getting consistency b...
# android
c
Does anyone have any tips on getting consistency between code style for developers? It seems like IntelliJ codestyle is a little different between intellij/kotlin style, and then there's also https://developer.android.com/kotlin/style-guide. Seems like a lot of options, but I'm looking for something turnkey that works in static code analysis and works easily to import into intellij so the IDE formatting matches the actually analyzer. Not the biggest nitpicker on style, and using something out of the box from square or another trusted company would be cool. Curious to hear what everyone is using!
n
I think ktlint is probably what you're looking for. https://github.com/pinterest/ktlint
c
Thanks. I'll be giving this a try.
v
Take a look it detekt. It also provides a wrapper around ktlint and comes with an IDE plugin so the styles are enforeced at code-time
c
Whoah. Now I'm definitely confused. It doesn't explicitly say that it's a wrapper around ktlint? Also, ktlint and detekt seem to provide the exact same things (linter + plugin/formatter). Any idea on what to use?
n
ktlint to me seems more like a styler/formatter where as detekt is better for code smells and preventing silly mistakes. I use both for personal projects as part of the linting. You can use the ktlint command
./ktlint --android applyToIDEA
in Terminal to apply the style to your IDE and enforce it and also use detekt to lint against any code smells and easy mistakes. But here's where detekt mentions it also wraps over ktlint: https://github.com/arturbosch/detekt#adding-more-rule-sets
c
@Nicholas Doglio "I use both for personal projects as part of the linting." Both in the same project?
n
Correct.
I think of ktlint as more of code formatter style guide and detekt as a way to prevent code smells, I don't really think they do the same thing
c
Cool. Appreciate your experience on these.
­čĹŹ 1