autonomousapps / autonomousapps/dependency-analysis-gradle-plugin
Duplicate add advice generated for transitive dependency across `implementation` and `testImplementation`
- Dominant language
- Kotlin
- Stars
- 2.2k
- Forks
- 158
- Avg merge
- 16h 25m
- Merged PRs (30d)
- 46
Description
### Contributor Checklist
- [x] I have read the [Contributing guide](https://github.com/autonomousapps/dependency-analysis-gradle-plugin/blob/main/CONTRIBUTING.asciidoc).
- [x] I have read the [Code of Conduct](https://github.com/autonomousapps/dependency-analysis-gradle-plugin/blob/main/CODE_OF_CONDUCT.md).
- [x] No part of this bug report was created with an LLM/AI.
### (Optional) Build scan link
### Plugin version
3.18.0 (latest)
### Gradle version
9.7.0 (latest)
### JDK version
25
### (Optional) Kotlin and Kotlin Gradle Plugin (KGP) version
2.4.10
### (Optional) Android Gradle Plugin (AGP) version
N/A
### (Optional) `reason` output for bugs relating to incorrect advice
```
------------------------------------------------------------
You asked about the dependency ':libraries:ListingModel'.
You have been advised to add this dependency to 'testImplementation'.
You have been advised to add this dependency to 'implementation'.
------------------------------------------------------------
Shortest path from :domains:Search:impl to :libraries:ListingModel for releaseCompileClasspath:
:domains:Search:impl
\--- :libraries:Listing
\--- :libraries:ListingModel
Shortest path from :domains:Search:impl to :libraries:ListingModel for releaseRuntimeClasspath:
:domains:Search:impl
\--- :libraries:Listing
\--- :libraries:ListingModel
Shortest path from :domains:Search:impl to :libraries:ListingModel for releaseUnitTestCompileClasspath:
:domains:Search:impl
\--- :libraries:Listing
\--- :libraries:ListingModel
Shortest path from :domains:Search:impl to :libraries:ListingModel for releaseUnitTestRuntimeClasspath:
:domains:Search:impl
\--- :libraries:Listing
\--- :libraries:ListingModel
Source: release, main
---------------------
* Uses 1 class: [...].listingmodel.ListingType (implies implementation).
Source: release, test
---------------------
* Uses 1 class: [...].listingmodel.ListingType (implies testImplementation).
* Imports 3 constants: [...].listingmodel.ListingType.CAROUSEL, [...].listingmodel.ListingType.LIST, [...].listingmodel.ListingType.MOSAIC (implies testImplementation).
```
### Describe the bug
Add advice is generated for `implementation` and `testImplementation` for a transitive dependency, while only `implementation` should be given.
Adding both of these advice, leads to a new contradicting advice (to remove the `testImplementation` because it is implied by the `implementation`):
```
------------------------------------------------------------
You asked about the dependency ':libraries:ListingModel'.
You have been advised to remove this dependency from 'testImplementation'.
------------------------------------------------------------
Shortest path from :domains:Search:impl to :libraries:ListingModel for releaseCompileClasspath:
:domains:Search:impl
\--- :libraries:ListingModel
Shortest path from :domains:Search:impl to :libraries:ListingModel for releaseRuntimeClasspath:
:domains:Search:impl
\--- :libraries:ListingModel
Shortest path from :domains:Search:impl to :libraries:ListingModel for releaseUnitTestCompileClasspath:
:domains:Search:impl
\--- :libraries:ListingModel
Shortest path from :domains:Search:impl to :libraries:ListingModel for releaseUnitTestRuntimeClasspath:
:domains:Search:impl
\--- :libraries:ListingModel
Source: release, main
---------------------
* Uses 1 class: [..].listingmodel.ListingType (implies implementation).
Source: release, test
---------------------
* Uses 1 class: [..].listingmodel.ListingType (implies testImplementation).
* Imports 3 constants: [..].listingmodel.ListingType.CAROUSEL, [..].listingmodel.ListingType.LIST, [..].listingmodel.ListingType.MOSAIC (implies testImplementation).
```
### To Reproduce
I'll create a reproducer on a fork project.
### Expected behavior
Only the add advice on `implementation` should be given
Contributor guide
Research direction
Start by creating the fork reproducer promised in the issue and inspect the generated dependency advice for the transitive dependency across implementation and testImplementation. Compare the advice with the expected output: only implementation should receive add advice, without subsequent removal advice for testImplementation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100