Skip to content

Commit

Permalink
Add lints from package:pedantic (flutter#66)
Browse files Browse the repository at this point in the history
- Fix a control_flow_in_finally by removing the nested try/catch which
  was set up for ordering of behavior and instead check for a closed
  controller in both places.
- Fix a prefer_is_not_empty.
  • Loading branch information
natebosch authored Sep 11, 2018
1 parent 8c904da commit 5022c65
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
1 change: 1 addition & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include: package:pedantic/analysis_options.yaml
analyzer:
strong-mode:
implicit-casts: false
Expand Down
18 changes: 8 additions & 10 deletions lib/src/file_watcher/polling.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,14 @@ class _PollingFileWatcher implements FileWatcher, ManuallyClosedWatcher {

DateTime modified;
try {
try {
modified = await getModificationTime(path);
} finally {
if (_eventsController.isClosed) return;
}
modified = await getModificationTime(path);
} on FileSystemException catch (error, stackTrace) {
_eventsController.addError(error, stackTrace);
close();
return;
if (!_eventsController.isClosed) {
_eventsController.addError(error, stackTrace);
await close();
}
}
if (_eventsController.isClosed) return;

if (_lastModified == modified) return;

Expand All @@ -84,8 +82,8 @@ class _PollingFileWatcher implements FileWatcher, ManuallyClosedWatcher {
}
}

void close() {
Future<void> close() async {
_timer.cancel();
_eventsController.close();
await _eventsController.close();
}
}
2 changes: 1 addition & 1 deletion lib/src/path_set.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class PathSet {
if (entry == null) return false;
}

return !entry.contents.isEmpty;
return entry.contents.isNotEmpty;
}

/// All of the paths explicitly added to this set.
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ dependencies:

dev_dependencies:
benchmark_harness: ^1.0.4
pedantic: ^1.1.0
test: '>=0.12.42 <2.0.0'
test_descriptor: ^1.0.0

0 comments on commit 5022c65

Please sign in to comment.