warning.ex (1199B)
1 defmodule Dialyxir.Warning do 2 @moduledoc """ 3 Behaviour for defining warning semantics. 4 5 Contains callbacks for various warnings 6 """ 7 8 @doc """ 9 By expressing the warning that is to be matched on, error handling 10 and dispatching can be avoided in format functions. 11 """ 12 @callback warning() :: atom 13 14 @doc """ 15 The default documentation when seeing an error without the user 16 otherwise overriding the format. 17 """ 18 @callback format_long([String.t()] | {String.t(), String.t(), String.t()} | String.t()) :: 19 String.t() 20 21 @doc """ 22 A short message, often missing things like success types and expected types for space. 23 """ 24 @callback format_short([String.t()] | {String.t(), String.t(), String.t()} | String.t()) :: 25 String.t() 26 27 @doc """ 28 Explanation for a warning of this type. Should include a simple example of how to trigger it. 29 """ 30 @callback explain() :: String.t() 31 32 @spec default_explain() :: String.t() 33 def default_explain() do 34 """ 35 This warning type does not have an explanation yet. If you have 36 code that causes it, please file an issue or pull request in 37 https://github.com/jeremyjh/dialyxir/issues 38 """ 39 end 40 end