-
Notifications
You must be signed in to change notification settings - Fork 506
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 unused import when import is referencing extension function and is used only in kdoc #1282
Comments
Can you provide some background of the use case for which you want to keep the import when it is only used for a reference in a KDoc? IntelliJ IDEA Ultimate has no problem to resolve the reference without the imports. |
Can you check the version of the kotlin plugin in IntelliJ? I am on version |
It happens with the latest one Are you sure your IntelliJ can resolve this kdoc if you remove an import? Can you take a screenshot? Because I don't even see how would that work (IntelliJ needs imports to resolve conflicts etc.). Linked issue is exactly what points against your point (it was false positive that import can be removed, since IntelliJ needs imports for KDoc). |
I think I do understand the miscommunication between us. Is it correct that your files are in different directories? If files are both in the same directory then IntelliJ indeed has no problems to display the link inside the kdoc as files belong to same package. However, if the files are in different directories (e.g. not in the same package) then IntelliJ needs the import for displaying the link inside kdoc correctly. |
Sorry, you are correct. I thought that files having the different package implied that they are in the different directories (I know kotlin allows different packages in the same directory, but this is generally not the practice). Updated the bug report to make that clear. |
See commit above. It should be fixed with that. |
Thanks! |
Closes #1282 Co-authored-by: Paul Dingemans <pdingemans@bol.com> Co-authored-by: Roman Zavarnitsyn <rom4ek93@gmail.com>
Steps to Reproduce
Run ktlint on the following two files (each file needs to be in a directory corresponding to the package):
Expected Behavior
Ktlint should pass
Observed Behavior
Ktlint fails with
FileB.kt:1:1 Unused import
Your Environment
0.43.0
JLLeitschuh/ktlint-gradle 10.2.0
7.2
5.15.1-1-MANJARO #1 SMP PREEMPT Sat Nov 6 14:11:10 UTC 2021 x86_64 GNU/Linux
The text was updated successfully, but these errors were encountered: