W0092 - Unused Exported Type
Error
-module(main).
-export_type([foo/0]).
-type foo() :: ok.
%% ^^^ warning: W0092: Exported type foo/0 is not used anywhere in the codebase.
Explanation
The type foo/0 is exported, but nothing references it: no spec, type,
opaque, record field or callback in its own module or in any other module of
the project. References from its own definition (a recursive type) and from
other types of the module that are themselves unused do not count, so a group
of types that only refer to each other is reported together.
This linter is a companion to the Erlang/OTP compiler's unused_type warning
(type foo() is unused). The compiler only flags local types: it counts an
-export_type entry as a use, since other modules could reference the type,
so finding out whether they do needs a project-wide search. This linter only
checks exported types, so the two never report the same type.
To fix this warning, remove the type and its -export_type entry, or use it
where it was meant to be used.
How the Linter Works
ELP reads the type references in the type definitions, specs, callbacks,
records and type casts ((Expr :: Type) and (Expr :> Type), as eqWAlizer's
cast macros expand to) of the module. A type referenced outside a type
definition is used, and so is every type its definition references. For the
exported types that are still unused, ELP then looks for module:type()
references in the other files of the project that mention the module name:
Erlang has no type imports, so a reference from another module always names
it.
Types defined in the eqwalizer_types module, which eqWAlizer reads as
overrides of the types of other modules, and types defined in header files are
not checked.