Skip to content

Commit

Permalink
bail on first non-assert (dart-lang#1873)
Browse files Browse the repository at this point in the history
  • Loading branch information
pq authored Dec 5, 2019
1 parent 7ddeafe commit f2a2687
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/src/rules/always_require_non_null_named_parameters.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ class _Visitor extends SimpleAstVisitor<void> {
for (final statement in body.block.statements) {
if (statement is AssertStatement) {
_checkAssert(statement.condition, params);
} else {
// Bail on first non-assert.
return;
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions test/rules/always_require_non_null_named_parameters.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@

import 'package:meta/meta.dart';

var condition = true;

m0({
Object a, // OK
}) {
if (condition) {
return;
}
assert(a != null);
}

m1(
a,
b,
Expand Down

0 comments on commit f2a2687

Please sign in to comment.