Module unused_callbacks

A rule to detect unused callbacks.

Behaviours: hank_rule.

To do


A rule to detect unused callbacks.

This rule will check all callbacks defined in a module and find those that are not used anywhere in the module itself.

It will emit a warning if it can't find the callback's atom name being used anywhere within a module. It will NOT emit a warning if an atom named as a callback is being used, no matter for what that atom is used.

This limitation is due to the fact that there are many ways to call a function in Erlang (particularly when dynamic calls are involved).

The assumption is that if you define a callback for a behavior, your generic module (where the callback is defined) should call that function at some point, using the implementation provided by the specific module (the one that implements the behavior).

To avoid this warning, remove the unused callback definition.


For this rule to apply, it's assumed that callbacks defined for a particular behavior are only used within the same module that defines it. If you define behaviors in your project and you use their callbacks from other modules, you can add an ignore rule in rebar.config for it.

Function Index

ignored/2Rule ignore specifications.

Function Details


ignored(Pattern::hank_rule:ignore_pattern(), Callback::term()) -> boolean()

Rule ignore specifications. Example:

               [all, %% Will ignore all versions of the all callback (i.e. any arity)
                {just, 1} %% Will ignore just(term()) but not just() nor just(_, _) callbacks

Generated by EDoc