From 5022c65c3333cb1b015467bd0219598dd0408384 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Tue, 11 Sep 2018 12:08:22 -0700 Subject: [PATCH] Add lints from package:pedantic (#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. --- analysis_options.yaml | 1 + lib/src/file_watcher/polling.dart | 18 ++++++++---------- lib/src/path_set.dart | 2 +- pubspec.yaml | 1 + 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 4c9f8113aa9ec..3155c7fc0b20e 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,3 +1,4 @@ +include: package:pedantic/analysis_options.yaml analyzer: strong-mode: implicit-casts: false diff --git a/lib/src/file_watcher/polling.dart b/lib/src/file_watcher/polling.dart index 777038fdfadbe..877031ecb8423 100644 --- a/lib/src/file_watcher/polling.dart +++ b/lib/src/file_watcher/polling.dart @@ -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; @@ -84,8 +82,8 @@ class _PollingFileWatcher implements FileWatcher, ManuallyClosedWatcher { } } - void close() { + Future close() async { _timer.cancel(); - _eventsController.close(); + await _eventsController.close(); } } diff --git a/lib/src/path_set.dart b/lib/src/path_set.dart index 9a2c03cc1e02c..d6983ffb1dd5f 100644 --- a/lib/src/path_set.dart +++ b/lib/src/path_set.dart @@ -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. diff --git a/pubspec.yaml b/pubspec.yaml index 552b13a9dbd20..c107856ec41f4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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