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

false positive for unused import #204

Closed
objectivePinta opened this issue May 2, 2018 · 5 comments
Closed

false positive for unused import #204

objectivePinta opened this issue May 2, 2018 · 5 comments

Comments

@objectivePinta
Copy link

I use the class for which I get the report like this:
val response = config.restTemplate.postForEntity(uri, excel, ThatClass::class.java)

@shyiko
Copy link
Collaborator

shyiko commented May 2, 2018

$ cat A.kt
import x.y.z.ThatClass

fun main() {
    val response = config.restTemplate.postForEntity(uri, excel, ThatClass::class.java)
}
$ ktlint A.kt
// no errors printed

Please provide a complete example.

@JayNewstrom
Copy link

I've seen this happen as well. It was dealing with a val in one file, and using it in another package. I'll see if I can come up with a minimal sample to reproduce.

@JayNewstrom
Copy link

JayNewstrom commented May 2, 2018

So it has to do with the naming of things.

package jaynewstrom.minimal.another

import jaynewstrom.minimal.anotherThing

class Foo {
    val bar = anotherThing
}

And

package jaynewstrom.minimal

internal val anotherThing = ""

This minimal sample will reproduce it. Notice these are in different packages, and the name of the val has the name of the nested package in it.

@shyiko
Copy link
Collaborator

shyiko commented May 2, 2018

Thank you, Jay! I'll have a fix shortly.

@shyiko shyiko closed this as completed in c9181df May 2, 2018
@shyiko
Copy link
Collaborator

shyiko commented May 3, 2018

Fixed in 0.23.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants