Rajat Varyani
05/13/2020, 4:26 PMvar
in codebase. What is i could come up till now is
override fun visitDeclaration(dcl: KtDeclaration) {
super.visitDeclaration(dcl)
if (dcl is KtProperty && dcl.isVar) {
report(CodeSmell(issue, Entity.from(dcl), "Mutation in code"))
}
}
Now I am writing code to detect keywords like
val list = mutableListOf(1, 2)
. I am not sure how to go about it?Brais Gabin
05/13/2020, 4:39 PMmutableListOf()
you could take this rule as example: https://github.com/arturbosch/detekt/blob/master/detekt-rules/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/style/ForbiddenMethodCall.ktimport
stament so it’s easier to forbid the import… But ForbiddenImport doesn’t help you…ExplicitCollectionElementAccessMethod
. It looks for uses of Map so probably you can take some ideas from it.Rajat Varyani
05/14/2020, 5:20 AM