composer-unused: BUG: Package Functions
Describe the bug
Composer Unused does not seem to detect a package as a dependency if the source repo uses a function that is defined in that package.
Error dump
Live example in Actions output: https://github.com/tattersoftware/codeigniter4-files/runs/4347265699?check_suite_focus=true
Run composer-unused -vvv --profile --ansi --no-interaction --no-progress --excludePackage=php
Running 2.1.12 (2021-11-09 16:02:04) with PHP 8.0.13 on Linux / 5.11.0-1021-azure
Loading packages
----------------
! [NOTE] Found 7 package(s) to be checked.
Scanning files from basedir /home/runner/work/codeigniter4-files/codeigniter4-files
-----------------------------------------------------------------------------------
Results
-------
Found 4 used, 3 unused and 5 ignored packages
Used packages
✓ tatter/exports
✓ tatter/permits
✓ tatter/settings
✓ tatter/thumbnails
[18.7MiB/0.38s] Memory usage: 18.68MiB (peak: 18.97MiB), time: 0.38s
Unused packages
✗ tatter/alerts
✗ tatter/assets
✗ tatter/audits
Ignored packages
○ php (Package excluded by cli/config)
○ components/jquery (Package provides no namespace)
○ enyo/dropzone (Package provides no namespace)
○ fortawesome/font-awesome (Package provides no namespace)
○ twbs/bootstrap (Package provides no namespace)
Error: Process completed with exit code 1.
In this example tatter/alerts
defines a helper function alerts()
(https://github.com/tattersoftware/codeigniter4-alerts/blob/develop/src/Helpers/alerts_helper.php) which is used by the source repo’s controller (https://github.com/tattersoftware/codeigniter4-files/blob/0ee8595a60394cebeb42ab11a3e095042b0ebd5e/src/Controllers/Files.php#L374).
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 25 (25 by maintainers)
Feel free to add a feature request discussion 😉
So we can close this one for now?
I mean, technically it is correct. It is just odd that it picks up the helper file functions without their addition to Composer’s
files
array. I’m fine to roll with it for now and just keep an eye on changes.FWIW for some packages with helper files I will probably opt to ignore them rather than have them autoloaded every time; in some scenarios that is quite useful but in others the helper function are mostly “optional” and rarely used. It’s too bad there’s not an “autoload-dev” files section. If you every consider adding external Config files similar to PHPStan or CS Fixer, this would be on my request: additional files to load before scanning.