diff --git a/ktlint-ruleset-standard/src/main/kotlin/com/pinterest/ktlint/ruleset/standard/NoWildcardImportsRule.kt b/ktlint-ruleset-standard/src/main/kotlin/com/pinterest/ktlint/ruleset/standard/NoWildcardImportsRule.kt index 42d7bc5331..0c40afa0ea 100644 --- a/ktlint-ruleset-standard/src/main/kotlin/com/pinterest/ktlint/ruleset/standard/NoWildcardImportsRule.kt +++ b/ktlint-ruleset-standard/src/main/kotlin/com/pinterest/ktlint/ruleset/standard/NoWildcardImportsRule.kt @@ -14,8 +14,8 @@ class NoWildcardImportsRule : Rule("no-wildcard-imports") { ) { if (node.elementType == IMPORT_DIRECTIVE) { val importDirective = node.psi as KtImportDirective - val path = importDirective.importPath?.pathStr - if (path != null && !path.startsWith("kotlinx.android.synthetic") && path.contains('*')) { + val path = importDirective.importPath + if (path != null && path.isAllUnder && !path.pathStr.startsWith("kotlinx.android.synthetic")) { emit(node.startOffset, "Wildcard import", false) } } diff --git a/ktlint-ruleset-standard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/NoWildcardImportsRuleTest.kt b/ktlint-ruleset-standard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/NoWildcardImportsRuleTest.kt index f810fe7189..d4e9ff9c9d 100644 --- a/ktlint-ruleset-standard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/NoWildcardImportsRuleTest.kt +++ b/ktlint-ruleset-standard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/NoWildcardImportsRuleTest.kt @@ -16,6 +16,7 @@ class NoWildcardImportsRuleTest { import a.b.c.* import a.b import kotlinx.android.synthetic.main.layout_name.* + import foo.bar.`**` """.trimIndent() ) ).isEqualTo(