-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the ability to ignore weeds #58
base: master
Are you sure you want to change the base?
Conversation
This is currently in limbo pending support from users. I thought I needed this, turns out I don't. But maybe others do? |
I've "just" started using weeder for my personal projects, so I don't know yet :) |
Work codebase is 500kloc and we have several example projects that aren't roots and I would like to ignore. |
Yes, this feature would be useful. |
For haskell/cabal, it might help there being able to ignore
|
@ocharles I definitely need this for false positives such as TH splices. In fact, the last three times I tried using weeder, I decided not to because I couldn't ignore false-positives :P |
I’ve run into a similar use case for ignoring instances. I have root-instances = [
{ class = '''^Data\.Foldable\.Foldable$''' },
{ class = '''^Data\.Traversable\.Traversable$''' },
{ class = '''^GHC\.Base\.Functor$''' },
{ class = '''^GHC\.Classes\.Eq$''' },
{ class = '''^GHC\.Classes\.Ord$''' },
{ class = '''^GHC\.Generics\.Generic$''' },
{ class = '''^GHC\.Generics\.Generic1$''' },
{ class = '''^GHC\.Read\.Read$''' },
{ class = '''^GHC\.Show\.Show$''' },
] which generally works well. But if I have something like data UnusedType = UnusedConstructor
deriving (Eq, Ord, Read, Show) then I think that With the current impl (at least 2.8.0), the following configuration type-class-roots = true
unused-types = true doesn’t actually warn about many unused types, because they tend to have My workaround is to run Weeder, make sure it’s clean, then remove However, ignoring instances also causes any functions that exist only to be called by those instances to now be labeled as weeds, but I think this is a minor issue. Similarly, to “ignore” tests and benchmarks, I do the following stack clean
stack build --test --bench --haddock --no-run-benchmarks --no-run-tests
weeder
# ensure everything is clean
stack clean
stack build
weeder
# output now contains types and terms in the “core” code that are only used by tests or benchmarks. I partition these results into two groups – one is dead code that is tested, and so I remove the code & corresponding tests. The other group is testing/benchmarking code that should be moved to the test modules instead of in the “core” code. I think there may be ways to identify these more subtle cases (e.g., explicitly calling out tests that refer to otherwise dead code), but having an ignore mechanism would be a great first step. But, per my examples above, just having an |
Fixes #56