Linting #3
Replies: 3 comments
-
@kibettheophilus any thoughts? |
Beta Was this translation helpful? Give feedback.
-
Hey @MamboBryan , in my understanding...both of them are static analysis tools when working with Kotlin,however the key difference is Ktlint has been configured to follow the official Kotlin language guidelines while Detekt gives you the ability to configure rules which aren't really "Kotlinish" but to you own personal/team liking. e.g with Detekt you can configure the max length of a class or function, number of params in a class or function while Ktlint will just do the formatting based on the preconfigured rules(to adhere to Kotlin standards e.g a function should not start with a capital letter unless it is a Composable which you can disable only for composable functions). Just like the official Android lint, detekt and ktlint also offers api which let's you extend the existing rulesets offered by the tool. Read more about extending the rulesets: ℹ️ Both detekt and ktlint work hand in hand to ensure code quality in our codebases:
|
Beta Was this translation helpful? Give feedback.
-
@kibettheophilus thanks for the detailed answer. @MamboBryan both are code analysis tool we can use to ensure clean and consistent quality code. Ktlint as @kibettheophilus mentioned is 'very Kotlinish' and is focused more on formatting and code styling as per kotlin rules. (Check available rule sets on this link) Detekt on the other hand goes beyond formatting and styling to check for code smells and has a wider range of rulesets beyond the formatting one e.g. this complexity rule set and this coroutines rule set. Detekt also has the formatting ruleset that wraps the Ktlint rules under the hood but there was an active discussion to remove it hence why I always went with integrating them separately but I can see the discussion is closed now and they are keeping the Ktlint wrapper(yaaaay!😃). With this I would just integrate Detekt alone and use Ktlint formating rules under the hood. |
Beta Was this translation helpful? Give feedback.
-
What are the specific usecases for ktlint and detekt?
Beta Was this translation helpful? Give feedback.
All reactions