Remix.run Logo
LennyWhiteJr 2 days ago

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.

esafak 2 days ago | parent [-]

Do you use it in CI? Do you have a template or something to share?

LennyWhiteJr 2 days ago | parent | next [-]

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".

rileymichael 2 days ago | parent | prev [-]

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....