-
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
Unused imports are not removed with .* in the end #1256
Comments
Sorry I don't get the issue - if the |
@romtsn sorry Unused imports are not removed with .* in the end as import java.util.* for exanple |
In your editorconfig you have explicitly disabled the rule
Wildcard imports can just not be auto-corrected by ktlint. |
it's not about wildcard import but about the |
Yes @romtsn and @paul-dingemans this issue about This config is full my linter config |
@YauheniPo I'm not asking you about the config file, but about the source code file - we cannot reproduce the issue just by having an import list, we also need to see the source code and how these imports are used |
Actually the code provided could be a full example ;-) It would result in an empty after lint/format. I have fixed it (#1258), using example below:
which reports both |
awesome @paul-dingemans |
Closes #1256 Co-authored-by: Paul Dingemans <pdingemans@bol.com>
Issue reproduced for the current moment with the next setting
@romtsn @JLLeitschuh please help me with the issue don't remove unused import
|
sorry "0.42.1" is a old version without fix Who can build new version? |
You seem to be lucky. Today a new version, 0.43.0 was released in which this fix should be included. |
In 0.43.0 it seems to be removing wild card imports even though they are needed. And I have no-wildcard-import disabled.
Both imports are flagged as "Unnecessary import" and removed. |
I'm having same issue as @abouda |
You can create new issue with your problem of the klint my issue was resolved in 0.43.0 version |
I see the issue and for the next case import io.ktor.client.* config
@paul-dingemans please help ) |
const val ktlintExtension = "0.43.0" |
1 similar comment
const val ktlintExtension = "0.43.0" |
Please be more clear. I do not understand why the issue is reopened. Neither do I understand a stand alone comment like this:
|
Sorry
unused import are not removed above i provided my setting in gradle |
please tell me which setting of klint will prohibit the use * of such imports? |
I assume that the code sample is not complete as it only contains import statements. I can not analyse why the second import is not removed without the full sample. Not removing an unused import statement might be unwanted but is not a blocking problem. I suggest you accept that behavior till it is fixed in a future release. |
…lead to removal of required imports There is no reliable way to determined whether a wildcard import is actually used in the file. The AST does not seem to contain information about the actuall class that an identifier refers to. It is preferred to not remove unused imports than that needed imports are removed. Revert pinterest#1256 Closes pinterest#1277
The solution for this issue has been reverted. It can lead to removal of wildcard imports that are actually needed to compile the code (see #1277). The downside that some imports which are not used, is considered less harmfull than removal of imports which are required. As we see no solution for how to implement this with reasonable effort, the issue will be closed without resolving it. |
…emoval of required imports (#1402) There is no reliable way to determined whether a wildcard import is actually used in the file. The AST does not seem to contain information about the actuall class that an identifier refers to. It is preferred to not remove unused imports than that needed imports are removed. Revert #1256 Closes #1277 Closes #1393
.editorconfig:
import java.util.* - not using
Your Environment
The text was updated successfully, but these errors were encountered: