bnjbvr/cargo-machete

Add an option skip analyzing a directory

Closed this issue · 2 comments

Context

When running trybuild tests, that library creates new crates under target/tests directory. Unfortunately, it does it without caring to remove unused dependencies; thus, we get a warning from cargo-machete.

Summary

I was surprised to discover cargo-machete looks into target/ dir. We could have a CLI option or better a knob that we could specify via a config file or workspace-level metadata to skip checking some directories.

Thanks for opening an issue, sounds like a great idea.

Would you need to specify every possible target/ directory, or just a specific one?

Asking because cargo-machete can analyze a directory that contains subdirectories which are crates, so if you need to ignore all the target/ directories in every such subdirectory, that makes things slightly more tricky (would need some kind of template path to ignore).

Or, we make it so that cargo-machete ignores target/ directories when scanning for crates to analyze. After all, it sounds unlikely there'd be anything interesting to analyze in there...

I think the industry standard for specifying ignored paths is using glob patterns.
Also, it is often seen that tools like this that operate on source code even automagically read .gitignore file which is reasonable in 99% of cases. I believe we could support reading .gitignore as an opt-in option as well.

Regarding my case, I would prefer to ignore the entire /target directory and that's it.

P.S. sorry for late response