Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composer virtual packages are reported as ignored #93

Closed
icanhazstring opened this issue Aug 7, 2020 · 4 comments
Closed

Composer virtual packages are reported as ignored #93

icanhazstring opened this issue Aug 7, 2020 · 4 comments
Labels
bug Something isn't working good first issue Good for newcomers hacktoberfest

Comments

@icanhazstring
Copy link
Member

icanhazstring commented Aug 7, 2020

Describe the bug

Running composer unused in a library that requires a virtual package (e.g. psr/log-implementation) composer unused is obviously not able to locate the package. Packages with the -implementation suffix should not be reported at all.

Additional information

https://devedge.wordpress.com/2014/09/27/composer-and-virtual-packages/
https://matthiasnoback.nl/2014/10/composer-provide-and-dependency-inversion/

As the excludePackage feature was added back again with #222.
This issue can utilize this implementation to actually match packages ending with -implementation to be ignored as well.

This could be done somewhere around here:
https://github.com/composer-unused/composer-unused/blob/main/src/Command/Handler/CollectFilteredDependenciesCommandHandler.php#L17

@icanhazstring icanhazstring added the bug Something isn't working label Aug 7, 2020
@icanhazstring icanhazstring changed the title composer virtual packages are reported as ignored Composer virtual packages are reported as ignored Aug 7, 2020
@icanhazstring
Copy link
Member Author

related to: #217

@markuspoerschke
Copy link

markuspoerschke commented Oct 13, 2021

I tested this bug and I get the following output:

❯ php vendor/bin/composer-unused


Loading packages
----------------

 4/4 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 ! [NOTE] Found 2 package(s) to be checked.                                                                             

Scanning files from basedir /Users/markus.poerschke/Development/Keks/composer-unused-test
-----------------------------------------------------------------------------------------

 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

Results
-------

Found 0 used, 2 unused and 2 ignored packages

 Used packages

 Unused packages
 ✗ eluceo/ical
 ✗ psr/log

 Ignored packages
 ○ icanhazstring/composer-unused (Invalid package type)
 ○ psr/log-implementation (Unable to locate package)

My example project: https://github.com/markuspoerschke/composer-unused-test/tree/issue-93

git clone --branch issue-93 https://github.com/markuspoerschke/composer-unused-test.git
cd composer-unused-test
composer install
php vendor/bin/composer-unused 

Since the package is reported as ignored, I think this issue can be closed.

@icanhazstring
Copy link
Member Author

Packages with the -implementation suffix should not be reported at all.

No, they should not be reported at all. As they impose a requirement for the using application and do not add a "real" dependency

@icanhazstring
Copy link
Member Author

Solved with #223

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers hacktoberfest
Projects
None yet
Development

No branches or pull requests

2 participants