dependency-analysis-gradle-plugin icon indicating copy to clipboard operation
dependency-analysis-gradle-plugin copied to clipboard

Uses of `const val` not detected properly

Open joshfriend opened this issue 10 months ago • 2 comments

Plugin version 2.18.0

Gradle version 8.12.1

JDK version 17

(Optional) Kotlin and Kotlin Gradle Plugin (KGP) version 2.1.20

(Optional) reason output for bugs relating to incorrect advice

------------------------------------------------------------
You asked about the dependency ':utils'.
You have been advised to remove this dependency from 'implementation'.
------------------------------------------------------------

Describe the bug When module :app uses a const val from a named object in :util, and the two projects use the same java package, the usage of the constant from :util is not detected. This is very similar to #1430 but the fix for that looked for the companion object specifically, which is not in play here:

// :util
object Something {
  const val EXAMPLE = "example"
}

// :app
fun main() {
  println(Something.EXAMPLE)
}

To Reproduce In this reproducer, run buildHealth

Expected behavior No advice should be given

Additional context Advice suggests removing :util dependency, which breaks compilation

joshfriend avatar Jun 10 '25 00:06 joshfriend

Thanks for the report.

autonomousapps avatar Jun 10 '25 16:06 autonomousapps

@joshfriend could you re-test this with the latest snapshot?

autonomousapps avatar Aug 08 '25 00:08 autonomousapps