Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit bf9211f

Browse files
munificentcbracken
authored andcommitted
Fix warnings related to fuzzy arrows. (#209)
These will become an arrow in Dart 2.0. See this bug for more context: dart-lang/sdk#29630 I also fixed a couple of unused variable warnings while I was at it. I bumped the version number in the pubspec. This is technically a potentially breaking change because the signatures of createHitmap() and mergeHitmaps() are more precise now. The only code I could find calling that was in flutter_tools and that seems to be happy with the change. If you'd rather I keep the old version, let me know.
1 parent 53daab4 commit bf9211f

File tree

7 files changed

+15
-14
lines changed

7 files changed

+15
-14
lines changed

lib/src/collect.dart

+5-3
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,11 @@ Future _waitIsolatesPaused(VMServiceClient service, {Duration timeout}) async {
8080
Future<List<Map<String, dynamic>>> _getCoverageJson(
8181
VMServiceClient service, VMSourceReport report) async {
8282
var scriptRefs = report.ranges.map((r) => r.script).toSet();
83-
var scripts = new Map<Uri, VMScript>.fromIterable(
84-
await Future.wait<VMScript>(scriptRefs.map((ref) => ref.load()).toList()),
85-
key: (VMScript s) => s.uri);
83+
var scripts = <Uri, VMScript>{};
84+
for (var script in await Future
85+
.wait<VMScript>(scriptRefs.map((ref) => ref.load()).toList())) {
86+
scripts[script.uri] = script;
87+
}
8688

8789
// script uri -> { line -> hit count }
8890
var hitMaps = <Uri, Map<int, int>>{};

lib/src/hitmap.dart

+5-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import 'dart:io';
88

99
/// Creates a single hitmap from a raw json object. Throws away all entries that
1010
/// are not resolvable.
11-
Map createHitmap(List<Map> json) {
11+
Map<String, Map<int, int>> createHitmap(List<Map> json) {
1212
// Map of source file to map of line to hit count for that line.
1313
var globalHitMap = <String, Map<int, int>>{};
1414

@@ -51,8 +51,9 @@ Map createHitmap(List<Map> json) {
5151
}
5252

5353
/// Merges [newMap] into [result].
54-
void mergeHitmaps(Map newMap, Map result) {
55-
newMap.forEach((String file, Map v) {
54+
void mergeHitmaps(
55+
Map<String, Map<int, int>> newMap, Map<String, Map<int, int>> result) {
56+
newMap.forEach((String file, Map<int, int> v) {
5657
if (result.containsKey(file)) {
5758
v.forEach((int line, int cnt) {
5859
if (result[file][line] == null) {
@@ -69,7 +70,7 @@ void mergeHitmaps(Map newMap, Map result) {
6970

7071
/// Generates a merged hitmap from a set of coverage JSON files.
7172
Future<Map> parseCoverage(Iterable<File> files, int _) async {
72-
Map globalHitmap = <String, Map<int, int>>{};
73+
var globalHitmap = <String, Map<int, int>>{};
7374
for (var file in files) {
7475
String contents = file.readAsStringSync();
7576
List<Map<String, dynamic>> json = JSON.decode(contents)['coverage'];

lib/src/resolver.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ class Loader {
157157
final List<String> failed = [];
158158

159159
/// Loads an imported resource and returns a [Future] with a [List] of lines.
160-
/// Returns [null] if the resource could not be loaded.
160+
/// Returns `null` if the resource could not be loaded.
161161
Future<List<String>> load(String path) async {
162162
try {
163163
return new File(path).readAsLines();

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: coverage
2-
version: 0.9.4-dev
2+
version: 0.10.0-dev
33
author: Dart Team <[email protected]>
44
description: Coverage data manipulation and formatting
55
homepage: https://github.com/dart-lang/coverage

test/collect_coverage_api_test.dart

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ void main() {
2626
List coverage = json['coverage'];
2727
expect(coverage, isNotEmpty);
2828

29-
var sources = coverage.fold(<String, dynamic>{}, (Map map, Map value) {
29+
var sources = coverage.fold(<String, dynamic>{},
30+
(Map<String, dynamic> map, dynamic value) {
3031
String sourceUri = value['source'];
3132
map.putIfAbsent(sourceUri, () => <Map>[]).add(value);
3233
return map;

test/lcov_test.dart

-3
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,10 @@ import 'package:test/test.dart';
1313

1414
final _sampleAppPath = p.join('test', 'test_files', 'test_app.dart');
1515
final _isolateLibPath = p.join('test', 'test_files', 'test_app_isolate.dart');
16-
final _collectAppPath = p.join('bin', 'collect_coverage.dart');
1716

1817
final _sampleAppFileUri = p.toUri(p.absolute(_sampleAppPath)).toString();
1918
final _isolateLibFileUri = p.toUri(p.absolute(_isolateLibPath)).toString();
2019

21-
const _timeout = const Duration(seconds: 5);
22-
2320
void main() {
2421
test('validate hitMap', () async {
2522
var hitmap = await _getHitMap();

test/test_files/test_app_isolate.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Future<String> fooAsync(int x) async {
2323
/// The number of covered lines is tested and expected to be 4.
2424
///
2525
/// If you modify this method, you may have to update the tests!
26-
void isolateTask(List<dynamic> threeThings) {
26+
void isolateTask(dynamic threeThings) {
2727
sleep(const Duration(milliseconds: 500));
2828

2929
fooSync(42);

0 commit comments

Comments
 (0)