Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unused Callbacks #7

Closed
elbrujohalcon opened this issue Jul 25, 2022 · 0 comments
Closed

Unused Callbacks #7

elbrujohalcon opened this issue Jul 25, 2022 · 0 comments
Assignees
Labels
rule Idea for a rule
Milestone

Comments

@elbrujohalcon
Copy link
Collaborator

Rule

A rule to detect unused callbacks.
This rule will check all callbacks defined in a module and find those not used anywhere in the module itself.

It will emit a warning if it can't find the callback's atom name 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 because Erlang has many ways to call a function (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).

Example

defmodule BadBeh do
  @callback used() :: term()
  @callback unused() :: term()
  def use(mod) do
    mod.used()
  end
end

Meandro should emit a warning about the second callback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule Idea for a rule
Projects
None yet
Development

No branches or pull requests

1 participant