Skip to content

Commit 06f5db3

Browse files
srawlinsCommit Queue
authored andcommitted
dartdev: Enforce strict-raw-types
Change-Id: I593497edfbb05f0b524de4d18dc87ef7d1efdd2d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425583 Reviewed-by: Devon Carew <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]> Reviewed-by: Ben Konyi <[email protected]>
1 parent 9fa0f08 commit 06f5db3

14 files changed

+32
-28
lines changed

pkg/dartdev/analysis_options.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ analyzer:
44
errors:
55
# Disable implementation_imports.
66
implementation_imports: ignore
7+
language:
8+
strict-raw-types: true
79

810
linter:
911
rules:

pkg/dartdev/lib/src/analysis_server.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ class AnalysisServer {
290290
_streamController(event).add(params.cast<String, dynamic>());
291291
}
292292
} else if (response case {'id': final String id}) {
293-
if (response case {'error': final Map error}) {
293+
if (response case {'error': final Map<String, Object?> error}) {
294294
_requestCompleters.remove(id)?.completeError(
295295
RequestError.parse(error.cast<String, dynamic>()));
296296
} else {

pkg/dartdev/lib/src/core.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ abstract class DartdevCommand extends Command<int> {
7171
ArgParser(usageLineLength: dartdevUsageLineLength);
7272
}
7373

74-
extension DartDevCommand on Command {
74+
extension DartDevCommand<T> on Command<T> {
7575
/// Return whether commands should emit verbose output.
7676
bool get verbose => globalResults!.flag('verbose');
7777

@@ -105,7 +105,7 @@ Future<int> runProcess(
105105
void Function(String str)? listener,
106106
String? cwd,
107107
}) async {
108-
Future forward(Stream<List<int>> output, bool isStderr) {
108+
Future<void> forward(Stream<List<int>> output, bool isStderr) {
109109
return _streamLineTransform(output, (line) {
110110
final trimmed = line.trimRight();
111111
logToTrace
@@ -129,7 +129,7 @@ Future<int> runProcess(
129129
return exitCode;
130130
}
131131

132-
Future _streamLineTransform(
132+
Future<void> _streamLineTransform(
133133
Stream<List<int>> stream,
134134
Function(String line) handler,
135135
) {

pkg/dartdev/lib/src/dds_runner.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@ class DDSRunner {
3434
if (!isAot) {
3535
// On ia32 sdks we do not have an AOT runtime and so we would be
3636
// using the regular executable.
37-
snapshotName = fullSdk
38-
? sdk.ddsSnapshot
39-
: absolute(sdkDir, 'dds.dart.snapshot');
37+
snapshotName =
38+
fullSdk ? sdk.ddsSnapshot : absolute(sdkDir, 'dds.dart.snapshot');
4039
if (!Sdk.checkArtifactExists(snapshotName)) {
4140
return false;
4241
}
@@ -64,7 +63,7 @@ class DDSRunner {
6463
const devToolsMessagePrefix =
6564
'The Dart DevTools debugger and profiler is available at:';
6665
if (debugDds) {
67-
late final StreamSubscription stdoutSub;
66+
late final StreamSubscription<String> stdoutSub;
6867
stdoutSub = process.stdout
6968
.transform(utf8.decoder)
7069
.transform(const LineSplitter())

pkg/dartdev/test/analytics_test.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ import 'package:unified_analytics/unified_analytics.dart';
1616
import 'experiment_util.dart';
1717
import 'utils.dart';
1818

19-
List<Map> extractAnalytics(io.ProcessResult result) {
19+
List<Map<String, Object?>> extractAnalytics(io.ProcessResult result) {
2020
return LineSplitter.split(result.stderr)
2121
.where((line) => line.startsWith('[analytics]: '))
22-
.map((line) => json.decode(line.substring('[analytics]: '.length)) as Map)
23-
.toList();
22+
.map((line) {
23+
return (json.decode(line.substring('[analytics]: '.length)) as Map)
24+
.cast<String, Object?>();
25+
}).toList();
2426
}
2527

2628
void main() {

pkg/dartdev/test/commands/create_integration_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ void defineCreateTests() {
122122

123123
if (isLastCommand && (isServerTemplate || isWebTemplate)) {
124124
final completer = Completer<void>();
125-
late StreamSubscription stdoutSub;
126-
late StreamSubscription stderrSub;
125+
late final StreamSubscription<String> stdoutSub;
126+
late final StreamSubscription<String> stderrSub;
127127
// Listen for well-known output from specific templates to determine
128128
// if they've executed correctly. These templates won't exit on their
129129
// own, so we'll need to terminate the process once we've verified it

pkg/dartdev/test/commands/devtools_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void devtools() {
7979
final devToolsServedCompleter = Completer<void>();
8080
final dtdServedCompleter = Completer<void>();
8181

82-
late StreamSubscription sub;
82+
late final StreamSubscription<String> sub;
8383
sub = process!.stdout
8484
.transform<String>(utf8.decoder)
8585
.transform<String>(const LineSplitter())
@@ -157,7 +157,7 @@ void devtools() {
157157
bool startedDds = false;
158158
bool startedDtd = false;
159159
final devToolsServedCompleter = Completer<void>();
160-
late StreamSubscription sub;
160+
late final StreamSubscription<String> sub;
161161
sub = process.stdout
162162
.transform<String>(utf8.decoder)
163163
.transform<String>(const LineSplitter())
@@ -228,7 +228,7 @@ Future<void> main() async {
228228
);
229229

230230
final serviceUriCompleter = Completer<String>();
231-
late StreamSubscription sub;
231+
late final StreamSubscription<String> sub;
232232
sub = targetProjectInstance!.stdout
233233
.transform(utf8.decoder)
234234
.transform(const LineSplitter())

pkg/dartdev/test/commands/flag_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void command() {
3333
test('description formatting', () {
3434
DartdevRunner(['--suppress-analytics'])
3535
.commands
36-
.forEach((String commandKey, Command command) {
36+
.forEach((String commandKey, Command<int> command) {
3737
expect(commandKey, isNotEmpty);
3838
expect(command.description, isNotEmpty);
3939
expect(command.description.split('\n').first, endsWith('.'));
@@ -45,7 +45,7 @@ void command() {
4545
test('argParser usageLineLength', () {
4646
DartdevRunner(['--suppress-analytics'])
4747
.commands
48-
.forEach((String commandKey, Command command) {
48+
.forEach((String commandKey, Command<int> command) {
4949
if (command.name != 'help' &&
5050
command.name != 'format' &&
5151
command.name != 'pub' &&

pkg/dartdev/test/commands/help_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void help() {
2222
];
2323
DartdevRunner(['--suppress-analytics'])
2424
.commands
25-
.forEach((String commandKey, Command command) {
25+
.forEach((String commandKey, Command<int> command) {
2626
if (!commandsNotTested.contains(commandKey)) {
2727
test('(help $commandKey == $commandKey --help)', () async {
2828
p = project();
@@ -57,7 +57,7 @@ void help() {
5757
test('(--help flags also have -h abbr)', () {
5858
DartdevRunner(['--suppress-analytics'])
5959
.commands
60-
.forEach((String commandKey, Command command) {
60+
.forEach((String commandKey, Command<int> command) {
6161
var helpOption = command.argParser.options['help'];
6262
// Some commands (like pub which use
6363
// "argParser = ArgParser.allowAnything()") may not have the help Option

pkg/dartdev/test/commands/language_server_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void defineLanguageServerTests() {
2727
late utils.TestProject project;
2828
Process? process;
2929

30-
Future runWithLsp(List<String> args) async {
30+
Future<void> runWithLsp(List<String> args) async {
3131
project = utils.project();
3232

3333
process = await project.start(args);

0 commit comments

Comments
 (0)