Skip to content
This repository was archived by the owner on Nov 20, 2024. It is now read-only.

remove unnecessary boolean literals #3007

Merged
merged 2 commits into from
Oct 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/src/ast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ class _ElementVisitorAdapter extends GeneralizingElementVisitor {
@override
void visitElement(Element element) {
var visitChildren = processor(element);
if (visitChildren == true) {
if (visitChildren) {
element.visitChildren(this);
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/rules/avoid_positional_boolean_parameters.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class _Visitor extends SimpleAstVisitor<void> {
if (declaredElement != null && !declaredElement.isPrivate) {
var parametersToLint =
node.parameters.parameters.where(_isFormalParameterToLint);
if (parametersToLint.isNotEmpty == true) {
if (parametersToLint.isNotEmpty) {
rule.reportLint(parametersToLint.first);
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/rules/valid_regexps.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class _Visitor extends SimpleAstVisitor<void> {
return;
}

bool isTrue(Expression e) => e is BooleanLiteral && e.value == true;
bool isTrue(Expression e) => e is BooleanLiteral && e.value;

var unicode = args.any((arg) =>
arg is NamedExpression &&
Expand Down
3 changes: 1 addition & 2 deletions lib/src/test_utilities/annotation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,5 @@ class Annotation implements Comparable<Annotation> {

extension on String? {
int? toInt() => this == null ? null : int.parse(this!);
String? toNullIfBlank() =>
this == null || this!.trim().isEmpty == true ? null : this;
String? toNullIfBlank() => this == null || this!.trim().isEmpty ? null : this;
}