krakjoe / tombs

Detect unused code in production
Other
433 stars 20 forks source link

Be able to restrict collection to files under a path #1

Closed lyrixx closed 5 years ago

lyrixx commented 5 years ago

pcov has a configuration directive to "restrict collection to files under this path". This is really useful to exclude vendor & co.

I would be nice to have such option in tombs too.

WDYT?

andreasschroth commented 5 years ago

Would be super useful! 👍

krakjoe commented 5 years ago

Is tombs.namespace not sufficient ?

lyrixx commented 5 years ago

:man_facepalming: I missed it. Sorry for the noise!

francislavoie commented 5 years ago

A project of mine has a ton of non-namespaced code (legacy stuff). Excluding by path rather than namespace would be helpful I think.

krakjoe commented 5 years ago

To be clear, tombs.namespace can be taken to mean something like tombs.prefix, so that even legacy namespaced code named like VendorClass or DomainClass can be set Vendor or Domain respectively.

Does that make it a bit better ?

There are subtle differences between the pcov.directory/exclude settings and tombs.namespace.

For PCOV, these settings are mostly about cutting considerable overhead. The otherwise potentially expensive checks (file name comparisons) are made acceptable using short circuit tables (they are only performed once).

For Tombs, namespace is about setting the pace, not really cutting overhead (although it obviously may cut overhead). When you first run Tombs on your application you will be bombarded with more information than you can reasonably process [1]. "Process" here might mean something as drastic as deleting code, so it must happen reasonably. Unlike pcov.directory which is a hint about the root of a project, tombs.namespace should be considered a very specific target - in other words, it would not be reasonable to set pcov.directory to /path/to/root/src/Vendor/Domain/Thing, it would only serve to waste time. However, it's very reasonable to set tombs.namespace to Vendor\Domain\Thing.

[1] Possibly in the order of thousands of records, where each record represents, potentially, work for a human. Coordinating that kind of work, for humans, is a daunting task.