Skip to main content

W0081 - Redundant suppression

Examples

Stale code

-module(main).
-export([test/0]).

% elp:ignore W0007
%% ^^^^^ 💡 warning: W0081: Redundant suppression: no `W0007 (trivial_match)` diagnostic in suppressed range
test() ->
ok.

Codeless suppression

-module(main).
-export([test/0]).

% elp:ignore
%%<^^^^^^^^^ 💡 warning: W0081: Redundant suppression: this annotation does not suppress any diagnostic.
test() ->
ok.

Stale code in a multi-code annotation

baz() ->
X = 42,
% elp:ignore W0007 W0006
%% ^^^^^ 💡 warning: W0081: Redundant suppression: no `W0006 (statement_has_no_effect)` diagnostic in suppressed range
X = X. %% W0007 is genuinely suppressed here

Explanation

ELP supports two annotation comments that suppress a single diagnostic on the line immediately following the annotation:

  • % elp:ignore <CODE> — silently ignore the diagnostic.
  • % elp:fixme <CODE> — same as ignore, but typically used to mark technical debt that should be revisited.

This diagnostic flags annotations that do not actually suppress anything in the current configuration. Such annotations rot in the codebase: they mislead reviewers ("why is this ignored?") and can hide the fact that a previously-flagged piece of code is now clean.

When specific codes are listed

Each code is checked individually. An annotation % elp:ignore W0007 W0006 where W0007 is genuinely suppressing a diagnostic but W0006 is not produces a single W0081 warning anchored on the stale W0006 token — leaving the live W0007 alone. The diagnostic message includes both the code (W0006) and its label (statement_has_no_effect) so you immediately know what was supposed to be suppressed.

The check is strict on codes: an % elp:ignore W0007 is redundant even if a different diagnostic (say W0008) fires on the line below. The annotation only consumes diagnostics whose codes are explicitly listed.

When no codes are listed

Codeless annotations (% elp:ignore with no code) are always flagged redundant because today's suppression filter requires the diagnostic's code to be in the annotation's codes set — a codeless annotation has an empty codes set and therefore can never suppress anything.

Quickfixes

Two quickfixes are provided depending on the situation:

  • Delete redundant suppression — when every listed code is redundant (or when the annotation is codeless), removes the entire suppression comment line including any leading whitespace and the trailing newline.

  • Remove redundant code Wnnnn — when only some of the listed codes are redundant, removes just the stale code (and its leading whitespace) while keeping the rest of the comment intact.

Auditing a project

W0081 is a meta-diagnostic: its analysis depends on observing what other linters fire. Filtering to W0081 alone with

elp lint --diagnostic-filter W0081

is supported as a single command — every other linter still runs (so consumption tracking has the data it needs) and the CLI then drops their output, leaving you with a clean W0081-only report. There is no need to pass --recursive.

Combine with --read-config --config-file path/to/.elp_lint.toml to make the audit honour your project's per-linter overrides (disabled linters, exclude_apps, etc.) — annotations targeting codes that are disabled in your config are conservatively skipped rather than flagged.

Suppressing this diagnostic

If you really want to keep an annotation that the analyzer considers redundant, place % elp:ignore W0081 on the line immediately above it:

% elp:ignore W0081
% elp:ignore W0007
test() -> ok.

See also