Skip to content

Commit e748ba2

Browse files
authored
remove unnecessary boolean literals (dart-archive/linter#3007)
* remove unnecessary boolean literals * fmt
1 parent d80605b commit e748ba2

File tree

4 files changed

+4
-5
lines changed

4 files changed

+4
-5
lines changed

lib/src/ast.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ class _ElementVisitorAdapter extends GeneralizingElementVisitor {
422422
@override
423423
void visitElement(Element element) {
424424
var visitChildren = processor(element);
425-
if (visitChildren == true) {
425+
if (visitChildren) {
426426
element.visitChildren(this);
427427
}
428428
}

lib/src/rules/avoid_positional_boolean_parameters.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class _Visitor extends SimpleAstVisitor<void> {
6868
if (declaredElement != null && !declaredElement.isPrivate) {
6969
var parametersToLint =
7070
node.parameters.parameters.where(_isFormalParameterToLint);
71-
if (parametersToLint.isNotEmpty == true) {
71+
if (parametersToLint.isNotEmpty) {
7272
rule.reportLint(parametersToLint.first);
7373
}
7474
}

lib/src/rules/valid_regexps.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class _Visitor extends SimpleAstVisitor<void> {
5959
return;
6060
}
6161

62-
bool isTrue(Expression e) => e is BooleanLiteral && e.value == true;
62+
bool isTrue(Expression e) => e is BooleanLiteral && e.value;
6363

6464
var unicode = args.any((arg) =>
6565
arg is NamedExpression &&

lib/src/test_utilities/annotation.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,5 @@ class Annotation implements Comparable<Annotation> {
6161

6262
extension on String? {
6363
int? toInt() => this == null ? null : int.parse(this!);
64-
String? toNullIfBlank() =>
65-
this == null || this!.trim().isEmpty == true ? null : this;
64+
String? toNullIfBlank() => this == null || this!.trim().isEmpty ? null : this;
6665
}

0 commit comments

Comments
 (0)