shipmonk-rnd / dead-code-detector

💀 PHP unused code detection via PHPStan extension.
53 stars 5 forks source link

comparison with TomasVotruba/unused-public #5

Closed staabm closed 1 month ago

staabm commented 9 months ago

first let me say thank you for this repo... dead code is a major problem, a lot of people miss :-).

we are currently using https://github.com/TomasVotruba/unused-public which is pretty similar. it would be great to see if there is a major difference between this 2 libs...?


one thing I saw by reading the docs: you are using a NEON based whitelist, while unused-public allows whitelisting by adding a @api annotation at class and/or method level. maybe thats something useful for you as well

janedbal commented 9 months ago

Honestly, I never did any comparison with this library. I'd try that in our huge codebase (where our tool work well), but seeing its readme, I dont really see any entrypoint configuration so I'm not sure where I should place our huge list of all the symfony/doctrine/... methods which are "dead" by design. I cannot really imagine how that might work without that :D


Currently, whitelisting dead methods (ignoring those that are currently dead in the project) is not implemented at all. You can always mark those as "entrypoint" as shown in readme (which is what we currently do).

But I think PHPStan's error identifiers (since 1.11) will be much better option, as those has native backchecking functionality (reports that it is not dead anymore once used).

But, all this is more suitable for applications, not libraries. Libraries typically need something like @api that theoretically may serve as ignorelist. And I'd say, you can use EntrypointProvider for that very easily in current implementation.

janedbal commented 1 month ago

In recent weeks, I made quite major improvements and did the comparison with unused-public. It is now mentioned in readme: https://github.com/shipmonk-rnd/dead-code-detector?tab=readme-ov-file#comparison-with-tomasvotrubaunused-public