Skip to content

Commit 5022c65

Browse files
authored
Add lints from package:pedantic (flutter#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.
1 parent 8c904da commit 5022c65

4 files changed

Lines changed: 11 additions & 11 deletions

File tree

analysis_options.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
include: package:pedantic/analysis_options.yaml
12
analyzer:
23
strong-mode:
34
implicit-casts: false

lib/src/file_watcher/polling.dart

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,14 @@ class _PollingFileWatcher implements FileWatcher, ManuallyClosedWatcher {
6060

6161
DateTime modified;
6262
try {
63-
try {
64-
modified = await getModificationTime(path);
65-
} finally {
66-
if (_eventsController.isClosed) return;
67-
}
63+
modified = await getModificationTime(path);
6864
} on FileSystemException catch (error, stackTrace) {
69-
_eventsController.addError(error, stackTrace);
70-
close();
71-
return;
65+
if (!_eventsController.isClosed) {
66+
_eventsController.addError(error, stackTrace);
67+
await close();
68+
}
7269
}
70+
if (_eventsController.isClosed) return;
7371

7472
if (_lastModified == modified) return;
7573

@@ -84,8 +82,8 @@ class _PollingFileWatcher implements FileWatcher, ManuallyClosedWatcher {
8482
}
8583
}
8684

87-
void close() {
85+
Future<void> close() async {
8886
_timer.cancel();
89-
_eventsController.close();
87+
await _eventsController.close();
9088
}
9189
}

lib/src/path_set.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class PathSet {
136136
if (entry == null) return false;
137137
}
138138

139-
return !entry.contents.isEmpty;
139+
return entry.contents.isNotEmpty;
140140
}
141141

142142
/// All of the paths explicitly added to this set.

pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ dependencies:
1616

1717
dev_dependencies:
1818
benchmark_harness: ^1.0.4
19+
pedantic: ^1.1.0
1920
test: '>=0.12.42 <2.0.0'
2021
test_descriptor: ^1.0.0

0 commit comments

Comments
 (0)