Enable and fix lints, test on oldest supported Dart SDK, verify lints on Travis (#68)
diff --git a/.travis.yml b/.travis.yml
index 2547644..c15590b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,15 +1,23 @@
language: dart
-dart: dev
+
+dart:
+- dev
+- 2.0.0
dart_task:
- - test
- - dartfmt
- - dartanalyzer
+- test
+- dartanalyzer: --fatal-warnings --fatal-infos .
+
+matrix:
+ include:
+ # Only validate formatting using the dev release
+ - dart: dev
+ dart_task: dartfmt
# Only building master means that we don't run two builds for each pull request.
branches:
only: [master]
cache:
- directories:
- - $HOME/.pub-cache
+ directories:
+ - $HOME/.pub-cache
diff --git a/analysis_options.yaml b/analysis_options.yaml
index 3155c7f..dd6881e 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -12,4 +12,7 @@
linter:
rules:
- comment_references
+ - prefer_generic_function_type_aliases
- prefer_typing_uninitialized_variables
+ - unnecessary_const
+ - unnecessary_new
diff --git a/benchmark/path_set.dart b/benchmark/path_set.dart
index 8a5b843..1ec3336 100644
--- a/benchmark/path_set.dart
+++ b/benchmark/path_set.dart
@@ -21,7 +21,7 @@
final PathSet pathSet = PathSet(root);
- /// Use a fixed [Random] with a constant seed to ensure the tests are
+ /// Use a fixed [math.Random] with a constant seed to ensure the tests are
/// deterministic.
final math.Random random = math.Random(1234);
@@ -59,7 +59,9 @@
}
void run() {
- for (var path in paths) pathSet.add(path);
+ for (var path in paths) {
+ pathSet.add(path);
+ }
}
}
@@ -135,7 +137,9 @@
}
void run() {
- for (var path in paths) pathSet.remove(path);
+ for (var path in paths) {
+ pathSet.remove(path);
+ }
}
}
diff --git a/lib/src/async_queue.dart b/lib/src/async_queue.dart
index de7b718..d864b1b 100644
--- a/lib/src/async_queue.dart
+++ b/lib/src/async_queue.dart
@@ -5,7 +5,7 @@
import 'dart:async';
import 'dart:collection';
-typedef Future ItemProcessor<T>(T item);
+typedef ItemProcessor<T> = Future Function(T item);
/// A queue of items that are sequentially, asynchronously processed.
///
diff --git a/lib/src/file_watcher/polling.dart b/lib/src/file_watcher/polling.dart
index 877031e..a0466b5 100644
--- a/lib/src/file_watcher/polling.dart
+++ b/lib/src/file_watcher/polling.dart
@@ -5,6 +5,8 @@
import 'dart:async';
import 'dart:io';
+import 'package:pedantic/pedantic.dart';
+
import '../file_watcher.dart';
import '../resubscribable.dart';
import '../stat.dart';
@@ -54,7 +56,7 @@
if (_lastModified != null && !pathExists) {
_eventsController.add(WatchEvent(ChangeType.REMOVE, path));
- close();
+ unawaited(close());
return;
}
diff --git a/lib/src/stat.dart b/lib/src/stat.dart
index 59a5eb6..a569208 100644
--- a/lib/src/stat.dart
+++ b/lib/src/stat.dart
@@ -7,7 +7,7 @@
/// A function that takes a file path and returns the last modified time for
/// the file at that path.
-typedef DateTime MockTimeCallback(String path);
+typedef MockTimeCallback = DateTime Function(String path);
MockTimeCallback _mockTimeCallback;
diff --git a/pubspec.yaml b/pubspec.yaml
index 163e70e..3722c84 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,7 +1,7 @@
name: watcher
-version: 0.9.7+12
+version: 0.9.8-dev
-description: >
+description: >-
A file system watcher. It monitors changes to contents of directories and
sends notifications when files have been added, removed, or modified.
author: Dart Team <misc@dartlang.org>
@@ -13,9 +13,9 @@
dependencies:
async: '>=1.10.0 <3.0.0'
path: '>=0.9.0 <2.0.0'
+ pedantic: ^1.1.0
dev_dependencies:
benchmark_harness: ^1.0.4
- pedantic: ^1.1.0
test: '>=0.12.42 <2.0.0'
test_descriptor: ^1.0.0
diff --git a/test/directory_watcher/shared.dart b/test/directory_watcher/shared.dart
index f6e451c..a302c93 100644
--- a/test/directory_watcher/shared.dart
+++ b/test/directory_watcher/shared.dart
@@ -115,7 +115,7 @@
await startWatcher(path: "dir");
renameFile("old.txt", "dir/new.txt");
- expectAddEvent("dir/new.txt");
+ await expectAddEvent("dir/new.txt");
});
test('notifies when a file is moved outside the watched directory',
@@ -124,7 +124,7 @@
await startWatcher(path: "dir");
renameFile("dir/old.txt", "new.txt");
- expectRemoveEvent("dir/old.txt");
+ await expectRemoveEvent("dir/old.txt");
});
test('notifies when a file is moved onto an existing one', () async {
@@ -231,7 +231,7 @@
test('watches files in subdirectories', () async {
await startWatcher();
writeFile("a/b/c/d/file.txt");
- expectAddEvent("a/b/c/d/file.txt");
+ await expectAddEvent("a/b/c/d/file.txt");
});
test(
diff --git a/test/no_subscription/shared.dart b/test/no_subscription/shared.dart
index 2fa3353..e82692e 100644
--- a/test/no_subscription/shared.dart
+++ b/test/no_subscription/shared.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:async/async.dart';
+import 'package:pedantic/pedantic.dart';
import 'package:test/test.dart';
import 'package:watcher/watcher.dart';
@@ -15,7 +16,7 @@
// stream is and is not subscribed.
var watcher = createWatcher();
var queue = StreamQueue(watcher.events);
- queue.hasNext;
+ unawaited(queue.hasNext);
var future =
expectLater(queue, emits(isWatchEvent(ChangeType.ADD, "file.txt")));
diff --git a/test/ready/shared.dart b/test/ready/shared.dart
index 76089e2..ebe2f0c 100644
--- a/test/ready/shared.dart
+++ b/test/ready/shared.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:pedantic/pedantic.dart';
import 'package:test/test.dart';
import '../utils.dart';
@@ -11,9 +12,9 @@
var watcher = createWatcher();
var ready = false;
- watcher.ready.then((_) {
+ unawaited(watcher.ready.then((_) {
ready = true;
- });
+ }));
await pumpEventQueue();
expect(ready, isFalse);
diff --git a/test/utils.dart b/test/utils.dart
index 95f594d..57b4563 100644
--- a/test/utils.dart
+++ b/test/utils.dart
@@ -7,13 +7,13 @@
import 'package:async/async.dart';
import 'package:path/path.dart' as p;
+import 'package:pedantic/pedantic.dart';
import 'package:test/test.dart';
import 'package:test_descriptor/test_descriptor.dart' as d;
-
import 'package:watcher/src/stat.dart';
import 'package:watcher/watcher.dart';
-typedef Watcher WatcherFactory(String directory);
+typedef WatcherFactory = Watcher Function(String directory);
/// Sets the function used to create the watcher.
set watcherFactory(WatcherFactory factory) {
@@ -69,7 +69,7 @@
var watcher = createWatcher(path: path);
_watcherEvents = StreamQueue(watcher.events);
// Forces a subscription to the underlying stream.
- _watcherEvents.hasNext;
+ unawaited(_watcherEvents.hasNext);
await watcher.ready;
}