venantius / yagni

A Leiningen plugin for finding dead code
Eclipse Public License 1.0
219 stars 10 forks source link

any way for yagni to ignore test files? #38

Closed ags799 closed 5 years ago

ags799 commented 7 years ago

Moved from https://github.com/tolitius/boot-check/issues/10#issuecomment-332260905

Yagni is reporting my test functions as lacking any references and being unused. These errors are red herrings of course. Why would a test function have any references?

I'm using Yagni through boot-check.

Is there a common way to configure Yagni so that it ignores tests? Any help is much appreciated, thanks.

venantius commented 7 years ago

At the moment, no - it shouldn’t be hard to engineer a whitelist or alternative mechanism if you’re so inclined.

venantius commented 7 years ago

Ah, I just looked at the issue. That’s strange. Your test functions shouldn’t be reachable from the graph. I’m not sure why they’re getting picked up.

venantius commented 5 years ago

Returning to this issue - this is an issue with boot-check and not with Yagni. boot-check is being passed a fileset that includes your test directory. It's a problem that should be resolved with them and not here.

More broadly, if you wanted Yagni to only ignore test forms within the test/ directory and to otherwise track other forms...that's probably beyond the scope of this project. Test forms defined with deftest (or other, non-clojure.test forms) are typically just plain functions that have been wrapped with a macro, and consequently there's no easy way for Yagni to know whether something is a test or a utility function.