Insolita / unused-scanner

Detect unused composer dependencies
MIT License
429 stars 38 forks source link

False positive #14

Closed b1rdex closed 5 years ago

b1rdex commented 5 years ago

I have following code and scanner still reports matthiasmullie/minify is not used. If I replace use with use MatthiasMullie\Minify\JS and call with new JS then problem gone. But IMO this still should be fixed as example is valid php code.

<?php

declare(strict_types=1);

namespace Sp\Minifier;

use MatthiasMullie\Minify;

class MinifyJSMinifier implements MinifierInterface
{
    public function minify(string $pathFrom, string $pathTo)
    {
        $minifier = new Minify\JS($pathFrom);
        $minifier->minify($pathTo);
    }
}
Insolita commented 5 years ago

It may be not so simple for resolve. If we start to check partial namespaces, we may got false results from other side. I not sure that can fix it soon.

Firstly for same non-trivial cases, you can skip checking this package via skipPackages option in configuration file

Next way - is to write own matching function - in option customMatch in configuration file, that can solve this problem. And if you done it and it will be universal for other same cases - you can share result or make PR