https://kotlinlang.org logo
#detekt
Title
g

gammax

09/02/2019, 9:37 AM
c

Czar

09/02/2019, 9:40 AM
Since test passes, I probably have to implement a repro-project 😞 I miss checkstyle 🙂
g

gammax

09/02/2019, 9:40 AM
Yeah having a repro project would be ideal 🙂
c

Czar

09/02/2019, 9:47 AM
Ha, interesting, if I remove my config, it works. I mean if I don't use detekt.yml at all
g

gammax

09/02/2019, 9:47 AM
Are you on the latest version of Detekt?
c

Czar

09/02/2019, 9:48 AM
1.0.0
g

gammax

09/02/2019, 9:48 AM
Please go with 1.0.1. Also make sure you’re on Kotlin 1.3. 50
c

Czar

09/02/2019, 9:50 AM
1.3.50, it's too new to be used in prod unfortunately
Ok, I verified with 1.0.1 issue is still present, both with Kotlin 1.3.41 and 1.3.50. I also found out why it "works" without my config. That's only because I have 0 permitted issues in it, in fact the import warning is still issues without config it just does not fail the check.
g

gammax

09/02/2019, 9:53 AM
The only way to circumvent this problem I’ve found is to disable the check completely:
Please note that you are mixing up two rules:
NoWildcardImports
and
WildcardImport
NoWildcardImports
is a
style
rule and a wrap of a KtLint rule. Documentation of the rule is here: https://arturbosch.github.io/detekt/formatting.html#nowildcardimports
c

Czar

09/02/2019, 9:54 AM
Aren't they supposed to go together?
g

gammax

09/02/2019, 9:54 AM
WildcardImport
is a
formatting
rule from Detekt. Documentation is here: https://arturbosch.github.io/detekt/style.html#wildcardimport
c

Czar

09/02/2019, 9:55 AM
That's quite counterintuitive. So basically if I want to use WildcardImport rule I have to disable NoWildcardImports rule?
g

gammax

09/02/2019, 9:56 AM
They’re independent. You can use either one or the other or both.
c

Czar

09/02/2019, 9:58 AM
If
NoWildcardImports
is not disabled
WildcardImport
exclusions are completely ignored by detekt and it is failing
NoWildcardImports
check on
java.util.*
That is why test passes, it checks
WildcardImport
in isolation
g

gammax

09/02/2019, 10:00 AM
🤔 Looking at the code of the two rules, I don’t see any connections between the two
c

Czar

09/02/2019, 10:01 AM
and that's exactly the problem,
NoWildcardImport
effectively tramples
WildcardImport
Maybe it's more of a documentation issue, it should be stated somewhere, that it does not matter what exclusions are configured for the latter, if the former is enabled. If one needs more permissive check,
NoWildcardImport
should be disabled and
WildcardImport
may then do the checking according to its configuration
g

gammax

09/02/2019, 10:12 AM
I see your point. I think the confusion arise from the fact that Detekt wraps over KtLint and the ktlint rule (
NoWildcardImport
) is not configurable.
Anyway I edited my messages above with links to the documentation 👍
s

schalkms

09/02/2019, 7:00 PM
@Czar thanks for submitting the PR
7 Views