Skip to content

SCR123: unused-suppression

# iglint: ignore[...] that suppresses nothing

Code SCR123
Name unused-suppression
Category Scripts (SCR)
Default severity info
Enabled by default yes
Fix available always
Fix safety safe or unsafe, depending on the finding (see below)
ign-lint equivalent none

Reports # iglint: ignore[...] and # iglint: ignore-file[...] comments, or single codes in them, that did not suppress any finding in this run. A comment at the end of a statement that spans several lines counts the findings of the whole statement up to its line. Scripts that do not parse are skipped: the rules that need the syntax tree did not run on them.

A code is only reported when every script rule it selects is enabled (otherwise the comment may be needed under another configuration). Codes that select no rule at all, or only rules that never report in scripts, are always reported. A bare # iglint: ignore is reported only when every script rule is enabled.

Stale suppressions hide future findings on the same line and make readers believe there is a problem there.

total = 0 # iglint: ignore[SCR103]
return total

Use instead:

total = 0
return total

Removes the unused codes, or the whole comment when none of its codes is used. A comment alone on its line leaves the line empty, so no line number changes. Safe, except when the whole comment would go and it holds more than the suppression (a reason, a # pylint: directive, a coding: declaration); that fix is unsafe and removes the comment's line too. The fix only changes a comment, so it is also unsafe when it would change a token of the script: a comment after a backslash that is not followed by a line break goes with the whitespace before it, and the backslash would then join the next line.

Like every fix, it is unsafe while code in the workspace may read the files a fix edits (any file access, read, write, rename or delete, whose path is not a literal outside the workspace, or code that is not vetted); the project setting [fix] assume-scripts-do-not-read-workspace-files = true declares that no script does (see docs/internal/fix-safety.md, "File reads").


Generated from the rule metadata by iglint generate-docs; iglint rule SCR123 prints the same page in the terminal. Source: docs/rules/SCR123.md.