Has there ever been a discussion about providing a...
# ktlint
e
Has there ever been a discussion about providing a "simpler" API for Rules? For example, I'm porting some rules that I wrote for detekt and I find the detekt rule API to be very pleasant to work with.
s
can you be a bit more specific about what seems harder than it needs to be?
e
Detekt has some nice abstractions around working with psi and KtFile. Looks like most of that is supplied through the Kotlin compiler's KtVisitorVoid and then some wiring through detekt's BaseRule. Having the convenience functions from
KtVisitorVoid
are very helpful and make development simpler (at least from my perspective). It looks like ktlint just extracts the root AST node from the KtFile and operates using AST.
s
ah. yes, i can see us providing some abstractions or extensions if necessary. depending on what you need to do, it does sometimes require custom traversal of the AST
e
Yeah I expect to have to do custom traversal in some cases, but for certain cases it seems like there's a lot of non trivial repetition across rules (e.g. traversing the AST to find a
when
vs having a
visitWhen
function)
s
that makes a lot of sense. if you wouldn't mind writing an issue we can consider it for the 1.0 release or later