Credo.Check.Refactor.UnusedPublicFunctions (checkbook v0.0.1)

Basics

This check is disabled by default.

Learn how to enable it via .credo.exs.

This check has a base priority of high and works with any version of Elixir.

Explanation

Public functions that are never called should be considered for removal.

Unused public functions:

  • Increase cognitive load by making the codebase larger than necessary
  • May indicate dead code or incomplete refactoring
  • Can lead to maintenance confusion about what code is actually in use
  • Expose more of the module's API than necessary

Example:

defmodule MyModule do
  def used_function, do: :ok

  # this function is never called
  def unused_function, do: :ok

  defp private_function do
    used_function()
  end
end

The unused_function should be removed if it's no longer needed.

Check-Specific Parameters

There are no specific parameters for this check.

General Parameters

Like with all checks, general params can be applied.

Parameters can be configured via the .credo.exs config file.