2016-05-12 06:24:42 +03:00
|
|
|
# Unused [![Build Status](https://travis-ci.org/joshuaclayton/unused.svg?branch=master)](https://travis-ci.org/joshuaclayton/unused)
|
2016-04-28 12:37:06 +03:00
|
|
|
|
|
|
|
A command line tool in Haskell to identify unused code.
|
|
|
|
|
2016-05-11 13:34:16 +03:00
|
|
|
![Image of Unused Output](http://i.giphy.com/3oEjHGgyV2EDdy1Ogw.gif)
|
2016-05-11 00:24:28 +03:00
|
|
|
|
2016-05-12 05:29:29 +03:00
|
|
|
## Installing
|
|
|
|
|
|
|
|
### Homebrew
|
|
|
|
|
|
|
|
You can install [my formulae] via [Homebrew] with `brew tap`:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
brew tap joshuaclayton/formulae
|
|
|
|
```
|
|
|
|
|
|
|
|
Next, run:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
brew install unused
|
|
|
|
```
|
|
|
|
|
|
|
|
[my formulae]: https://github.com/joshuaclayton/homebrew-formulae
|
|
|
|
[Homebrew]: http://brew.sh/
|
|
|
|
|
|
|
|
Alternatively, you can install by hand.
|
|
|
|
|
|
|
|
### Stack
|
|
|
|
|
|
|
|
This project uses [Haskell] and [Stack].
|
|
|
|
|
|
|
|
Once you have these tools installed:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
stack setup
|
|
|
|
stack install
|
|
|
|
```
|
|
|
|
|
|
|
|
This will generate a binary in `$HOME/.local/bin`; ensure this directory is in
|
|
|
|
your `$PATH`.
|
|
|
|
|
|
|
|
[Haskell]: https://www.haskell.org
|
|
|
|
[Stack]: http://www.haskellstack.org
|
|
|
|
|
2016-04-29 12:55:09 +03:00
|
|
|
## Using Unused
|
|
|
|
|
|
|
|
`unused` reads from a pipe expecting a series of tokens to search the codebase
|
|
|
|
for.
|
|
|
|
|
|
|
|
This could be done with `echo`:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
echo "module\nimport" | unused
|
|
|
|
```
|
|
|
|
|
|
|
|
Or pulling in a ctags file:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
cat .git/tags | cut -f1 | sort -u | unused
|
|
|
|
```
|
|
|
|
|
|
|
|
My end goal is to have the latter rolled up into unused itself, so you can
|
|
|
|
navigate to a directory, run `unused`, and everything works as expected.
|
|
|
|
|
2016-05-11 18:15:18 +03:00
|
|
|
## Requirements
|
|
|
|
|
|
|
|
Unused leverages [Ag](https://github.com/ggreer/the_silver_searcher) to
|
|
|
|
analyze the codebase; as such, you'll need to have `ag` available in your
|
2016-05-12 05:29:29 +03:00
|
|
|
`$PATH`. This is set as an explicit dependency in Homebrew.
|
2016-04-29 12:55:09 +03:00
|
|
|
|
2016-05-11 04:03:56 +03:00
|
|
|
## Testing
|
|
|
|
|
|
|
|
To run the test suite, run:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
stack test
|
|
|
|
```
|
|
|
|
|
2016-04-28 12:37:06 +03:00
|
|
|
## License
|
|
|
|
|
|
|
|
Copyright 2016 Josh Clayton. See the [LICENSE](LICENSE).
|