Skip to content
New issue

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

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

Already on GitHub? # to your account

False positive from UnusedImports on org.gradle.kotlin.dsl.provideDelegate #506

Closed
vlsi opened this issue Jun 28, 2019 · 7 comments · Fixed by #513
Closed

False positive from UnusedImports on org.gradle.kotlin.dsl.provideDelegate #506

vlsi opened this issue Jun 28, 2019 · 7 comments · Fixed by #513

Comments

@vlsi
Copy link
Contributor

vlsi commented Jun 28, 2019

See detekt/detekt#1608

@shashachu
Copy link
Contributor

I'm not sure this is a solvable problem. There's no way via static analysis we can tell that provideDelegate is used in that file. In this very specific case, I'd recommend a ktlint-disable directive to suppress the error.

@vlsi
Copy link
Contributor Author

vlsi commented Jun 28, 2019

I wonder if provideDelegate can be added to default excludes.

I see it might require compilation in order to tell if the import is used or not, however it is really sad that default spotless + ktlint configuration produces false positives on provideDelegate call.

@vlsi
Copy link
Contributor Author

vlsi commented Jun 28, 2019

Alternative option is to allow provideDelegate if source code contains at least one by

@JLLeitschuh
Copy link
Contributor

Could you check the type of provideDelegate to see if it's a delegate type and leave it in place if it is?

@shashachu
Copy link
Contributor

Alternative option is to allow provideDelegate if source code contains at least one by

Yes I see that detekt has just whitelisted that import. We could certainly do that.

Could you check the type of provideDelegate to see if it's a delegate type and leave it in place if it is?

@JLLeitschuh I'm not sure what you mean here.

@vlsi
Copy link
Contributor Author

vlsi commented Jul 3, 2019

Yes I see that detekt has just whitelisted that import. We could certainly do that

or even "whitelist it provided there's by in the source code"

@shashachu
Copy link
Contributor

It's not very sophisticated, but I put up a PR for this.

shashachu added a commit that referenced this issue Jul 10, 2019
…le (#513)

* Allow unreferenced provideDelegate if there is a by keyword in the file

Fixes #506

* fix test
sowmyav24 pushed a commit to sowmyav24/ktlint that referenced this issue Jul 18, 2019
…le (pinterest#513)

* Allow unreferenced provideDelegate if there is a by keyword in the file

Fixes pinterest#506

* fix test
orchestr7 pushed a commit to saveourtool/diktat that referenced this issue Jun 29, 2020
…le (#513)

* Allow unreferenced provideDelegate if there is a by keyword in the file

Fixes pinterest/ktlint#506

* fix test
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants