-
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 negative on "import java.util.*", expected no-wildcard-imports #1792
Comments
Can you check whether property |
This was with no Although, that got me looking a little deeper, and I see now that this is a feature, not a bug: Lines 96 to 101 in 481ad64
Based on the comment, it's also part of the IntelliJ default config, and there appears to be some confusion on the JetBrains side with regard to why the exception was made in the first place, with a decision to leave it in place regardless, just for consistency. However, at some point in the past I must have disabled that particular setting in my IntelliJ config. The defaults are set in Preferences->Editor->Code Style->Kotlin, which are currently blank for me (that gets stored in The ktlint documentation also suggests overwriting the Given that, I think it makes sense that ktlint should stop including those two paths as default wildcard exceptions. As a temporary workaround, adding an
Also, the second issue does appear genuine: an allowed wildcard import (due to this default, or from |
Tnx for your elaborative analysis. The feature to respect setting If the property is not set explicitly, IntelliJ IDEA allows imports Your approach by setting the property in
Currently, I am working on a new codestyle
|
Closed as follow-up issues are created. |
Expected Behavior
When
java.util.*
is included as a wildcard import, it should trigger the warning forno-wildcard-imports
. When none of the classes in that package are used (bothno-wildcard-imports
andno-unused-imports
rules apply), then at least one ofno-wildcard-imports
orno-unused-imports
should be triggered.Observed Behavior
When
java.util.*
is included as a wildcard import, it triggers no warnings forno-wildcard-imports
. When no classes from the package are used, it also does not trigger ano-unused-imports
warning.Changing to a specific class like
java.util.UUID
produces the expectedno-unused-imports
, and a different wildcard likejavax.net.*
orjava.time.*
produces the expectedno-wildcard-imports
. Also, moving thejava.util.*
to above a different import produces the expectedimport-ordering
.Screenshots
Showing error case (false negative with incorrect build success):
Similar but different cases without error (correctly failing):
Steps to Reproduce
Add
java.util.*
as an import in the correct ordering, run ktlint.Your Environment
.editorconfig
settings: no file, defaults onlyThe text was updated successfully, but these errors were encountered: