diff --git a/lib/src/rules/super_goes_last.dart b/lib/src/rules/super_goes_last.dart index d943c64d2..d4918f1b8 100644 --- a/lib/src/rules/super_goes_last.dart +++ b/lib/src/rules/super_goes_last.dart @@ -2,9 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'package:analyzer/dart/ast/ast.dart'; -import 'package:analyzer/dart/ast/visitor.dart'; - import '../analyzer.dart'; const _desc = @@ -42,13 +39,6 @@ View(Style style, List children) : _children = children, super(style) { ``` - -**DEPRECATED:** In Dart 2, it is a compile-time error if a superinitializer -appears in an initializer list at any other position than at the end so this -rule is made redundant by the Dart analyzer's basic checks and is no longer -necessary. - -The rule will be removed in a future Linter release. '''; class SuperGoesLast extends LintRule { @@ -63,34 +53,9 @@ class SuperGoesLast extends LintRule { name: 'super_goes_last', description: _desc, details: _details, - state: State.deprecated(), + state: State.removed(since: dart3), group: Group.style); @override LintCode get lintCode => code; - - @override - void registerNodeProcessors( - NodeLintRegistry registry, LinterContext context) { - var visitor = _Visitor(this); - registry.addConstructorDeclaration(this, visitor); - } -} - -class _Visitor extends SimpleAstVisitor { - final LintRule rule; - - _Visitor(this.rule); - - @override - void visitConstructorDeclaration(ConstructorDeclaration node) { - var last = node.initializers.length - 1; - - for (var i = 0; i <= last; ++i) { - var init = node.initializers[i]; - if (init is SuperConstructorInvocation && i != last) { - rule.reportLint(init); - } - } - } } diff --git a/test/rules/all.dart b/test/rules/all.dart index cf614daa9..0957b3ce1 100644 --- a/test/rules/all.dart +++ b/test/rules/all.dart @@ -79,7 +79,6 @@ import 'recursive_getters_test.dart' as recursive_getters; import 'sort_constructors_first_test.dart' as sort_constructors_first; import 'sort_unnamed_constructors_first_test.dart' as sort_unnamed_constructors_first; -import 'super_goes_last_test.dart' as super_goes_last; import 'tighten_type_of_initializing_formals_test.dart' as tighten_type_of_initializing_formals; import 'type_init_formals_test.dart' as type_init_formals; @@ -157,7 +156,6 @@ void main() { recursive_getters.main(); sort_constructors_first.main(); sort_unnamed_constructors_first.main(); - super_goes_last.main(); tighten_type_of_initializing_formals.main(); type_init_formals.main(); unawaited_futures.main(); diff --git a/test/rules/super_goes_last_test.dart b/test/rules/super_goes_last_test.dart deleted file mode 100644 index dbef04c6d..000000000 --- a/test/rules/super_goes_last_test.dart +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -import 'package:test_reflective_loader/test_reflective_loader.dart'; - -import '../rule_test_support.dart'; - -main() { - defineReflectiveSuite(() { - defineReflectiveTests(SuperGoesLastTest); - }); -} - -@reflectiveTest -class SuperGoesLastTest extends LintRuleTest { - @override - String get lintRule => 'super_goes_last'; - - test_invalidSuperInvocation() async { - await assertDiagnostics(r''' -class A { - int a; - A(this.a); -} - -class C extends A { - int _c; - C(int a) - : super(a), _c = a + 1; -} - -''', [ - error(HintCode.UNUSED_FIELD, 61, 2), - error(CompileTimeErrorCode.SUPER_INVOCATION_NOT_LAST, 84, 5), - lint(84, 8), - ]); - } -} diff --git a/test_data/rules/super_goes_last.dart b/test_data/rules/super_goes_last.dart deleted file mode 100644 index 0036161e7..000000000 --- a/test_data/rules/super_goes_last.dart +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -// test w/ `dart test -N super_goes_last` - -class A { - int a; - A(this.a); -} - -class B extends A { - int _b; - B(int a) - : _b = a + 1, - super(a); // OK -}