autonomousapps / autonomousapps/dependency-analysis-gradle-plugin
compileOnly: report unused compileOnly dependencies as 'should be removed'
- Dominant language
- Kotlin
- Stars
- 2.2k
- Forks
- 158
- Avg merge
- 16h 25m
- Merged PRs (30d)
- 46
Description
**Is your feature request related to a problem? Please describe.**
If we define dependencies like this but do not use them at all they are not reported.
```
compileOnly("androidx.annotation:annotation")
compileOnly("org.json:json")
```
The plugin currently discards all advices for dependencies declared as `compileOnly`. I think this is the right behavior if it is about cases where the dependencies _could_ be `implementation` or `api`. Because the plugin cannot know, if a dependency is (not) needed at runtime.
However, the plugin would know if the dependency is not needed at compile time. In this case, the dependency can be safely removed altogether and I think the plugin should give that advice.
**Describe the solution you'd like**
The plugin should list `compileOnly` dependencies that are unused in the _Unused dependencies which should be removed_ part of the report.
**Describe alternatives you've considered**
_..._
**Additional context**
A related topic I just thought of (but this is really a very rare case I assume) :
- `compileOnly` dependencies which are detected as _api_ should be recommended as `compileOnlyApi`
- `compileOnlyApi` dependencies which are detected as _implementation_ should be recommended as `compileOnly`
Contributor guide
Research direction
Start by tracing where the plugin filters compileOnly dependency advice and where the “Unused dependencies which should be removed” report section is assembled. Verify behavior for an unused compileOnly dependency; done means it appears in that section without changing advice for compileOnly dependencies that may be needed at runtime.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100