Skip to content

build: add a lint guard for inline fully-qualified names (custom detekt rule) #801

Description

@rustyrazorblade

Follow-up from #794 (merged). That PR removed ~28 inline fully-qualified type names in favor of imports, but no lint rule prevents recurrence.

Finding

There is no built-in detekt 1.23.8 or ktlint rule that flags an inline FQN used where an import would do. A real guard needs a custom detekt ruleset module (jar + RuleSetProvider + META-INF/services), wired type-resolution-aware against the existing detektMain/detektTest/detektIntegrationTest tasks so it can distinguish a genuine same-name collision (which must stay FQN'd) from a shortenable FQN — plus its own tests and a baseline for the legitimate collision cases.

Legitimate FQNs that a rule must NOT flag (from #794)

  • project DockerException vs dockerjava DockerException (Docker.kt, RetryUtil.kt, ContainerExecutor.kt, ContainerExecutorTest.kt)
  • fabric8 Container vs testcontainers Container (K8sServiceIntegrationTest.kt)
  • java.lang.Long/Double/Float/Boolean::class.java (McpToolRegistry.kt)
  • ResultCallback.Adapter<Frame> (DockerTest.kt — owned by build: treat Kotlin compiler warnings as errors (and fix the fallout) #780)

Recommendation

Worthwhile only if the pattern recurs. If it does, build the custom rule as above. Low priority until then.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions