annotate-overrides
Same as annotate_overrides in Dart lints
- Group
- Style
- Path
lint/style/annotate-overrides- Default
- On (recommended)
- Origin
- Dart lints
- Rule
- 10 of 512
Requires @override on members that override an inherited declaration.
An instance method, operator, getter, setter, or field of a class, mixin class, enum, or mixin is reported when its inherited interface has a combined member signature for that name — a getter for fields and getters, a setter for setters. Conflicting inherited signatures with no most-specific existing candidate do not count, even when this declaration validly overrides all candidates. Extension-type members are never checked. Unloaded dependency signatures remain unknown rather than being inferred from member names.
Declaring var/final primary-constructor parameters are also instance
fields and are checked as such.
Invalid
class Base {
void method(int value) {}
int get count => 0;
int field = 0;
}
class Child extends Base {
void method(int value) {}
int get count => 1;
int field = 1;
}
class SetterOnly { set onlySetter(int value) {} }
class SetterOverride extends SetterOnly {
set onlySetter(int value) {}
}
class Negatable {
Negatable operator -() => this;
Negatable operator +(Negatable other) => this;
}
class BinaryOverride extends Negatable {
Negatable operator +(Negatable other) => this;
}class Child extends Base { void method(int value) {} void method(int value) {} int get count => 1; int get count => 1; int field = 1;class SetterOverride extends SetterOnly { set onlySetter(int value) {}class BinaryOverride extends Negatable { Negatable operator +(Negatable other) => this;Valid
class Base { void method() {} }
class Child extends Base {
@override
void method() {}
static void helper() {}
}
class SetterOnlyBase { set onlySetter(int value) {} }
class FieldOverSetter implements SetterOnlyBase {
// Fields are compared through their getter; only a setter is inherited.
int onlySetter = 0;
}
class UnaryOnly { UnaryOnly operator -() => this; }
class BinaryMinus extends UnaryOnly {
UnaryOnly operator -(UnaryOnly other) => this;
}
extension type Wrapper(int value) implements Object {
String toString() => '';
}Configure annotate-overrides
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"style": {
"annotate-overrides": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/style/annotate-overrides: <reason>More style rules
- arguments-ordering
Named arguments follow their resolved parameter declaration order by default.
- avoid-abbreviations-in-doc-comments
avoid_abbreviations_in_doc_commentsFlags Latin abbreviations in doc comments.
- avoid-annotating-with-dynamic
avoid_annotating_with_dynamicFlags parameters explicitly annotated with
dynamic. - avoid-bloc-public-fieldsbloc
Keep package-confirmed Bloc instance fields private; inherited API overrides are allowed.
- avoid-bloc-public-methodsbloc
Enforce the package-confirmed Bloc convention.
- avoid-bool-literals-in-conditional-expressions
avoid_bool_literals_in_conditional_expressionsrecommendedFlags conditional expressions over
boolthat have aboolliteral branch. - avoid-catches-without-on-clauses
avoid_catches_without_on_clausesAvoid
catchclauses without anontype. - avoid-catching-errors
avoid_catching_errorsDon't explicitly catch
Erroror types that implement it.