Skip to content

Commit f03a2c0

Browse files
authored
Fix analysis hints (#1740)
1 parent edc6b22 commit f03a2c0

File tree

7 files changed

+16
-13
lines changed

7 files changed

+16
-13
lines changed

lib/src/asset/dart/serialize/aggregate_transform.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,8 @@ class ForeignAggregateTransform extends _ForeignBaseAggregateTransform
136136
deserializeStream(transform['primaryInputs'], deserializeAsset),
137137
super(transform);
138138

139-
Future<Asset> getInput(AssetId id) {
140-
return call(_port, {'type': 'getInput', 'id': serializeId(id)})
141-
.then(deserializeAsset);
142-
}
139+
Future<Asset> getInput(AssetId id) async => deserializeAsset(
140+
await call(_port, {'type': 'getInput', 'id': serializeId(id)}));
143141

144142
void addOutput(Asset output) {
145143
call(_port, {'type': 'addOutput', 'output': serializeAsset(output)});

lib/src/asset/dart/serialize/transform.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,8 @@ class ForeignTransform extends _ForeignBaseTransform
115115
: primaryInput = deserializeAsset(transform['primaryInput']),
116116
super(transform);
117117

118-
Future<Asset> getInput(AssetId id) {
119-
return call(_port, {'type': 'getInput', 'id': serializeId(id)})
120-
.then(deserializeAsset);
121-
}
118+
Future<Asset> getInput(AssetId id) async => deserializeAsset(
119+
await call(_port, {'type': 'getInput', 'id': serializeId(id)}));
122120

123121
void addOutput(Asset output) {
124122
call(_port, {'type': 'addOutput', 'output': serializeAsset(output)});

lib/src/pubspec.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import 'dart:io';
66

77
import 'package:collection/collection.dart';
8+
import 'package:meta/meta.dart';
89
import 'package:path/path.dart' as path;
910
import 'package:pub_semver/pub_semver.dart';
1011
import 'package:source_span/source_span.dart';
@@ -879,6 +880,9 @@ class Pubspec {
879880
if (node == null || node.value == null) return new YamlList();
880881
if (node is YamlList) return node;
881882
_error('Must be a list.', node.span);
883+
884+
// TODO(nweiz): Remove this when sdk#31384 is fixed.
885+
throw "Unreachable";
882886
}
883887

884888
/// Runs [fn] and wraps any [FormatException] it throws in a
@@ -904,6 +908,7 @@ class Pubspec {
904908
}
905909

906910
/// Throws a [PubspecException] with the given message.
911+
@alwaysThrows
907912
void _error(String message, SourceSpan span) {
908913
throw new PubspecException(message, span);
909914
}

lib/src/source/hosted.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ class BoundHostedSource extends CachedSource {
220220
for (var serverDir in listDir(systemCacheRoot)) {
221221
var url = _directoryToUrl(p.basename(serverDir));
222222

223-
var packages = [];
223+
var packages = <Package>[];
224224
for (var entry in listDir(serverDir)) {
225225
try {
226226
packages.add(new Package.load(null, entry, systemCache.sources));

lib/src/utils.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,8 @@ Set<String> createDirectoryFilter(Iterable<String> dirs) {
321321
/// Returns the maximum value in [iter] by [compare].
322322
///
323323
/// [compare] defaults to [Comparable.compare].
324-
maxAll(Iterable iter, [int compare(element1, element2)]) {
325-
if (compare == null) compare = Comparable.compare;
324+
T maxAll<T>(Iterable<T> iter, [int compare(T value, T value2)]) {
325+
compare ??= (value1, value2) => (value1 as Comparable).compareTo(value2);
326326
return iter
327327
.reduce((max, element) => compare(element, max) > 0 ? element : max);
328328
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ dependencies:
2020
http_multi_server: ">=1.0.0 <3.0.0"
2121
http_throttle: "^1.0.0"
2222
json_rpc_2: "^2.0.0"
23-
meta: ">=0.12.2 <2.0.0"
23+
meta: "^1.1.0"
2424
mime: "^0.9.0"
2525
oauth2: "^1.0.0"
2626
package_config: "^1.0.0"

test/serve/utils.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,9 @@ Future _ensureWebSocket() async {
322322
var socket = await WebSocket.connect("ws://localhost:$_adminPort");
323323
_webSocket = socket;
324324
// TODO(rnystrom): Works around #13913.
325-
_webSocketBroadcastStream = _webSocket.map(JSON.decode).asBroadcastStream();
325+
_webSocketBroadcastStream = _webSocket
326+
.map((message) => JSON.decode(message as String))
327+
.asBroadcastStream();
326328
}
327329

328330
/// Closes the web socket connection to the currently-running pub serve.

0 commit comments

Comments
 (0)