Skip to content

prefer_correct_setter_parameter_name

v1.0.0WarningConfigurableClass Naming

This rule flags a setter whose parameter does not use the configured name.

A setter has exactly one parameter and its name appears nowhere but the body, so the only thing it communicates is which convention the file follows. When half the setters say value and half say newValue or v, a reader scanning a class of setters has to look at each one to be sure nothing else is going on.

An override is skipped, since it inherits its parameter name along with the signature.

This rule is in the pedantic preset.

set width(int newValue) => _width = newValue;
set width(int value) => _width = value;

This rule is in the pedantic preset, so it is enabled by preset: pedantic or by name:

many_lints.yaml
rules:
prefer_correct_setter_parameter_name:
enabled: true
analysis_options.yaml
many_lints:
rules:
prefer_correct_setter_parameter_name:
parameter_name: value
allow_names: []
Option Type Default Description
parameter_name string value The name every setter parameter should use
allow_names list [] Additional spellings accepted alongside the default

To disable this rule:

many_lints.yaml
rules:
prefer_correct_setter_parameter_name: false

To keep the rule on but skip certain paths, use per-rule exclude.