https://kotlinlang.org logo
#ktlint
Title
# ktlint
r

rsetkus

07/14/2020, 3:11 PM
Hi all. I know that Klint is for style & formatting but since you can access PSI elements, I am wondering is it possible to write a rule which would fail if not certain class is extended. Would it be possible to do that in Ktlint?
s

Sha Sha Chu

07/14/2020, 4:15 PM
i don’t think ktlint is the best tool for this because it wouldn’t be easy to tell, for example, if class A : B and class B : C since it mostly has access to the names and types of the elements. i’m not sure if maybe detekt is a better tool? i’ve never actually used it myself
r

rsetkus

07/14/2020, 8:33 PM
Thanks for the response @Sha Sha Chu. I would agree with you. Ktlint is a tool for different purpose. Mostly, I am interested only into super type, I guess I can just match classes node
text
using regex to find whether it extends the right type. Don't want include another dependency just for that.
s

Sha Sha Chu

07/14/2020, 9:34 PM
yes, that would work it just wouldn’t be extremely robust.
7 Views