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 Unused Import when importing static java function #872

Closed
Koriit opened this issue Aug 28, 2020 · 3 comments · Fixed by #889
Closed

false-positive Unused Import when importing static java function #872

Koriit opened this issue Aug 28, 2020 · 3 comments · Fixed by #889
Labels
Milestone

Comments

@Koriit
Copy link

Koriit commented Aug 28, 2020

Expected Behavior

Applying linter rule should not break the compilation.

Observed Behavior

There is a false-positive unused import. With hard linter check, cannot build because of linter error. If the import is removed cannot build due to compilation error.

There was no such issue in 0.37.2

Might be related to #845

Steps to Reproduce

This is tricky as I couldn't reproduce a "clean" scenario. However, this is a sample project that reproduces the issue with a google library that we had in one of my projects and which is affected: https://github.com/Koriit/issues-ktlint-872

Your Environment

  • Version of ktlint used: 0.38.1
  • Name and version (or code for custom task) of integration used (Gradle plugin, Maven plugin, command line, custom Gradle task): org.jlleitschuh.gradle.ktlint 9.3.0
  • Version of Gradle used (if applicable): Gradle 6.5.1
  • Operating System and version: Mac OS X 10.14.6 x86_64
  • Link to your project (if it's a public repository): https://github.com/Koriit/issues-ktlint-872
@Tapchicoma Tapchicoma added the bug label Aug 29, 2020
@shashachu
Copy link
Contributor

@Koriit thanks for the report at the sample project. If you need to unblock yourself, the ktlint-disable directives should work; see the README for details.

@shashachu shashachu added this to the 0.39.0 milestone Aug 29, 2020
@Koriit
Copy link
Author

Koriit commented Aug 31, 2020

Thanks for the suggestion!

@olegivo
Copy link

olegivo commented Sep 2, 2020

I also reprodused the bug when there are static class import and concrete static class method import both:

import org.assertj.core.api.Assertions
import org.assertj.core.api.Assertions.assertThat

After removing static class import and leaving static method import all works fine.

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

Successfully merging a pull request may close this issue.

4 participants