unused_function.ex (956B)
1 defmodule Dialyxir.Warnings.UnusedFunction do 2 @moduledoc """ 3 Due to issues higher in the function or call stack, while the 4 function is recognized as used by the compiler, it will never be 5 recognized as having been called until the other error is resolved. 6 7 ## Example 8 9 defmodule Example do 10 def ok() do 11 raise "error" 12 13 unused() 14 end 15 16 defp unused(), do: :ok 17 end 18 """ 19 20 @behaviour Dialyxir.Warning 21 22 @impl Dialyxir.Warning 23 @spec warning() :: :unused_fun 24 def warning(), do: :unused_fun 25 26 @impl Dialyxir.Warning 27 @spec format_short([String.t()]) :: String.t() 28 def format_short(args), do: format_long(args) 29 30 @impl Dialyxir.Warning 31 @spec format_long([String.t()]) :: String.t() 32 def format_long([function, arity]) do 33 "Function #{function}/#{arity} will never be called." 34 end 35 36 @impl Dialyxir.Warning 37 @spec explain() :: String.t() 38 def explain() do 39 @moduledoc 40 end 41 end