Re:Detekt – A static code analyzer for Kotlin
by LennyWhiteJr on Thursday July 24, 2025 @09:59AM
(#44670764)
I love Detekt! It's particularly good for enforcing project conventions that can't be covered with standard linters. With access to the full AST, you can basically enforce any kind of rule you want with custom analyzers. And LLMs take out 90% of the effort for creating new analyzers.
[ Parent
| on HN ]
Re:Detekt – A static code analyzer for Kotlin
by esafak on Thursday July 24, 2025 @10:39AM
(#44671276)
Do you use it in CI? Do you have a template or something to share?
Re:Detekt – A static code analyzer for Kotlin
by LennyWhiteJr on Thursday July 24, 2025 @11:15AM
(#44671737)
Yeah, it's included as one of the gradle scripts which fails the build in CI if the rules don't pass.
No template, as it's specific to my team's project, but one example is that we enforce that classes within our core domain don't import types from outside the project. You could accomplish this with separate projects, but that comes with its own complexities. This rule basically says "any domain type shall not import a non-domain type".
Re:Detekt – A static code analyzer for Kotlin
by rileymichael on Thursday July 24, 2025 @01:17PM
(#44673319)
there's an official template here: https://github.com/detekt/detekt-custom-rule-template/tree/m...
and here's the diff for a 'real world' rule I implemented: https://github.com/michaelbull/kotlin-result/compare/master....