avoid-duplicate-mixins
- Group
- Correctness
- Path
lint/correctness/avoid-duplicate-mixins- Default
- Off, opt in
- Origin
- Falcon
- Rule
- 52 of 512
Flags repeated mixins in a with clause or a same-library superclass chain. Implemented interfaces do not count. Unknown ancestry, super calls, and intervening member overrides are skipped: reapplication can change behavior.
Invalid
mixin M {}
mixin N<T> {}
class A with M, M {}
class B with N<int>, N<int> {}
class C = Object with M, M;
class D with M, M {}
enum E with M, M { value }
mixin class MC {}
class Base with M {}
class Middle extends Base {}
class Inherited extends Middle with M {}
class AliasBase = Object with M;
class InheritedAlias extends AliasBase with M {}
class Direct extends MC with MC {}
class Forward extends Later with M {}
class Later with M {}
mixin Greeter { String greet() => 'hi'; }
mixin Spacer { String other() => 'other'; }
class NoConflict with Greeter, Spacer, Greeter {}
class GreeterBase with Greeter { String other() => 'other'; }
class NoConflictInherited extends GreeterBase with Greeter {}mixin N<T> {}class A with M, M {}class A with M, M {}class B with N<int>, N<int> {}class B with N<int>, N<int> {}class C = Object with M, M;class C = Object with M, M;class D with M, M {}class D with M, M {}enum E with M, M { value }class Middle extends Base {}class Inherited extends Middle with M {}class AliasBase = Object with M;class InheritedAlias extends AliasBase with M {}class InheritedAlias extends AliasBase with M {}class Direct extends MC with MC {}class Direct extends MC with MC {}class Forward extends Later with M {}mixin Spacer { String other() => 'other'; }class NoConflict with Greeter, Spacer, Greeter {}class GreeterBase with Greeter { String other() => 'other'; }class NoConflictInherited extends GreeterBase with Greeter {}Valid
import 'one.dart' as one;
import 'two.dart' as two;
mixin M {}
mixin N<T> {}
class A with M, N<int> {}
class B with N<int>, N<String> {}
class C with one.M, two.M {}
class D with M {}
class E with M {}
class F = Object with M, N<double>;
enum G with M { value }
class InterfaceOnly implements M {}
class Applied extends InterfaceOnly with M {}
class GenericBase<T> with N<T> {}
class DifferentArguments extends GenericBase<int> with N<String> {}
class UnknownBase extends missing.Base with M {}
class SeparateBase with M {}
class Separate extends SeparateBase with N<int> {}
mixin Greeter { String greet() => 'hi'; }
mixin OtherGreeter { String greet() => 'other'; }
class BaseGreeter with Greeter {}
class Polite extends BaseGreeter { String greet() => 'good day'; }
class Restored extends Polite with Greeter {}
class OwnOverride with Greeter { String greet() => 'good day'; }
class RestoredOwn extends OwnOverride with Greeter {}
class LaterOverride with Greeter, OtherGreeter {}
class RestoredLater extends LaterOverride with Greeter {}
class Reapplied with Greeter, OtherGreeter, Greeter {}
class UnknownBetween with Greeter, missing.Other, Greeter {}
mixin Delegating on Greeter { String greet() => super.greet(); }
class DelegatingBase extends BaseGreeter with Delegating {}
class DelegatingAgain extends DelegatingBase with Delegating {}
class Base { int f() => 0; }
mixin Increment on Base { int f() => super.f() + 1; }
class Twice extends Base with Increment, Increment {}
class TwiceAlias = Base with Increment, Increment;Configure avoid-duplicate-mixins
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"correctness": {
"avoid-duplicate-mixins": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/correctness/avoid-duplicate-mixins: <reason>More correctness rules
- avoid-duplicate-named-imports
Flags imports of the same library that differ only in their name prefix.
- avoid-duplicate-switch-case-conditionsrecommended
Flags repeated
whenguards on syntactically identical switch patterns. - avoid-duplicate-test-assertionsrecommendedtest
Reports repeated identical, side-effect-free assertions in a straight-line block.
- avoid-dynamic-calls
avoid_dynamic_callsrecommendedAvoid method calls or property accesses on a
dynamictarget. - avoid-emit-outside-blocrecommendedbloc
Flags external calls and tear-offs of a Bloc or Cubit's
emitmethod. - avoid-empty-setstaterecommendedflutter
Avoid setState callbacks with empty block bodies.
- avoid-empty-test-groupstest
Reports inline framework groups without any test registrations.
- avoid-global-state
avoid-global-stateDisallow mutable global and static state.