unused-parameter
What it does
Section titled “What it does”Reports a parameter of a function with a body (a declaration or a literal) that its body never mentions. A name that matches ignore_pattern and the blank identifier are not checked; the receiver and the named results are not parameters; an assignment to a parameter counts as a use.
Why it matters
Section titled “Why it matters”A parameter that nothing reads is either dead weight in the signature or a sign that the body ignores a value it should use (a typo in a name often shows this way).
To fix, remove the parameter, or use it.
Example
Section titled “Example”...
func unused(a, b int) int { return a...func lit() func(int) int { return func(n int) int { return 1 }}
func (r *T) method(x int) (n int, err error) { return...
func shadowed(a int) { if true {...
func newBool(pos int, true bool) bool { return true...Configuration
Section titled “Configuration”go: lint: rules: unused-parameter: level: warn # off (default), warn, error options: args: "all" ignore_pattern: "^_"js: lint: rules: unused-parameter: level: warn # off (default), warn, error options: args: "all" ignore_pattern: "^_"powershell: lint: rules: unused-parameter: level: warn # off (default), warn, error options: args: "all" ignore_pattern: "^_"| Option | Type | Default | Description |
|---|---|---|---|
args |
string | "all" |
Which parameters are checked: those after the last one that is read, all of them, or none. Values: after-used, all, none |
ignore_pattern |
string | "^_" |
A regex for the names that are not checked (revive’s allowRegex). |
Enabled by the presets: go/revive, js/eslint-recommended, js/typescript-eslint-recommended, js/biome-recommended, js/oxlint, powershell/psscriptanalyzer.
Suppress one line with sudsy-disable-next-line unused-parameter in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.
| Tool | Rule | Match | What differs |
|---|---|---|---|
| eslint | no-unused-vars |
partial | the options keep their defaults; /*exported*/ and /*global*/ comments are not read; a JSX tag counts as a use |
| psscriptanalyzer | PSReviewUnusedParameter |
partial | A read in a block inside the function counts; the module counts only reads in the function itself and in ForEach-Object and Where-Object blocks. Parameters written after the function name (function f($a)) are not checked. |
| revive | unused-parameter |
full | |
| typescript-eslint | no-unused-vars |
partial | the options keep their defaults; .d.ts files and declare module blocks are not treated as used |