prefer_correct_setter_parameter_name
v1.0.0WarningConfigurableClass Naming
many_lints.yaml
analysis_options.yaml many_lints.yaml
many_lints.yaml
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;Enabling this rule
Section titled “Enabling this rule”This rule is in the pedantic preset, so it is enabled by preset: pedantic or by name:
rules: prefer_correct_setter_parameter_name: enabled: trueOptions
Section titled “Options”many_lints: rules: prefer_correct_setter_parameter_name: parameter_name: value allow_names: []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 |
Turning this rule off
Section titled “Turning this rule off”To disable this rule:
rules: prefer_correct_setter_parameter_name: falseTo keep the rule on but skip certain paths, use per-rule exclude.
Related rules
Section titled “Related rules”prefer_correct_callback_field_name— Name callbacks onSomething, the way Flutter does.prefer_correct_error_name— Name exception and error classes with the matching suffix.prefer_correct_handler_name— Name event handlers after the event they answer.prefer_boolean_prefixes— Name booleans as questions.