Enable standard pedantic lints (#287)

diff --git a/.travis.yml b/.travis.yml
index 07f7919..9ce0790 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,7 +1,7 @@
 language: dart
 
 dart:
-  - 2.1.1
+  - 2.6.0
   - dev
 
 install:
@@ -13,7 +13,7 @@
   - coveralls-lcov var/lcov.info
 
 env:
-  - DARTANALYZER_FLAGS=--fatal-warnings
+  - DARTANALYZER_FLAGS="--fatal-warnings --fatal-infos"
 
 # Only building master means that we don't run two builds for each pull request.
 branches:
diff --git a/analysis_options.yaml b/analysis_options.yaml
index 8f7fcfd..82d1a22 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -1,20 +1,8 @@
-# Specify analysis options.
-#
-# Until there are meta linter rules, each desired lint must be explicitly enabled.
-# See: https://github.com/dart-lang/linter/issues/288
-#
-# For a list of lints, see: http://dart-lang.github.io/linter/lints/
-# See the configuration guide for more
-# https://github.com/dart-lang/sdk/tree/master/pkg/analyzer#configuring-the-analyzer
+include: package:pedantic/analysis_options.yaml
 
 analyzer:
   strong-mode:
-    implicit-dynamic: false
-  errors:
-    # treat missing required parameters as a warning (not a hint)
-    missing_required_param: warning
-    # allow having TODOs in the code
-    todo: ignore
+    implicit-casts: false
 
 linter:
   rules:
@@ -44,7 +32,6 @@
     - always_declare_return_types
     # - always_specify_types
     - annotate_overrides
-    - avoid_as
     - avoid_init_to_null
     - avoid_return_types_on_setters
     - await_only_futures
diff --git a/bin/collect_coverage.dart b/bin/collect_coverage.dart
index 14e1767..e49e62f 100644
--- a/bin/collect_coverage.dart
+++ b/bin/collect_coverage.dart
@@ -87,7 +87,7 @@
     exit(1);
   }
 
-  if (args['help']) {
+  if (args['help'] as bool) {
     printUsage();
     exit(0);
   }
@@ -99,25 +99,31 @@
     serviceUri = Uri.parse('http://${args['host']}:${args['port']}/');
   } else {
     try {
-      serviceUri = Uri.parse(args['uri']);
+      serviceUri = Uri.parse(args['uri'] as String);
     } on FormatException {
       fail('Invalid service URI specified: ${args['uri']}');
     }
   }
 
-  // ignore: avoid_as
   final scopedOutput = args['scope-output'] as List<String> ?? [];
 
   IOSink out;
   if (args['out'] == 'stdout') {
     out = stdout;
   } else {
-    final outfile = File(args['out'])..createSync(recursive: true);
+    final outfile = File(args['out'] as String)..createSync(recursive: true);
     out = outfile.openWrite();
   }
   final timeout = (args['connect-timeout'] == null)
       ? null
-      : Duration(seconds: int.parse(args['connect-timeout']));
-  return Options(serviceUri, out, timeout, args['wait-paused'],
-      args['resume-isolates'], args['include-dart'], scopedOutput.toSet());
+      : Duration(seconds: int.parse(args['connect-timeout'] as String));
+  return Options(
+    serviceUri,
+    out,
+    timeout,
+    args['wait-paused'] as bool,
+    args['resume-isolates'] as bool,
+    args['include-dart'] as bool,
+    scopedOutput.toSet(),
+  );
 }
diff --git a/bin/format_coverage.dart b/bin/format_coverage.dart
index 259e1c7..295f861 100644
--- a/bin/format_coverage.dart
+++ b/bin/format_coverage.dart
@@ -30,7 +30,7 @@
 Future<Null> main(List<String> arguments) async {
   final env = parseArgs(arguments);
 
-  final List<File> files = filesToProcess(env.input);
+  final files = filesToProcess(env.input);
   if (env.verbose) {
     print('Environment:');
     print('  # files: ${files.length}');
@@ -75,15 +75,15 @@
   }
 
   if (env.verbose) {
-    if (resolver.failed.length > 0) {
+    if (resolver.failed.isNotEmpty) {
       print('Failed to resolve:');
-      for (String error in resolver.failed.toSet()) {
+      for (var error in resolver.failed.toSet()) {
         print('  $error');
       }
     }
-    if (loader.failed.length > 0) {
+    if (loader.failed.isNotEmpty) {
       print('Failed to load:');
-      for (String error in loader.failed.toSet()) {
+      for (var error in loader.failed.toSet()) {
         print('  $error');
       }
     }
@@ -139,12 +139,12 @@
     exit(1);
   }
 
-  if (args['help']) {
+  if (args['help'] as bool) {
     printUsage();
     exit(0);
   }
 
-  env.sdkRoot = args['sdk-root'];
+  env.sdkRoot = args['sdk-root'] as String;
   if (env.sdkRoot != null) {
     env.sdkRoot = p.normalize(p.join(p.absolute(env.sdkRoot), 'lib'));
     if (!FileSystemEntity.isDirectorySync(env.sdkRoot)) {
@@ -157,23 +157,23 @@
     fail('Only one of --package-root or --packages may be specified.');
   }
 
-  env.packagesPath = args['packages'];
+  env.packagesPath = args['packages'] as String;
   if (env.packagesPath != null) {
     if (!FileSystemEntity.isFileSync(env.packagesPath)) {
       fail('Package spec "${args["packages"]}" not found, or not a file.');
     }
   }
 
-  env.pkgRoot = args['package-root'];
+  env.pkgRoot = args['package-root'] as String;
   if (env.pkgRoot != null) {
-    env.pkgRoot = p.absolute(p.normalize(args['package-root']));
+    env.pkgRoot = p.absolute(p.normalize(args['package-root'] as String));
     if (!FileSystemEntity.isDirectorySync(env.pkgRoot)) {
       fail('Package root "${args["package-root"]}" is not a directory.');
     }
   }
 
   if (args['in'] == null) fail('No input files given.');
-  env.input = p.absolute(p.normalize(args['in']));
+  env.input = p.absolute(p.normalize(args['in'] as String));
   if (!FileSystemEntity.isDirectorySync(env.input) &&
       !FileSystemEntity.isFileSync(env.input)) {
     fail('Provided input "${args["in"]}" is neither a directory nor a file.');
@@ -182,25 +182,26 @@
   if (args['out'] == 'stdout') {
     env.output = stdout;
   } else {
-    final outpath = p.absolute(p.normalize(args['out']));
+    final outpath = p.absolute(p.normalize(args['out'] as String));
     final outfile = File(outpath)..createSync(recursive: true);
     env.output = outfile.openWrite();
   }
 
-  env.reportOn = args['report-on'].isNotEmpty ? args['report-on'] : null;
+  final reportOn = args['report-on'] as List<String>;
+  env.reportOn = reportOn.isNotEmpty ? reportOn : null;
 
-  env.bazel = args['bazel'];
-  env.bazelWorkspace = args['bazel-workspace'];
+  env.bazel = args['bazel'] as bool;
+  env.bazelWorkspace = args['bazel-workspace'] as String;
   if (env.bazelWorkspace.isNotEmpty && !env.bazel) {
     stderr.writeln('warning: ignoring --bazel-workspace: --bazel not set');
   }
 
   if (args['base-directory'] != null) {
-    env.baseDirectory = p.absolute(args['base-directory']);
+    env.baseDirectory = p.absolute(args['base-directory'] as String);
   }
 
-  env.lcov = args['lcov'];
-  if (args['pretty-print'] && env.lcov) {
+  env.lcov = args['lcov'] as bool;
+  if (args['pretty-print'] as bool && env.lcov) {
     fail('Choose one of pretty-print or lcov output');
   }
   // Use pretty-print either explicitly or by default.
@@ -212,7 +213,7 @@
     fail('Invalid worker count: $e');
   }
 
-  env.verbose = args['verbose'];
+  env.verbose = args['verbose'] as bool;
   return env;
 }
 
diff --git a/lib/src/chrome.dart b/lib/src/chrome.dart
index e08b251..cc3a29a 100644
--- a/lib/src/chrome.dart
+++ b/lib/src/chrome.dart
@@ -26,15 +26,15 @@
   Future<Uri> Function(String sourceUrl, String scriptId) sourceUriProvider,
 ) async {
   final coverageReport = <Uri, Map<int, bool>>{};
-  for (Map<String, dynamic> entry in preciseCoverage) {
-    final String scriptId = entry['scriptId'];
+  for (var entry in preciseCoverage) {
+    final scriptId = entry['scriptId'] as String;
 
     final mapResponse = await sourceMapProvider(scriptId);
     if (mapResponse == null) continue;
 
     SingleMapping mapping;
     try {
-      mapping = parse(mapResponse);
+      mapping = parse(mapResponse) as SingleMapping;
     } on FormatException {
       continue;
     } on ArgumentError {
@@ -86,7 +86,7 @@
 /// Returns all covered positions in a provided source.
 Set<_Position> _coveredPositions(
     String compiledSource, List<bool> offsetCoverage) {
-  final positions = Set<_Position>();
+  final positions = <_Position>{};
   // Line is 1 based.
   var line = 1;
   // Column is 1 based.
@@ -109,9 +109,9 @@
   for (Map<String, dynamic> functions in entry['functions']) {
     for (Map<String, dynamic> range in functions['ranges']) {
       result.add(_CoverageInfo(
-        range['startOffset'],
-        range['endOffset'],
-        range['count'] > 0,
+        range['startOffset'] as int,
+        range['endOffset'] as int,
+        (range['count'] as int) > 0,
       ));
     }
   }
diff --git a/lib/src/collect.dart b/lib/src/collect.dart
index 9e24844..f44b030 100644
--- a/lib/src/collect.dart
+++ b/lib/src/collect.dart
@@ -37,7 +37,7 @@
 Future<Map<String, dynamic>> collect(Uri serviceUri, bool resume,
     bool waitPaused, bool includeDart, Set<String> scopedOutput,
     {Set<String> isolateIds, Duration timeout}) async {
-  scopedOutput ??= Set<String>();
+  scopedOutput ??= <String>{};
   if (serviceUri == null) throw ArgumentError('serviceUri must not be null');
 
   // Create websocket URI. Handle any trailing slashes.
@@ -51,7 +51,7 @@
       final options = const CompressionOptions(enabled: false);
       final socket = await WebSocket.connect('$uri', compression: options);
       final controller = StreamController<String>();
-      socket.listen((dynamic data) => controller.add(data));
+      socket.listen((data) => controller.add(data as String));
       service = VmService(
           controller.stream, (String message) => socket.add(message),
           log: StdoutLog(), disposeHandler: () => socket.close());
@@ -78,7 +78,7 @@
 
 Future<Map<String, dynamic>> _getAllCoverage(VmService service,
     bool includeDart, Set<String> scopedOutput, Set<String> isolateIds) async {
-  scopedOutput ??= Set<String>();
+  scopedOutput ??= <String>{};
   final vm = await service.getVM();
   final allCoverage = <Map<String, dynamic>>[];
 
@@ -100,7 +100,7 @@
         allCoverage.addAll(coverage);
       }
     } else {
-      final SourceReport isolateReport = await service.getSourceReport(
+      final isolateReport = await service.getSourceReport(
         isolateRef.id,
         <String>[SourceReportKind.kCoverage],
         forceCompile: true,
@@ -116,7 +116,7 @@
 Future _resumeIsolates(VmService service) async {
   final vm = await service.getVM();
   for (var isolateRef in vm.isolates) {
-    final Isolate isolate = await service.getIsolate(isolateRef.id);
+    final isolate = await service.getIsolate(isolateRef.id) as Isolate;
     if (isolate.pauseEvent.kind != EventKind.kResume) {
       await service.resume(isolateRef.id);
     }
@@ -124,20 +124,20 @@
 }
 
 Future _waitIsolatesPaused(VmService service, {Duration timeout}) async {
-  final pauseEvents = Set<String>.from(<String>[
+  final pauseEvents = <String>{
     EventKind.kPauseStart,
     EventKind.kPauseException,
     EventKind.kPauseExit,
     EventKind.kPauseInterrupted,
     EventKind.kPauseBreakpoint
-  ]);
+  };
 
   Future allPaused() async {
-    final VM vm = await service.getVM();
+    final vm = await service.getVM();
     for (var isolateRef in vm.isolates) {
-      final Isolate isolate = await service.getIsolate(isolateRef.id);
+      final isolate = await service.getIsolate(isolateRef.id) as Isolate;
       if (!pauseEvents.contains(isolate.pauseEvent.kind)) {
-        throw "Unpaused isolates remaining.";
+        throw 'Unpaused isolates remaining.';
       }
     }
   }
@@ -177,7 +177,7 @@
   final scripts = <ScriptRef, Script>{};
   for (var range in report.ranges) {
     final scriptRef = report.scripts[range.scriptIndex];
-    final Uri scriptUri = Uri.parse(report.scripts[range.scriptIndex].uri);
+    final scriptUri = Uri.parse(report.scripts[range.scriptIndex].uri);
 
     // Not returned in scripts section of source report.
     if (scriptUri.scheme == 'evaluate') continue;
@@ -186,7 +186,8 @@
     if (!includeDart && scriptUri.scheme == 'dart') continue;
 
     if (!scripts.containsKey(scriptRef)) {
-      scripts[scriptRef] = await service.getObject(isolateRef.id, scriptRef.id);
+      scripts[scriptRef] =
+          await service.getObject(isolateRef.id, scriptRef.id) as Script;
     }
     final script = scripts[scriptRef];
 
@@ -225,6 +226,7 @@
 class StdoutLog extends Log {
   @override
   void warning(String message) => print(message);
+
   @override
   void severe(String message) => print(message);
 }
diff --git a/lib/src/formatter.dart b/lib/src/formatter.dart
index 1d8383e..d124490 100644
--- a/lib/src/formatter.dart
+++ b/lib/src/formatter.dart
@@ -10,7 +10,7 @@
 
 abstract class Formatter {
   /// Returns the formatted coverage data.
-  Future<String> format(Map hitmap);
+  Future<String> format(Map<String, Map<int, int>> hitmap);
 }
 
 /// Converts the given hitmap to lcov format and appends the result to
@@ -31,11 +31,11 @@
   final List<String> reportOn;
 
   @override
-  Future<String> format(Map hitmap) async {
-    final _PathFilter pathFilter = _getPathFilter(reportOn);
+  Future<String> format(Map<String, Map<int, int>> hitmap) async {
+    final pathFilter = _getPathFilter(reportOn);
     final buf = StringBuffer();
     for (var key in hitmap.keys) {
-      final Map<int, int> v = hitmap[key];
+      final v = hitmap[key];
       var source = resolver.resolve(key);
       if (source == null) {
         continue;
@@ -51,7 +51,7 @@
 
       buf.write('SF:$source\n');
       final lines = v.keys.toList()..sort();
-      for (int k in lines) {
+      for (var k in lines) {
         buf.write('DA:$k,${v[k]}\n');
       }
       buf.write('LF:${lines.length}\n');
@@ -80,11 +80,11 @@
   final List<String> reportOn;
 
   @override
-  Future<String> format(Map hitmap) async {
-    final _PathFilter pathFilter = _getPathFilter(reportOn);
+  Future<String> format(Map<String, dynamic> hitmap) async {
+    final pathFilter = _getPathFilter(reportOn);
     final buf = StringBuffer();
     for (var key in hitmap.keys) {
-      final Map<int, int> v = hitmap[key];
+      final v = hitmap[key] as Map<int, int>;
       final source = resolver.resolve(key);
       if (source == null) {
         continue;
diff --git a/lib/src/hitmap.dart b/lib/src/hitmap.dart
index ab6fb69..e8f5721 100644
--- a/lib/src/hitmap.dart
+++ b/lib/src/hitmap.dart
@@ -10,7 +10,7 @@
 /// are not resolvable.
 ///
 /// `jsonResult` is expected to be a List<Map<String, dynamic>>.
-Map<String, Map<int, int>> createHitmap(List jsonResult) {
+Map<String, Map<int, int>> createHitmap(List<Map<String, dynamic>> jsonResult) {
   // Map of source file to map of line to hit count for that line.
   final globalHitMap = <String, Map<int, int>>{};
 
@@ -19,33 +19,34 @@
     map[line] = count + oldCount;
   }
 
-  for (Map<String, dynamic> e in jsonResult) {
-    final String source = e['source'];
+  for (var e in jsonResult) {
+    final source = e['source'] as String;
     if (source == null) {
       // Couldn't resolve import, so skip this entry.
       continue;
     }
 
     final sourceHitMap = globalHitMap.putIfAbsent(source, () => <int, int>{});
-    final List<dynamic> hits = e['hits'];
+    final hits = e['hits'] as List;
     // hits is a flat array of the following format:
     // [ <line|linerange>, <hitcount>,...]
     // line: number.
     // linerange: '<line>-<line>'.
     for (var i = 0; i < hits.length; i += 2) {
-      final dynamic k = hits[i];
-      if (k is num) {
+      final k = hits[i];
+      if (k is int) {
         // Single line.
-        addToMap(sourceHitMap, k, hits[i + 1]);
-      } else {
-        assert(k is String);
+        addToMap(sourceHitMap, k, hits[i + 1] as int);
+      } else if (k is String) {
         // Linerange. We expand line ranges to actual lines at this point.
-        final int splitPos = k.indexOf('-');
+        final splitPos = k.indexOf('-');
         final start = int.parse(k.substring(0, splitPos));
         final end = int.parse(k.substring(splitPos + 1));
         for (var j = start; j <= end; j++) {
-          addToMap(sourceHitMap, j, hits[i + 1]);
+          addToMap(sourceHitMap, j, hits[i + 1] as int);
         }
+      } else {
+        throw StateError('Expected value of type int or String');
       }
     }
   }
@@ -71,12 +72,16 @@
 }
 
 /// Generates a merged hitmap from a set of coverage JSON files.
-Future<Map> parseCoverage(Iterable<File> files, int _) async {
+Future<Map<String, Map<int, int>>> parseCoverage(
+    Iterable<File> files, int _) async {
   final globalHitmap = <String, Map<int, int>>{};
   for (var file in files) {
     final contents = file.readAsStringSync();
-    final List jsonResult = json.decode(contents)['coverage'];
-    mergeHitmaps(createHitmap(jsonResult), globalHitmap);
+    final jsonResult = json.decode(contents)['coverage'] as List;
+    mergeHitmaps(
+      createHitmap(jsonResult.cast<Map<String, dynamic>>()),
+      globalHitmap,
+    );
   }
   return globalHitmap;
 }
diff --git a/lib/src/resolver.dart b/lib/src/resolver.dart
index 1da70c5..316c66d 100644
--- a/lib/src/resolver.dart
+++ b/lib/src/resolver.dart
@@ -18,7 +18,7 @@
   final String packageRoot;
   final String sdkRoot;
   final List<String> failed = [];
-  Map<String, Uri> _packages;
+  final Map<String, Uri> _packages;
 
   /// Returns the absolute path wrt. to the given environment or null, if the
   /// import could not be resolved.
@@ -40,8 +40,11 @@
         }
         // Canonicalize path. For instance: _collection-dev => _collection_dev.
         path = path.replaceAll('-', '_');
-        final pathSegments = [sdkRoot, path]
-          ..addAll(uri.pathSegments.sublist(1));
+        final pathSegments = [
+          sdkRoot,
+          path,
+          ...uri.pathSegments.sublist(1),
+        ];
         filePath = p.joinAll(pathSegments);
       } else {
         // Resolve 'dart:something' to be something/something.dart in the SDK.
diff --git a/lib/src/run_and_collect.dart b/lib/src/run_and_collect.dart
index 090b64c..94c4160 100644
--- a/lib/src/run_and_collect.dart
+++ b/lib/src/run_and_collect.dart
@@ -49,14 +49,14 @@
   final serviceUri = await serviceUriCompleter.future;
   Map<String, dynamic> coverage;
   try {
-    coverage = await collect(serviceUri, true, true, includeDart, Set<String>(),
+    coverage = await collect(serviceUri, true, true, includeDart, <String>{},
         timeout: timeout);
   } finally {
     await process.stderr.drain<List<int>>();
   }
   final exitStatus = await process.exitCode;
   if (exitStatus != 0) {
-    throw "Process exited with exit code $exitStatus";
+    throw 'Process exited with exit code $exitStatus';
   }
   return coverage;
 }
diff --git a/lib/src/util.dart b/lib/src/util.dart
index ad99654..f0a3d7e 100644
--- a/lib/src/util.dart
+++ b/lib/src/util.dart
@@ -8,10 +8,11 @@
 // TODO(cbracken) make generic
 /// Retries the specified function with the specified interval and returns
 /// the result on successful completion.
-Future<dynamic> retry(Future f(), Duration interval, {Duration timeout}) async {
+Future<dynamic> retry(Future Function() f, Duration interval,
+    {Duration timeout}) async {
   var keepGoing = true;
 
-  Future<dynamic> _withTimeout(Future f(), {Duration duration}) {
+  Future<dynamic> _withTimeout(Future Function() f, {Duration duration}) {
     if (duration == null) {
       return f();
     }
diff --git a/pubspec.yaml b/pubspec.yaml
index 88be6f0..b491d47 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -4,7 +4,7 @@
 homepage: https://github.com/dart-lang/coverage
 
 environment:
-  sdk: '>=2.1.1 <3.0.0'
+  sdk: '>=2.6.0 <3.0.0'
 
 dependencies:
   args: '>=1.4.0 <2.0.0'
@@ -16,6 +16,7 @@
   vm_service: '>=1.0.0 <3.0.0'
 
 dev_dependencies:
+  pedantic: ^1.0.0
   test: ^1.0.0
 
 executables:
diff --git a/test/chrome_test.dart b/test/chrome_test.dart
index 9f09b7e..b9c6a0e 100644
--- a/test/chrome_test.dart
+++ b/test/chrome_test.dart
@@ -28,8 +28,9 @@
 
 void main() {
   test('reports correctly', () async {
-    final List preciseCoverage = json.decode(
-        await File('test/test_files/chrome_precise_report.txt').readAsString());
+    final preciseCoverage = json.decode(
+        await File('test/test_files/chrome_precise_report.txt')
+            .readAsString()) as List;
 
     final report = await parseChromeCoverage(
       preciseCoverage.cast(),
@@ -38,11 +39,11 @@
       sourceUriProvider,
     );
 
-    final Map sourceReport = report['coverage'].firstWhere(
+    final sourceReport = report['coverage'].firstWhere(
         (Map<String, dynamic> report) =>
             report['source'].toString().contains('main_test.dart'));
 
-    final Map<int, int> expectedHits = {
+    final expectedHits = {
       7: 1,
       11: 1,
       13: 1,
@@ -62,7 +63,7 @@
       36: 1,
     };
 
-    final List<int> hitMap = sourceReport['hits'];
+    final hitMap = sourceReport['hits'] as List<int>;
     expect(hitMap.length, equals(expectedHits.keys.length * 2));
     for (var i = 0; i < hitMap.length; i += 2) {
       expect(expectedHits[hitMap[i]], equals(hitMap[i + 1]));
diff --git a/test/collect_coverage_api_test.dart b/test/collect_coverage_api_test.dart
index 0dabd45..658a939 100644
--- a/test/collect_coverage_api_test.dart
+++ b/test/collect_coverage_api_test.dart
@@ -19,21 +19,21 @@
 
 void main() {
   test('collect throws when serviceUri is null', () {
-    expect(() => collect(null, true, false, false, Set<String>()),
+    expect(() => collect(null, true, false, false, <String>{}),
         throwsArgumentError);
   });
 
   test('collect_coverage_api', () async {
-    final Map<String, dynamic> json = await _collectCoverage();
+    final json = await _collectCoverage();
     expect(json.keys, unorderedEquals(<String>['type', 'coverage']));
     expect(json, containsPair('type', 'CodeCoverage'));
 
-    final List coverage = json['coverage'];
+    final coverage = json['coverage'] as List;
     expect(coverage, isNotEmpty);
 
     final sources = coverage.fold(<String, dynamic>{},
         (Map<String, dynamic> map, dynamic value) {
-      final String sourceUri = value['source'];
+      final sourceUri = value['source'] as String;
       map.putIfAbsent(sourceUri, () => <Map>[]).add(value);
       return map;
     });
@@ -48,17 +48,17 @@
   });
 
   test('collect_coverage_api with scoped output', () async {
-    final Map<String, dynamic> json =
-        await _collectCoverage(scopedOutput: Set<String>()..add('coverage'));
+    final json =
+        await _collectCoverage(scopedOutput: <String>{}..add('coverage'));
     expect(json.keys, unorderedEquals(<String>['type', 'coverage']));
     expect(json, containsPair('type', 'CodeCoverage'));
 
-    final List coverage = json['coverage'];
+    final coverage = json['coverage'] as List;
     expect(coverage, isNotEmpty);
 
     final sources = coverage.fold(<String, dynamic>{},
         (Map<String, dynamic> map, dynamic value) {
-      final String sourceUri = value['source'];
+      final sourceUri = value['source'] as String;
       map.putIfAbsent(sourceUri, () => <Map>[]).add(value);
       return map;
     });
@@ -70,22 +70,21 @@
   });
 
   test('collect_coverage_api with isolateIds', () async {
-    final Map<String, dynamic> json = await _collectCoverage(isolateIds: true);
+    final json = await _collectCoverage(isolateIds: true);
     expect(json.keys, unorderedEquals(<String>['type', 'coverage']));
     expect(json, containsPair('type', 'CodeCoverage'));
 
-    final List coverage = json['coverage'];
+    final coverage = json['coverage'] as List<Map<String, dynamic>>;
     expect(coverage, isNotEmpty);
 
-    final Map<String, dynamic> testAppCoverage =
-        _getScriptCoverage(coverage, 'test_app.dart');
-    List<int> hits = testAppCoverage['hits'];
+    final testAppCoverage = _getScriptCoverage(coverage, 'test_app.dart');
+    var hits = testAppCoverage['hits'] as List<int>;
     _expectHitCount(hits, 44, 0);
     _expectHitCount(hits, 48, 0);
 
-    final Map<String, dynamic> isolateCoverage =
+    final isolateCoverage =
         _getScriptCoverage(coverage, 'test_app_isolate.dart');
-    hits = isolateCoverage['hits'];
+    hits = isolateCoverage['hits'] as List<int>;
     _expectHitCount(hits, 11, 1);
     _expectHitCount(hits, 18, 1);
   });
@@ -93,7 +92,7 @@
 
 Future<Map<String, dynamic>> _collectCoverage(
     {Set<String> scopedOutput, bool isolateIds = false}) async {
-  scopedOutput ??= Set<String>();
+  scopedOutput ??= <String>{};
   final openPort = await getOpenPort();
 
   // run the sample app, with the right flags
@@ -107,7 +106,7 @@
       .transform(LineSplitter())
       .listen((line) {
     if (!serviceUriCompleter.isCompleted) {
-      final Uri serviceUri = extractObservatoryUri(line);
+      final serviceUri = extractObservatoryUri(line);
       if (serviceUri != null) {
         serviceUriCompleter.complete(serviceUri);
       }
@@ -117,9 +116,9 @@
     }
   });
 
-  final Uri serviceUri = await serviceUriCompleter.future;
-  final String isolateId = await isolateIdCompleter.future;
-  final Set<String> isolateIdSet = isolateIds ? Set.of([isolateId]) : null;
+  final serviceUri = await serviceUriCompleter.future;
+  final isolateId = await isolateIdCompleter.future;
+  final isolateIdSet = isolateIds ? {isolateId} : null;
 
   return collect(serviceUri, true, true, false, scopedOutput,
       timeout: timeout, isolateIds: isolateIdSet);
@@ -129,8 +128,8 @@
 // script filename, ignoring leading path.
 Map<String, dynamic> _getScriptCoverage(
     List<Map<String, dynamic>> coverage, String filename) {
-  for (Map<String, dynamic> isolateCoverage in coverage) {
-    final Uri script = Uri.parse(isolateCoverage['script']['uri']);
+  for (var isolateCoverage in coverage) {
+    final script = Uri.parse(isolateCoverage['script']['uri'] as String);
     if (script.pathSegments.last == filename) {
       return isolateCoverage;
     }
@@ -141,11 +140,11 @@
 /// Tests that the specified hitmap has the specified hit count for the
 /// specified line.
 void _expectHitCount(List<int> hits, int line, int hitCount) {
-  final int hitIndex = hits.indexOf(line);
+  final hitIndex = hits.indexOf(line);
   if (hitIndex < 0) {
     fail('No hit count for line $line');
   }
-  final int actual = hits[hitIndex + 1];
+  final actual = hits[hitIndex + 1];
   expect(actual, equals(hitCount),
       reason: 'Expected line $line to have $hitCount hits, but found $actual.');
 }
diff --git a/test/collect_coverage_test.dart b/test/collect_coverage_test.dart
index 749e28e..0cf6864 100644
--- a/test/collect_coverage_test.dart
+++ b/test/collect_coverage_test.dart
@@ -24,17 +24,17 @@
     final resultString = await _getCoverageResult();
 
     // analyze the output json
-    final Map<String, dynamic> jsonResult = json.decode(resultString);
+    final jsonResult = json.decode(resultString) as Map<String, dynamic>;
 
     expect(jsonResult.keys, unorderedEquals(<String>['type', 'coverage']));
     expect(jsonResult, containsPair('type', 'CodeCoverage'));
 
-    final List coverage = jsonResult['coverage'];
+    final coverage = jsonResult['coverage'] as List;
     expect(coverage, isNotEmpty);
 
     final sources = coverage.fold<Map<String, dynamic>>(<String, dynamic>{},
         (Map<String, dynamic> map, dynamic value) {
-      final String sourceUri = value['source'];
+      final sourceUri = value['source'] as String;
       map.putIfAbsent(sourceUri, () => <Map>[]).add(value);
       return map;
     });
@@ -50,13 +50,13 @@
 
   test('createHitmap', () async {
     final resultString = await _getCoverageResult();
-    final Map<String, dynamic> jsonResult = json.decode(resultString);
-    final List coverage = jsonResult['coverage'];
-    final hitMap = createHitmap(coverage);
+    final jsonResult = json.decode(resultString) as Map<String, dynamic>;
+    final coverage = jsonResult['coverage'] as List;
+    final hitMap = createHitmap(coverage.cast<Map<String, dynamic>>());
     expect(hitMap, contains(_sampleAppFileUri));
 
-    final Map<int, int> isolateFile = hitMap[_isolateLibFileUri];
-    final Map<int, int> expectedHits = {
+    final isolateFile = hitMap[_isolateLibFileUri];
+    final expectedHits = {
       12: 1,
       13: 1,
       15: 0,
@@ -107,12 +107,8 @@
 
 String _coverageData;
 
-Future<String> _getCoverageResult() async {
-  if (_coverageData == null) {
-    _coverageData = await _collectCoverage();
-  }
-  return _coverageData;
-}
+Future<String> _getCoverageResult() async =>
+    _coverageData ??= await _collectCoverage();
 
 Future<String> _collectCoverage() async {
   expect(FileSystemEntity.isFileSync(testAppPath), isTrue);
@@ -120,7 +116,7 @@
   final openPort = await getOpenPort();
 
   // Run the sample app with the right flags.
-  final Process sampleProcess = await runTestApp(openPort);
+  final sampleProcess = await runTestApp(openPort);
 
   // Capture the VM service URI.
   final serviceUriCompleter = Completer<Uri>();
@@ -129,13 +125,13 @@
       .transform(LineSplitter())
       .listen((line) {
     if (!serviceUriCompleter.isCompleted) {
-      final Uri serviceUri = extractObservatoryUri(line);
+      final serviceUri = extractObservatoryUri(line);
       if (serviceUri != null) {
         serviceUriCompleter.complete(serviceUri);
       }
     }
   });
-  final Uri serviceUri = await serviceUriCompleter.future;
+  final serviceUri = await serviceUriCompleter.future;
 
   // Run the collection tool.
   // TODO: need to get all of this functionality in the lib
@@ -156,7 +152,7 @@
   }
 
   await sampleProcess.exitCode;
-  sampleProcess.stderr.drain<List<int>>();
+  await sampleProcess.stderr.drain<List<int>>();
 
-  return toolResult.stdout;
+  return toolResult.stdout as String;
 }
diff --git a/test/lcov_test.dart b/test/lcov_test.dart
index d4bddd8..b90ea99 100644
--- a/test/lcov_test.dart
+++ b/test/lcov_test.dart
@@ -25,13 +25,13 @@
     expect(hitmap, contains(_isolateLibFileUri));
     expect(hitmap, contains('package:coverage/src/util.dart'));
 
-    final Map<int, int> sampleAppHitMap = hitmap[_sampleAppFileUri];
+    final sampleAppHitMap = hitmap[_sampleAppFileUri];
 
     expect(sampleAppHitMap, containsPair(44, greaterThanOrEqualTo(1)),
         reason: 'be careful if you modify the test file');
     expect(sampleAppHitMap, containsPair(48, 0),
         reason: 'be careful if you modify the test file');
-    expect(sampleAppHitMap, isNot(contains(31)),
+    expect(sampleAppHitMap, isNot(contains(30)),
         reason: 'be careful if you modify the test file');
   });
 
@@ -42,7 +42,7 @@
       final resolver = Resolver(packagesPath: '.packages');
       final formatter = LcovFormatter(resolver);
 
-      final String res = await formatter.format(hitmap);
+      final res = await formatter.format(hitmap);
 
       expect(res, contains(p.absolute(_sampleAppPath)));
       expect(res, contains(p.absolute(_isolateLibPath)));
@@ -55,7 +55,7 @@
       final resolver = Resolver(packagesPath: '.packages');
       final formatter = LcovFormatter(resolver, reportOn: ['lib/', 'test/']);
 
-      final String res = await formatter.format(hitmap);
+      final res = await formatter.format(hitmap);
 
       expect(res, contains(p.absolute(_sampleAppPath)));
       expect(res, contains(p.absolute(_isolateLibPath)));
@@ -68,7 +68,7 @@
       final resolver = Resolver(packagesPath: '.packages');
       final formatter = LcovFormatter(resolver, reportOn: ['lib/']);
 
-      final String res = await formatter.format(hitmap);
+      final res = await formatter.format(hitmap);
 
       expect(res, isNot(contains(p.absolute(_sampleAppPath))));
       expect(res, isNot(contains(p.absolute(_isolateLibPath))));
@@ -81,7 +81,7 @@
       final resolver = Resolver(packagesPath: '.packages');
       final formatter = LcovFormatter(resolver, basePath: p.absolute('lib'));
 
-      final String res = await formatter.format(hitmap);
+      final res = await formatter.format(hitmap);
 
       expect(
           res, isNot(contains(p.absolute(p.join('lib', 'src', 'util.dart')))));
@@ -96,14 +96,14 @@
       final resolver = Resolver(packagesPath: '.packages');
       final formatter = PrettyPrintFormatter(resolver, Loader());
 
-      final String res = await formatter.format(hitmap);
+      final res = await formatter.format(hitmap);
 
       expect(res, contains(p.absolute(_sampleAppPath)));
       expect(res, contains(p.absolute(_isolateLibPath)));
       expect(res, contains(p.absolute(p.join('lib', 'src', 'util.dart'))));
 
       // be very careful if you change the test file
-      expect(res, contains("      0|  return a - b;"));
+      expect(res, contains('      0|  return a - b;'));
 
       expect(res, contains('|  return _withTimeout(() async {'),
           reason: 'be careful if you change lib/src/util.dart');
@@ -122,7 +122,7 @@
       final formatter =
           PrettyPrintFormatter(resolver, Loader(), reportOn: ['lib/', 'test/']);
 
-      final String res = await formatter.format(hitmap);
+      final res = await formatter.format(hitmap);
 
       expect(res, contains(p.absolute(_sampleAppPath)));
       expect(res, contains(p.absolute(_isolateLibPath)));
@@ -136,7 +136,7 @@
       final formatter =
           PrettyPrintFormatter(resolver, Loader(), reportOn: ['lib/']);
 
-      final String res = await formatter.format(hitmap);
+      final res = await formatter.format(hitmap);
 
       expect(res, isNot(contains(p.absolute(_sampleAppPath))));
       expect(res, isNot(contains(p.absolute(_isolateLibPath))));
@@ -145,7 +145,7 @@
   });
 }
 
-Future<Map> _getHitMap() async {
+Future<Map<String, Map<int, int>>> _getHitMap() async {
   expect(FileSystemEntity.isFileSync(_sampleAppPath), isTrue);
 
   // select service port.
@@ -166,17 +166,18 @@
       .transform(LineSplitter())
       .listen((line) {
     if (!serviceUriCompleter.isCompleted) {
-      final Uri serviceUri = extractObservatoryUri(line);
+      final serviceUri = extractObservatoryUri(line);
       if (serviceUri != null) {
         serviceUriCompleter.complete(serviceUri);
       }
     }
   });
-  final Uri serviceUri = await serviceUriCompleter.future;
+  final serviceUri = await serviceUriCompleter.future;
 
   // collect hit map.
-  final List<Map> coverageJson =
-      (await collect(serviceUri, true, true, false, Set<String>()))['coverage'];
+  final coverageJson =
+      (await collect(serviceUri, true, true, false, <String>{}))['coverage']
+          as List<Map<String, dynamic>>;
   final hitMap = createHitmap(coverageJson);
 
   // wait for sample app to terminate.
@@ -185,6 +186,6 @@
     throw ProcessException(
         'dart', sampleAppArgs, 'Fatal error. Exit code: $exitCode', exitCode);
   }
-  sampleProcess.stderr.drain<List<int>>();
+  await sampleProcess.stderr.drain<List<int>>();
   return hitMap;
 }
diff --git a/test/run_and_collect_test.dart b/test/run_and_collect_test.dart
index 445a557..6b3e949 100644
--- a/test/run_and_collect_test.dart
+++ b/test/run_and_collect_test.dart
@@ -22,12 +22,12 @@
     expect(json.keys, unorderedEquals(<String>['type', 'coverage']));
     expect(json, containsPair('type', 'CodeCoverage'));
 
-    final List<Map> coverage = json['coverage'];
+    final coverage = json['coverage'] as List<Map<String, dynamic>>;
     expect(coverage, isNotEmpty);
 
     final sources = coverage.fold<Map<String, dynamic>>(<String, dynamic>{},
         (Map<String, dynamic> map, dynamic value) {
-      final String sourceUri = value['source'];
+      final sourceUri = value['source'] as String;
       map.putIfAbsent(sourceUri, () => <Map>[]).add(value);
       return map;
     });
@@ -43,8 +43,8 @@
     final hitMap = createHitmap(coverage);
     expect(hitMap, contains(_sampleAppFileUri));
 
-    final Map<int, int> isolateFile = hitMap[_isolateLibFileUri];
-    final Map<int, int> expectedHits = {
+    final isolateFile = hitMap[_isolateLibFileUri];
+    final expectedHits = {
       12: 1,
       13: 1,
       15: 0,
diff --git a/test/test_files/test_app.dart b/test/test_files/test_app.dart
index 3d7b79c..1677fbe 100644
--- a/test/test_files/test_app.dart
+++ b/test/test_files/test_app.dart
@@ -6,7 +6,6 @@
 import 'dart:developer';
 import 'dart:isolate';
 
-// explicitly using a package import to validate hitmap coverage of packages
 import 'package:coverage/src/util.dart';
 
 import 'test_app_isolate.dart';
@@ -21,9 +20,9 @@
     }
   }
 
-  final ReceivePort port = ReceivePort();
+  final port = ReceivePort();
 
-  final Isolate isolate =
+  final isolate =
       await Isolate.spawn(isolateTask, [port.sendPort, 1, 2], paused: true);
   await Service.controlWebServer(enable: true);
   final isolateID = Service.getIsolateID(isolate);
@@ -32,12 +31,12 @@
   isolate.addOnExitListener(port.sendPort);
   isolate.resume(isolate.pauseCapability);
 
-  final int value = await port.first;
+  final value = await port.first as int;
   if (value != 3) {
     throw 'expected 3!';
   }
 
-  final int result = await retry(() async => 42, const Duration(seconds: 1));
+  final result = await retry(() async => 42, const Duration(seconds: 1)) as int;
   print(result);
 }
 
diff --git a/test/test_files/test_app_isolate.dart b/test/test_files/test_app_isolate.dart
index 2f0b770..0f72d27 100644
--- a/test/test_files/test_app_isolate.dart
+++ b/test/test_files/test_app_isolate.dart
@@ -30,8 +30,8 @@
 
   fooSync(answer);
   fooAsync(answer).then((_) {
-    final SendPort port = threeThings.first;
-    final int sum = threeThings[1] + threeThings[2];
+    final port = threeThings.first as SendPort;
+    final sum = (threeThings[1] + threeThings[2]) as int;
     port.send(sum);
   });
 }
diff --git a/test/util_test.dart b/test/util_test.dart
index 13c97cb..b98ffe2 100644
--- a/test/util_test.dart
+++ b/test/util_test.dart
@@ -12,7 +12,7 @@
 
 void main() {
   test('retry', () async {
-    int count = 0;
+    var count = 0;
     final stopwatch = Stopwatch()..start();
 
     Future failCountTimes() async {
@@ -25,7 +25,7 @@
       return 42;
     }
 
-    final int value = await retry(failCountTimes, _delay);
+    final value = await retry(failCountTimes, _delay) as int;
 
     expect(value, 42);
     expect(count, _failCount);
@@ -34,7 +34,7 @@
 
   group('retry with timeout', () {
     test('if it finishes', () async {
-      int count = 0;
+      var count = 0;
       final stopwatch = Stopwatch()..start();
 
       Future failCountTimes() async {
@@ -48,8 +48,11 @@
       }
 
       final safeTimoutDuration = _delay * _failCount * 2;
-      final int value =
-          await retry(failCountTimes, _delay, timeout: safeTimoutDuration);
+      final value = await retry(
+        failCountTimes,
+        _delay,
+        timeout: safeTimoutDuration,
+      ) as int;
 
       expect(value, 42);
       expect(count, _failCount);
@@ -57,7 +60,7 @@
     });
 
     test('if it does not finish', () async {
-      int count = 0;
+      var count = 0;
       final stopwatch = Stopwatch()..start();
 
       var caught = false;
@@ -78,7 +81,7 @@
       try {
         await retry(failCountTimes, _delay, timeout: unsafeTimeoutDuration);
       } on StateError catch (e) {
-        expect(e.message, "Failed to complete within 25ms");
+        expect(e.message, 'Failed to complete within 25ms');
         caught = true;
 
         expect(countAfterError, 0,