Skip to content

Commit 5ce7e10

Browse files
authored
remove prefer_bool_in_asserts (dart-archive/linter#4015)
1 parent f297d11 commit 5ce7e10

File tree

2 files changed

+1
-71
lines changed

2 files changed

+1
-71
lines changed

lib/src/rules/prefer_bool_in_asserts.dart

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
import 'package:analyzer/dart/ast/ast.dart';
6-
import 'package:analyzer/dart/ast/visitor.dart';
7-
import 'package:analyzer/dart/element/type.dart';
8-
95
import '../analyzer.dart';
106

117
const _desc = r'Prefer using a boolean as the assert condition.';
@@ -31,12 +27,6 @@ assert(() {
3127
return true;
3228
}());
3329
```
34-
35-
**DEPRECATED:** In Dart 2, `assert`s no longer accept non-`bool` values so this
36-
rule is made redundant by the Dart analyzer's basic checks and is no longer
37-
necessary.
38-
39-
The rule will be removed in a future Linter release.
4030
''';
4131

4232
class PreferBoolInAsserts extends LintRule {
@@ -50,45 +40,9 @@ class PreferBoolInAsserts extends LintRule {
5040
name: 'prefer_bool_in_asserts',
5141
description: _desc,
5242
details: _details,
53-
state: State.deprecated(),
43+
state: State.removed(since: dart3),
5444
group: Group.style);
5545

5646
@override
5747
LintCode get lintCode => code;
58-
59-
@override
60-
void registerNodeProcessors(
61-
NodeLintRegistry registry, LinterContext context) {
62-
var visitor = _Visitor(this, context);
63-
registry.addAssertStatement(this, visitor);
64-
}
65-
}
66-
67-
class _Visitor extends SimpleAstVisitor<void> {
68-
final LintRule rule;
69-
70-
final TypeSystem typeSystem;
71-
72-
final DartType boolType;
73-
74-
_Visitor(this.rule, LinterContext context)
75-
: typeSystem = context.typeSystem,
76-
boolType = context.typeProvider.boolType;
77-
78-
@override
79-
void visitAssertStatement(AssertStatement node) {
80-
var conditionType = _unbound(node.condition.staticType);
81-
if (conditionType != null &&
82-
!typeSystem.isAssignableTo(conditionType, boolType)) {
83-
rule.reportLint(node.condition);
84-
}
85-
}
86-
87-
DartType? _unbound(DartType? type) {
88-
var t = type;
89-
while (t is TypeParameterType) {
90-
t = t.bound;
91-
}
92-
return t;
93-
}
9448
}

test_data/rules/prefer_bool_in_asserts.dart

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)