ComposerRequireChecker icon indicating copy to clipboard operation
ComposerRequireChecker copied to clipboard

Useless dependencies option

Open soullivaneuh opened this issue 7 years ago • 6 comments

It would be a great addition to be able to list useless dependencies. I mean an required dependency with no symbol usage at all.

Of course, it should be optional and the configuration file should accept packages to ignore.

Some packages could just provide configuration file or whatever not related to PHP directly, but used. This case would be a false positive.

soullivaneuh avatar Jan 24 '18 10:01 soullivaneuh

This is problematic due to how composer dependencies work, as sometimes you have to require a dependency, and then a third-party package performs a lookup to see if a certain HTTP client or extension is available, then looks for polyfills and so on.

This means that the useless packages would be filled with potentially dangerous false-positives.

Ocramius avatar Jan 24 '18 10:01 Ocramius

This means that the useless packages would be filled with potentially dangerous false-positives.

That fact makes it perhaps not useful for automation, but yhere could still be an option to request this check on demand - usually the maintainer is going to be able to tell false positives from real ones, so this check could definitely be useful in my opinion.

For example, after a large refactoring, such as splitting off certain members to a separate package - it's often hard to keep track of the dependency changes in that situation.

mindplay-dk avatar Feb 22 '18 12:02 mindplay-dk

This means that the useless packages would be filled with potentially dangerous false-positives.

@mindplay-dk Well explained what I think about that.

This is also why I said the configuration file should accept packages to ignore.

soullivaneuh avatar Feb 22 '18 18:02 soullivaneuh

Duplicate of #14?

MidnightDesign avatar Mar 25 '19 11:03 MidnightDesign

@soullivaneuh Would https://github.com/composer-unused/composer-unused help for your case?

bobvandevijver avatar Mar 06 '21 18:03 bobvandevijver

Would https://github.com/composer-unused/composer-unused help for your case?

I'd recommend that tool, too, even though it is only just starting and has some issues, errors and unresolved edge cases.

I have them both running in an automated job, so using one or two tools is no big deal. And I can imagine that these two tools have way different approaches due to their different nature. Keeping them separate will probably reduce overall complexity. ;)

SvenRtbg avatar May 04 '21 12:05 SvenRtbg