avoid-renaming-method-parameters

Same as avoid_renaming_method_parameters in Dart lints

Group
Style
Path
lint/style/avoid-renaming-method-parameters
Default
Off, opt in
Origin
Dart lints
Rule
129 of 512

Requires overriding methods to keep the positional parameter names of the member they inherit.

The rule only runs for libraries under the package's lib/ directory and skips static and documented methods. For a class, enum, or mixin class the compared member is the concrete one inherited through the superclass chain and mixin applications (abstract and implements-only members do not count); for a mixin it is the member of its on types' interfaces (or Object). Owners with private names, extension types, getters, and setters are never checked. Positional parameters are compared pairwise up to the shorter list.

A _ name on either side is skipped when the library's language version enables wildcard variables (3.7+).

Invalid

lib/bad_semantics.dartdart
abstract class AbstractBase {
  void abstractOnly(int value);
}

class ConcreteBase {
  void concrete(int value, int other) {}
  bool operator ==(Object other) => false;
}

abstract class FromAbstract extends AbstractBase {
  // Only an abstract member is inherited: no concrete parent.
  @override
  void abstractOnly(int renamed);
}

class FromInterface implements ConcreteBase {
  @override
  void concrete(int renamed, int other) {}
}

class Shorter extends ConcreteBase {
  @override
  void concrete(int renamed) {}
}

class Documented extends ConcreteBase {
  /// Documented overrides are exempt.
  @override
  void concrete(int a, int b) {}
}

class _Private extends ConcreteBase {
  @override
  void concrete(int a, int b) {}
}

mixin OnBase on AbstractBase {
  @override
  void abstractOnly(int renamed) {}
}
lib/bad_semantics.dartRename parameter `renamed` to match the overridden declaration's `value`.
22 @override
23 void concrete(int renamed) {}
lib/bad_semantics.dartRename parameter `renamed` to match the overridden declaration's `value`.
38 @override
39 void abstractOnly(int renamed) {}

Valid

example.dartdart
class Base { void method(int value) {} }
class Child extends Base { void method(int value) {} }

Configure avoid-renaming-method-parameters

Set its severity in falcon.json. See the configuration guide.

falcon.jsonjson
{
  "linter": {
    "rules": {
      "style": {
        "avoid-renaming-method-parameters": "error"
      }
    }
  }
}

Or silence one occurrence with a suppression comment; the reason is required.

example.dartdart
// falcon-ignore lint/style/avoid-renaming-method-parameters: <reason>