-
Notifications
You must be signed in to change notification settings - Fork 507
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
False positive from standard:no-unused-imports
when using org.gradle.kotlin.dsl.assign
#2343
Comments
Please include a code sample that reproduces the issue.
No, you don't need to open an issue for that. The |
Very odd, I'm unable to reproduce this in a standalone project. What's more, in a standalone project importing |
I'm going to close this because this is clearly something specific to the setup of my project and I unfortunately cannot isolate it into a standalone sample even after trying various theories for over an hour. Sorry about the noise. |
Ok, so now that I need to add more and more suppressions this started bugging me enough to attach the debugger and see why I was unable to reproduce. It turns out it was because in my reproducer sample I used Reproducer sample is available at: https://github.com/erdi/ktlint-assign-bug. There are instructions for how to reproduce in the readme file. I believe the fix will be to add# |
Can you check whether this a public repository? The link does not work. Neither do I see another public repository in your profile that could match. |
Removing this import results in compilation error when shorthand "=" is used instead of function `assign(..)`. Closes #2343
Expected Behavior
When importing
org.gradle.kotlin.dsl.assign
and using that extension method in the file,standard:no-unused-imports
should not raise a violation.Observed Behavior
standard:no-unused-imports
raises a violation iforg.gradle.kotlin.dsl.assign
is imported even though the import is used in a file.Context
Gradle 8.1 introduced simple property assignment in Kotlin DSL scripts as an experimental feature. That feature became stable in Gradle 8.4. It looks like the implementation involves a compiler plugin.
FWIW, a similar issue (in that the import was reported as unused) seems to have been fixed in IntelliJ.
As a side note, I tried disabling that rule using EOL comment on the line importing
org.gradle.kotlin.dsl.assign
,// ktlint-disable standard:no-unused-imports
, but that had no effect, the only way I was able to suppress it was for the whole file, using@file:Suppress("ktlint:standard:no-unused-imports")
. Should I open an issue for that?Your Environment
0.49.1
org.jlleitschuh.gradle.ktlint:11.6.1
Gradle plugin8.4
macOS 14.1
(23B74)The text was updated successfully, but these errors were encountered: