detekt-intellij-plugin
detekt-intellij-plugin copied to clipboard
Detekt custom rules that uses Type resolution doesn't work with IntelliJ plugin
Hi team,
I've created some custom rules. Few that use type resolution and few that don't. In the IntelliJ Plugin, rules that don't need type resolution works fine when I add the plugin jar. But the type resolution ones don't. Is this expected?
Thanks.
Is this expected?
Are they working fine if you invoke Detekt from CLI or from Gradle?
Hey @cortinico, Yes, while running the Gradle task it's working fine.
This is actually reported by users. ConfiguredService
does not invoke Detetkt
with BindingContext
, therefore, type resolution rules do not work and mixed type resolving/plain rules may result in weird behavior.
It is reported that UnusedPrivateMember
is such a rule with mixed behavior: https://kotlinlang.slack.com/archives/C88E12QH4/p1624326624052100
Hey, I would love to help, but might need a hint. I assume that if we set the classpath via compiler options, rules with type resolutions are executed.
Do you know how to get the classpath in the plugin?
I googled a bit, read some javadocs and tried with:
ModuleManager.getInstance(project).modules
.map { OrderEnumerator.orderEntries(it).recursively().getPathsList().getPathsString() }
.filterNot { it.isNullOrEmpty() }
.joinToString { ":" }
which gives me an empty string.
Rules like ForbiddenMethodCall
, ForbiddenImport
are not working with the plugin.
Yea, also just noticed that built-in rules that require type resolution are not working.
It's not just custom rules, btw, as per https://github.com/detekt/detekt-intellij-plugin/issues/499.