Hank - The Oxbow code detector

Hank

This is the main thread for Hank, the Oxbow code detector for Erlang.

Usage

The best way to understand what Hank does is just to use it in your rebar3-managed project, like this…

Add the plugin to your rebar config:

{project_plugins, [rebar3_hank]}

Then just call the plugin directly in an existing application:

$ rebar3 hank # or…
$ rebar3 kiwf # (Kill It With Fire)

That will produce output similar to:

src/lapp.erl:18: maybe_evaluate/3 doesn't need its #2 argument
src/lapp.erl:15: maybe_evaluate/2 doesn't need its #1 argument
src/lapp.erl:5: ?DEFAULT_SAMPLE_RATE is unused
src/lapp.app.src:0: sample_rate is not used anywhere in the code
src/include/header.hrl:2: ?SOME_MACRO/1 is used only at src/lapp.erl
src/my_behaviour.erl:3: Callback process/1 is not used anywhere in the module
src/include/header.hrl:1: ?APP_HEADER is unused
src/main.erl:8: Field color in record state is unused

And you can be 100% sure you can remove all those pieces of dead code from your project.

More Information

If you want to know more, you can read the paper that we wrote with @lauramcastro : https://arxiv.org/pdf/2107.08699
Or you can watch some videos:

7 Likes

The best thing about this tool is that when my 13 year old was talking about how she’d covered oxbow lakes in geography, I was able to explain the programming equivalent. Thanks @elbrujohalcon !

HAHAHA!! It’s also the only part about the tool that my kid (a geography nerd, like his father) understands :slight_smile:

1 Like