ndmitchell / weeder

Detect dead exports or package imports
BSD 3-Clause "New" or "Revised" License
124 stars 8 forks source link

weeder as library #37

Closed sirlensalot closed 6 years ago

sirlensalot commented 6 years ago

The current recommendation to use weeder via a downloaded travis.sh script (for travis) and to use a nightly stack build for local installation is prone to build instability if developers do not maintain a regular process of re-installing weeder.

I have solved this problem with hlint by importing it as a library and running it as a test, as seen here: https://github.com/kadena-io/pact/blob/master/tests/HlintSpec.hs . This way the hlint version can be managed and upgraded from the cabal file, nobody ever "forgets" to run hlint, and CI integration is solved.

Weeder however does not export a library so it is not possible to work with it this way. Happy to provide a PR for this.

ndmitchell commented 6 years ago

If people want it use it that way, I have no objection. Just - main :: [String] -> IO () ?

sirlensalot commented 6 years ago

More like hlint, weeder :: [String] -> IO [Result], with main calling that

ndmitchell commented 6 years ago

The problem is that [Result] is really a tree, so it's a much richer structure than HLint where the hints really are a list. Any structure I give is then locked down in an API, so really want to expose as little as possible.

sirlensalot commented 6 years ago

Well, the real goal is to pass or fail, so a Bool result is good too.

ndmitchell commented 6 years ago

Int for number of non-ignored errors is just as easy - I think I currently spit that out as the exit code. Sounds like we have a plan. I'd welcome a PR, otherwise it might take a moderate while.

sirlensalot commented 6 years ago

Note: weeder just does exitFailure with no special code, so my PR returns a Bool.

ndmitchell commented 6 years ago

Fixed in #39.