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

False positive on a suggestion to remove the a library of which I am only using its inline functions.

Open StylianosGakis opened this issue 1 year ago • 4 comments

In a module, I'm using the Slimber library.

When running ./gradlew foo:reason --id com.github.PaulWoitaschek:Slimber I get the suggestion to

You asked about the dependency 'com.github.PaulWoitaschek:Slimber:1.0.7'.
You have been advised to remove this dependency from 'implementation'.

However I am in fact using this dependency, specifically the function e.

What I see here is that since that one is an inline function, the analysis tool only sees that I am using the Timber function directly and never sees me calling anything from Slimber itself.

In fact, when I add a line which uses this e instead, which is not inline, I am no longer suggested to remove the dependency.

So this suggestion doesn't recognize this situation and suggests me to remove it even though it's not what I need.

Do you think that there's some way for this tool to figure out cases like these? If not, do you have any idea on how to either silence this warning or in general do something about it?

StylianosGakis avatar Oct 03 '22 13:10 StylianosGakis

Thanks for the issue. This plugin already supports detection of inline members from Kotlin libraries, using a couple of heuristics. You may have run into an edge case where the heuristics are failing. Please supply a minimal reproducer and I'll be happy to take a look.

autonomousapps avatar Oct 10 '22 20:10 autonomousapps

Absolutely! Took the auto-generated project from AS and simply added this plugin and slimber here https://github.com/StylianosGakis/dependency-analysis-slimber-reproducer.

If you clone this, sync and simply run ./gradlew :app:projectHealth you'll get the suggestion of:

> Task :app:projectHealth
Unused dependencies which should be removed:
  implementation 'androidx.core:core-ktx:1.9.0'
  implementation 'com.github.PaulWoitaschek:Slimber:1.0.7'

Transitively used dependencies that should be declared directly as indicated:
  implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
  implementation 'com.jakewharton.timber:timber:4.6.0'

Despite using it here.

If you instead use any other function from in there which is not inline, like I'm doing here then the plugin correctly no longer suggests slimber's removal. Comment/uncomment to reproduce yourself.

Is this sufficient, can I help in some other way?

StylianosGakis avatar Oct 11 '22 12:10 StylianosGakis

It seems that this issue is now fixed with version 1.29.0.

MGaetan89 avatar Jan 19 '24 14:01 MGaetan89

I wasn't aware of any change in 1.29.0 that would address this issue! @StylianosGakis can you confirm?

autonomousapps avatar Jan 19 '24 21:01 autonomousapps

I'm going to close this for now. If it still exists, please re-open.

autonomousapps avatar May 01 '24 21:05 autonomousapps