Skip to content

Commit 562b9e5

Browse files
authored
Enable and fix lints, test on oldest supported Dart SDK, verify lints on Travis (flutter#68)
1 parent 7168052 commit 562b9e5

11 files changed

Lines changed: 43 additions & 24 deletions

File tree

.travis.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
language: dart
2-
dart: dev
2+
3+
dart:
4+
- dev
5+
- 2.0.0
36

47
dart_task:
5-
- test
6-
- dartfmt
7-
- dartanalyzer
8+
- test
9+
- dartanalyzer: --fatal-warnings --fatal-infos .
10+
11+
matrix:
12+
include:
13+
# Only validate formatting using the dev release
14+
- dart: dev
15+
dart_task: dartfmt
816

917
# Only building master means that we don't run two builds for each pull request.
1018
branches:
1119
only: [master]
1220

1321
cache:
14-
directories:
15-
- $HOME/.pub-cache
22+
directories:
23+
- $HOME/.pub-cache

analysis_options.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,7 @@ analyzer:
1212
linter:
1313
rules:
1414
- comment_references
15+
- prefer_generic_function_type_aliases
1516
- prefer_typing_uninitialized_variables
17+
- unnecessary_const
18+
- unnecessary_new

benchmark/path_set.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ abstract class PathSetBenchmark extends BenchmarkBase {
2121

2222
final PathSet pathSet = PathSet(root);
2323

24-
/// Use a fixed [Random] with a constant seed to ensure the tests are
24+
/// Use a fixed [math.Random] with a constant seed to ensure the tests are
2525
/// deterministic.
2626
final math.Random random = math.Random(1234);
2727

@@ -59,7 +59,9 @@ class AddBenchmark extends PathSetBenchmark {
5959
}
6060

6161
void run() {
62-
for (var path in paths) pathSet.add(path);
62+
for (var path in paths) {
63+
pathSet.add(path);
64+
}
6365
}
6466
}
6567

@@ -135,7 +137,9 @@ class RemoveBenchmark extends PathSetBenchmark {
135137
}
136138

137139
void run() {
138-
for (var path in paths) pathSet.remove(path);
140+
for (var path in paths) {
141+
pathSet.remove(path);
142+
}
139143
}
140144
}
141145

lib/src/async_queue.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import 'dart:async';
66
import 'dart:collection';
77

8-
typedef Future ItemProcessor<T>(T item);
8+
typedef ItemProcessor<T> = Future Function(T item);
99

1010
/// A queue of items that are sequentially, asynchronously processed.
1111
///

lib/src/file_watcher/polling.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import 'dart:async';
66
import 'dart:io';
77

8+
import 'package:pedantic/pedantic.dart';
9+
810
import '../file_watcher.dart';
911
import '../resubscribable.dart';
1012
import '../stat.dart';
@@ -54,7 +56,7 @@ class _PollingFileWatcher implements FileWatcher, ManuallyClosedWatcher {
5456

5557
if (_lastModified != null && !pathExists) {
5658
_eventsController.add(WatchEvent(ChangeType.REMOVE, path));
57-
close();
59+
unawaited(close());
5860
return;
5961
}
6062

lib/src/stat.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'dart:io';
77

88
/// A function that takes a file path and returns the last modified time for
99
/// the file at that path.
10-
typedef DateTime MockTimeCallback(String path);
10+
typedef MockTimeCallback = DateTime Function(String path);
1111

1212
MockTimeCallback _mockTimeCallback;
1313

pubspec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: watcher
2-
version: 0.9.7+12
2+
version: 0.9.8-dev
33

4-
description: >
4+
description: >-
55
A file system watcher. It monitors changes to contents of directories and
66
sends notifications when files have been added, removed, or modified.
77
author: Dart Team <[email protected]>
@@ -13,9 +13,9 @@ environment:
1313
dependencies:
1414
async: '>=1.10.0 <3.0.0'
1515
path: '>=0.9.0 <2.0.0'
16+
pedantic: ^1.1.0
1617

1718
dev_dependencies:
1819
benchmark_harness: ^1.0.4
19-
pedantic: ^1.1.0
2020
test: '>=0.12.42 <2.0.0'
2121
test_descriptor: ^1.0.0

test/directory_watcher/shared.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ void sharedTests() {
115115
await startWatcher(path: "dir");
116116

117117
renameFile("old.txt", "dir/new.txt");
118-
expectAddEvent("dir/new.txt");
118+
await expectAddEvent("dir/new.txt");
119119
});
120120

121121
test('notifies when a file is moved outside the watched directory',
@@ -124,7 +124,7 @@ void sharedTests() {
124124
await startWatcher(path: "dir");
125125

126126
renameFile("dir/old.txt", "new.txt");
127-
expectRemoveEvent("dir/old.txt");
127+
await expectRemoveEvent("dir/old.txt");
128128
});
129129

130130
test('notifies when a file is moved onto an existing one', () async {
@@ -231,7 +231,7 @@ void sharedTests() {
231231
test('watches files in subdirectories', () async {
232232
await startWatcher();
233233
writeFile("a/b/c/d/file.txt");
234-
expectAddEvent("a/b/c/d/file.txt");
234+
await expectAddEvent("a/b/c/d/file.txt");
235235
});
236236

237237
test(

test/no_subscription/shared.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// BSD-style license that can be found in the LICENSE file.
44

55
import 'package:async/async.dart';
6+
import 'package:pedantic/pedantic.dart';
67
import 'package:test/test.dart';
78
import 'package:watcher/watcher.dart';
89

@@ -15,7 +16,7 @@ void sharedTests() {
1516
// stream is and is not subscribed.
1617
var watcher = createWatcher();
1718
var queue = StreamQueue(watcher.events);
18-
queue.hasNext;
19+
unawaited(queue.hasNext);
1920

2021
var future =
2122
expectLater(queue, emits(isWatchEvent(ChangeType.ADD, "file.txt")));

test/ready/shared.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
import 'package:pedantic/pedantic.dart';
56
import 'package:test/test.dart';
67

78
import '../utils.dart';
@@ -11,9 +12,9 @@ void sharedTests() {
1112
var watcher = createWatcher();
1213

1314
var ready = false;
14-
watcher.ready.then((_) {
15+
unawaited(watcher.ready.then((_) {
1516
ready = true;
16-
});
17+
}));
1718
await pumpEventQueue();
1819

1920
expect(ready, isFalse);

0 commit comments

Comments
 (0)