dependency-analysis-gradle-plugin
dependency-analysis-gradle-plugin copied to clipboard
Ignoring unused annotation processors causes a new warning about unused kapt plugin
Build scan link
Plugin version 1.2.1
Gradle version
7.4.2
(Optional) Android Gradle Plugin (AGP) version
reason output for bugs relating to incorrect advice
Describe the bug
I had a false positive warning about unused annotation processors, so I wanted to ignore them by:
onUnusedAnnotationProcessors {
severity("fail")
exclude("com.airbnb.android:epoxy-processor", "com.google.dagger:hilt-compiler") // False positives
}
After this change, I don't get the warnings anymore, but a new item popped up:
Unused plugins that can be removed:
kotlin-kapt: this project has the kotlin-kapt (org.jetbrains.kotlin.kapt) plugin applied, but there are no used annotation processors.
To Reproduce Steps to reproduce the behavior:
- Have a warning about an unused annotation processor
- Add an exclusion for that kapt dependency
- Re-run analysis
Expected behavior Missing warning about the dependency, without new warnings appearing
Additional context
Thanks for the report!
Do you happen to have a reproducer? I'm surprised that the unused plugin advice only appears once you exclude the warnings about unused annotation processors. The former is caused by this.
There is no strong relationship between the dependency advice (which includes unused annotation processors) and unused plugin advice; they're independent.
I see, thank you for the context and explanation. Maybe it's a false alarm then, connecting the two seemed logical when I noticed it first.
By the way, I was working on this PR when encountered this "bug". Any tips how to debug this further?
I noticed you have this
onUsedTransitiveDependencies {
// Transitively used dependencies that should be declared directly
severity("ignore")
}
That can lead to advice that seems like false positives but is actually accurate. If you remove a dependency, you may also be removing all of its transitive dependencies if it was the only one supplying them. And if you are using one of those transitives, then your project may no longer compile. Then, you might think "oh, that advice that such-and-such a dependency is unused was just a false positive, I should filter it out."
The other thing you can do to "debug" the advice is to use the reason task. For example:
./gradlew :library:jsonviewer:reason --id org.json:json
The output of that is often illuminating.
If you have any specific questions, feel free to ask here. It's hard to provide general advice other than what I just gave.
Duplicate: https://github.com/autonomousapps/dependency-analysis-android-gradle-plugin/issues/778