composer-unused / composer-unused

Show unused composer dependencies by scanning your code
MIT License
1.53k stars 54 forks source link

Exclude aren't working or I doing something wrong #625

Closed nohnaimer closed 8 months ago

nohnaimer commented 8 months ago

I add a package to the exceptions and get this package like a zombie

Снимок экрана 2024-02-22 в 18 28 17

I try with --excludePackage= same result.

Configuration with exclude:

<?php

declare(strict_types=1);

use ComposerUnused\ComposerUnused\Configuration\Configuration;
use ComposerUnused\ComposerUnused\Configuration\NamedFilter;

return static function (Configuration $config): Configuration {
    return $config
        /** @see environments/prod/console/config/main-local.php */
        ->addNamedFilter(NamedFilter::fromString('codemix/yii2-streamlog'))
        /** @see environments/prod/common/config/main-local.php */
        ->addNamedFilter(NamedFilter::fromString('nohnaimer/yii2-sentry'))
        ->addNamedFilter(NamedFilter::fromString('league/flysystem-aws-s3-v3'))
        /** @see \kartik\date\DatePicker::validateConfig */
        ->addNamedFilter(NamedFilter::fromString('kartik-v/yii2-field-range'));
};

Maybe I du something wrong?

Thank you for any help!

icanhazstring commented 8 months ago

Hi. You have 4 named filters which show the package was ignored.

But you also defined two Named filters for a package that is not required. So it is marked as "zombie".

icanhazstring commented 8 months ago

Also you could configure composer-unused to look into other places than your composer autoload directories.

So if you have some PHP files in other folders you can add them to be scanned for used symbols as well. Then you might not need to ignore some packages.

See the readme under "Additional files to be parsed"

The dependency name would be the "name" property of your composer.json to associate the additional files with your root package.

nohnaimer commented 8 months ago

Thank you for help. A strange situation, but the packets did not need to be ignored - now the check passes. Here is the working config:

<?php

declare(strict_types=1);

use ComposerUnused\ComposerUnused\Configuration\Configuration;
use ComposerUnused\ComposerUnused\Configuration\NamedFilter;

return static function (Configuration $config): Configuration {
    return $config
        /** @see environments/prod/common/config/main-local.php */
        ->addNamedFilter(NamedFilter::fromString('league/flysystem-aws-s3-v3'))
        /** @see \kartik\date\DatePicker::validateConfig */
        ->addNamedFilter(NamedFilter::fromString('kartik-v/yii2-field-range'));
};

Thanks again.