Go to file
Joshua Clayton 0d2470815d Simplify parsing and caching of results
Why?
====

Parsec is overkill when all that's really needed is splitting on
semicolons and converting a string to a non-negative Int.

One side-effect of this is to convert the caching mechanism from flat
text to CSV, with cassava handling (de-)serialization.

Additional
==========

Introduce ReaderT to calculate sha once per cache interaction

Previously, we were calculating the fingerprint (SHA) for match results
potentially twice, once when reading from the cache, and a second time
if no cache was found. This introduces a ReaderT to manage cache
interaction with a single fingerprint calculation.

This also abstracts what's being cached to only care about the fact that
the data can be converted to/from csv.
2016-05-26 21:37:11 -04:00
app Simplify parsing and caching of results 2016-05-26 21:37:11 -04:00
data Rails allowed terms covering inflections, concerns, rendering 2016-05-22 07:51:11 -04:00
src/Unused Simplify parsing and caching of results 2016-05-26 21:37:11 -04:00
test Simplify parsing and caching of results 2016-05-26 21:37:11 -04:00
.gitignore Ignore tmp 2016-05-01 05:25:50 -04:00
.travis.yml Test unused on TravisCI 2016-05-11 23:09:35 -04:00
LICENSE Initial 2016-04-28 05:37:06 -04:00
NEWS Bump version to 0.2.0.0 2016-05-22 06:15:00 -04:00
README.md Fix wording around how unused finds tokens to work with 2016-05-23 05:02:54 -04:00
Setup.hs Initial 2016-04-28 05:37:06 -04:00
stack.yaml Initial 2016-04-28 05:37:06 -04:00
unused.cabal Simplify parsing and caching of results 2016-05-26 21:37:11 -04:00

Unused Build Status

A command line tool to identify unused code.

Image of Unused Output

"What kinds of projects can I used it on?"

Anything.

Yes, literally anything.

It's probably best if you have a ctags file it can read from (it looks in .git, tmp, and the root directory for a tags file), but if you have another way to pipe a bunch of methods/functions/classes/modules/whatever in, that works too.

Right now, there are some special cases built in for Rails and Phoenix apps (specifically, assumptions about what's fine to only have one reference to, e.g. Controllers in Rails and Views in Phoenix), but it'll work on Rubygems, Elixir packages, or anything else.

That said, be confident the code you're removing won't break your program. Especially with projects built in Ruby, Elixir, or JavaScript, there are ways to dynamically trigger or define behavior that may be surprising. A test suite can help here, but still cannot determine every possible execution path.

Installing

You can install my formulae via Homebrew with brew tap:

brew tap joshuaclayton/formulae

Next, run:

brew install unused

Alternatively, you can install by hand.

Installing by hand

This project uses Haskell and Stack.

Once you have these tools installed:

stack setup
stack install

This will generate a binary in $HOME/.local/bin; ensure this directory is in your $PATH.

Using Unused

unused attempts to read from common tags file locations (.git/tags, tags, and tmp/tags).

In an application where the tags file exists, run:

unused

If you want to specify a custom tags file, or load tokens from somewhere else, run:

cat .custom/tags | unused --stdin

To view more usage options, run:

unused --help

Requirements

Unused leverages Ag to analyze the codebase; as such, you'll need to have ag available in your $PATH. This is set as an explicit dependency in Homebrew.

Testing

To run the test suite, run:

stack test

License

Copyright 2016 Josh Clayton. See the LICENSE.