Add lints from package:pedantic (dart-lang/watcher#66) - 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.
diff --git a/pkgs/watcher/analysis_options.yaml b/pkgs/watcher/analysis_options.yaml index 4c9f811..3155c7f 100644 --- a/pkgs/watcher/analysis_options.yaml +++ b/pkgs/watcher/analysis_options.yaml
@@ -1,3 +1,4 @@ +include: package:pedantic/analysis_options.yaml analyzer: strong-mode: implicit-casts: false
diff --git a/pkgs/watcher/lib/src/file_watcher/polling.dart b/pkgs/watcher/lib/src/file_watcher/polling.dart index 777038f..877031e 100644 --- a/pkgs/watcher/lib/src/file_watcher/polling.dart +++ b/pkgs/watcher/lib/src/file_watcher/polling.dart
@@ -60,16 +60,14 @@ 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; @@ -84,8 +82,8 @@ } } - void close() { + Future<void> close() async { _timer.cancel(); - _eventsController.close(); + await _eventsController.close(); } }
diff --git a/pkgs/watcher/lib/src/path_set.dart b/pkgs/watcher/lib/src/path_set.dart index 9a2c03c..d6983ff 100644 --- a/pkgs/watcher/lib/src/path_set.dart +++ b/pkgs/watcher/lib/src/path_set.dart
@@ -136,7 +136,7 @@ if (entry == null) return false; } - return !entry.contents.isEmpty; + return entry.contents.isNotEmpty; } /// All of the paths explicitly added to this set.
diff --git a/pkgs/watcher/pubspec.yaml b/pkgs/watcher/pubspec.yaml index 552b13a..c107856 100644 --- a/pkgs/watcher/pubspec.yaml +++ b/pkgs/watcher/pubspec.yaml
@@ -16,5 +16,6 @@ dev_dependencies: benchmark_harness: ^1.0.4 + pedantic: ^1.1.0 test: '>=0.12.42 <2.0.0' test_descriptor: ^1.0.0