Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detekt custom rules that uses Type resolution doesn't work with IntelliJ plugin #126

Open
skymansandy opened this issue Apr 8, 2021 · 7 comments
Labels
bug Something isn't working improvement

Comments

@skymansandy
Copy link
Contributor

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.

@cortinico
Copy link
Member

Is this expected?

Are they working fine if you invoke Detekt from CLI or from Gradle?

@skymansandy
Copy link
Contributor Author

Hey @cortinico, Yes, while running the Gradle task it's working fine.

@chao2zhang chao2zhang added bug Something isn't working improvement and removed waiting for feedback labels Jun 22, 2021
@chao2zhang
Copy link
Member

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

@sesigl
Copy link

sesigl commented Jul 25, 2022

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.

@pinguinjkeke
Copy link

Rules like ForbiddenMethodCall, ForbiddenImport are not working with the plugin.

@kuhnroyal
Copy link

Yea, also just noticed that built-in rules that require type resolution are not working.

@sindrenm
Copy link

It's not just custom rules, btw, as per #499.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working improvement
Projects
None yet
Development

No branches or pull requests

7 participants