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

UnusedImport false positive with import kotlinx.android.synthetic as #286

Closed
olegivo opened this issue Oct 1, 2018 · 4 comments
Closed

Comments

@olegivo
Copy link

olegivo commented Oct 1, 2018

When you use import as for an import alias, ktlint detects a lint error: Unused import
Sample:
import kotlinx.android.synthetic.main.fragment_searchresultobjects.recyclerview as recyclerView

@shyiko
Copy link
Collaborator

shyiko commented Oct 1, 2018

Can you please provide a complete example?

$ cat A.kts
import kotlinx.android.synthetic.main.fragment_searchresultobjects.recyclerview as recyclerView
recyclerView()

$ ktlint --debug A.kts
...
[DEBUG] 772ms / 1 file(s) / 0 error(s)

$ ktlint --version
0.28.0

Thank you.

@olegivo
Copy link
Author

olegivo commented Oct 2, 2018

@shyiko, I can provide sanitized project for Android Studio which reproduce the behavior.
Version of ktlint is 0.28.0
I use kotliner gradle plugin to run ktlint
In the project there is a gradle task named 'staticAnalysis' that depends on ktlint task.
For now I does not understood yet where the ktlint placed to run it with arguments that you ask.

There is the one fragment (ObjectsFragment) with disabled ktlint rule. It faild when rules will be enabled.

@shyiko
Copy link
Collaborator

shyiko commented Oct 2, 2018

@olegivo Thank you for that. The line numbers reported by ktlint were off by 1 (CRLF EOL wasn't properly handled). Fixed in 0.29.0.

@shyiko shyiko closed this as completed Oct 2, 2018
@olegivo
Copy link
Author

olegivo commented Oct 2, 2018

Thank you very much!

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

2 participants