April 10, 2026
Lint Wars: Kotlin Edition
Static code analysis in Kotlin – tools overview
Kotlin devs clash: “Let robots sort methods” vs “Let humans tell the story”
TLDR: A team reviewed ktlint, detekt, and diktat to auto-sort Kotlin methods but found none support it — and Kotlin’s guidelines actually discourage it. Comments split between “let robots tidy” and “let humans tell the story,” turning a simple tool hunt into a spicy style-philosophy showdown.
A Kotlin team went shopping for a tool to auto-organize code and stumbled into a civil war. They checked three popular tools — ktlint, detekt, and diktat — hoping to auto-sort methods and fields. Plot twist: none of them do it, and Kotlin’s own guidelines say you shouldn’t. The comments lit up like a code review on a Friday night. One camp cheered, saying method order should tell a story a human can follow. The other camp wants the machines to tidy the mess and stop fights in pull requests.
Fans broke into brand factions. ktlint stans bragged it already polishes style; detekt defenders said it’s great at sniffing code smells (bad patterns); diktat got called the strict schoolteacher you love to fear. Non-tech translation: these tools read your code without running it and flag inconsistencies — but they won’t alphabetize your life. The memes flew fast: “linters are the new astrology,” “my code, my chaos,” and “let IntelliJ press the tidy button.” Some begged for a custom rule; others yelled “bikeshedding!” and dropped popcorn gifs. The vibe? Equal parts exasperation and relief. The article’s big reveal wasn’t a new tool, but a line in the sand — order by story, not by alphabet — and the internet had thoughts.
Key Points
- •A team evaluated detekt, diktat, and ktlint to automate or verify method/field ordering in Kotlin code.
- •Static code analysis inspects source code without execution to find bugs, style issues, and security problems using predefined rules.
- •Ktlint and diktat use the Kotlin compiler’s PSI; detekt uses PSI/AST with its own abstractions.
- •Rules traverse the AST using the Visitor pattern; violations produce reports and may include auto-correction by mutating AST nodes.
- •None of the reviewed tools support enforcing method order out of the box, aligning with Kotlin coding conventions that discourage sorting methods by order or visibility.