dartdev: Enforce strict-raw-types
Change-Id: I593497edfbb05f0b524de4d18dc87ef7d1efdd2d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425583 Reviewed-by: Devon Carew <devoncarew@google.com> Commit-Queue: Samuel Rawlins <srawlins@google.com> Reviewed-by: Ben Konyi <bkonyi@google.com>
This commit is contained in:
committed by
Commit Queue
parent
9fa0f081cd
commit
06f5db3480
@@ -4,6 +4,8 @@ analyzer:
|
||||
errors:
|
||||
# Disable implementation_imports.
|
||||
implementation_imports: ignore
|
||||
language:
|
||||
strict-raw-types: true
|
||||
|
||||
linter:
|
||||
rules:
|
||||
|
||||
@@ -290,7 +290,7 @@ class AnalysisServer {
|
||||
_streamController(event).add(params.cast<String, dynamic>());
|
||||
}
|
||||
} else if (response case {'id': final String id}) {
|
||||
if (response case {'error': final Map error}) {
|
||||
if (response case {'error': final Map<String, Object?> error}) {
|
||||
_requestCompleters.remove(id)?.completeError(
|
||||
RequestError.parse(error.cast<String, dynamic>()));
|
||||
} else {
|
||||
|
||||
@@ -71,7 +71,7 @@ abstract class DartdevCommand extends Command<int> {
|
||||
ArgParser(usageLineLength: dartdevUsageLineLength);
|
||||
}
|
||||
|
||||
extension DartDevCommand on Command {
|
||||
extension DartDevCommand<T> on Command<T> {
|
||||
/// Return whether commands should emit verbose output.
|
||||
bool get verbose => globalResults!.flag('verbose');
|
||||
|
||||
@@ -105,7 +105,7 @@ Future<int> runProcess(
|
||||
void Function(String str)? listener,
|
||||
String? cwd,
|
||||
}) async {
|
||||
Future forward(Stream<List<int>> output, bool isStderr) {
|
||||
Future<void> forward(Stream<List<int>> output, bool isStderr) {
|
||||
return _streamLineTransform(output, (line) {
|
||||
final trimmed = line.trimRight();
|
||||
logToTrace
|
||||
@@ -129,7 +129,7 @@ Future<int> runProcess(
|
||||
return exitCode;
|
||||
}
|
||||
|
||||
Future _streamLineTransform(
|
||||
Future<void> _streamLineTransform(
|
||||
Stream<List<int>> stream,
|
||||
Function(String line) handler,
|
||||
) {
|
||||
|
||||
@@ -34,9 +34,8 @@ class DDSRunner {
|
||||
if (!isAot) {
|
||||
// On ia32 sdks we do not have an AOT runtime and so we would be
|
||||
// using the regular executable.
|
||||
snapshotName = fullSdk
|
||||
? sdk.ddsSnapshot
|
||||
: absolute(sdkDir, 'dds.dart.snapshot');
|
||||
snapshotName =
|
||||
fullSdk ? sdk.ddsSnapshot : absolute(sdkDir, 'dds.dart.snapshot');
|
||||
if (!Sdk.checkArtifactExists(snapshotName)) {
|
||||
return false;
|
||||
}
|
||||
@@ -64,7 +63,7 @@ class DDSRunner {
|
||||
const devToolsMessagePrefix =
|
||||
'The Dart DevTools debugger and profiler is available at:';
|
||||
if (debugDds) {
|
||||
late final StreamSubscription stdoutSub;
|
||||
late final StreamSubscription<String> stdoutSub;
|
||||
stdoutSub = process.stdout
|
||||
.transform(utf8.decoder)
|
||||
.transform(const LineSplitter())
|
||||
|
||||
@@ -16,11 +16,13 @@ import 'package:unified_analytics/unified_analytics.dart';
|
||||
import 'experiment_util.dart';
|
||||
import 'utils.dart';
|
||||
|
||||
List<Map> extractAnalytics(io.ProcessResult result) {
|
||||
List<Map<String, Object?>> extractAnalytics(io.ProcessResult result) {
|
||||
return LineSplitter.split(result.stderr)
|
||||
.where((line) => line.startsWith('[analytics]: '))
|
||||
.map((line) => json.decode(line.substring('[analytics]: '.length)) as Map)
|
||||
.toList();
|
||||
.map((line) {
|
||||
return (json.decode(line.substring('[analytics]: '.length)) as Map)
|
||||
.cast<String, Object?>();
|
||||
}).toList();
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
||||
@@ -122,8 +122,8 @@ void defineCreateTests() {
|
||||
|
||||
if (isLastCommand && (isServerTemplate || isWebTemplate)) {
|
||||
final completer = Completer<void>();
|
||||
late StreamSubscription stdoutSub;
|
||||
late StreamSubscription stderrSub;
|
||||
late final StreamSubscription<String> stdoutSub;
|
||||
late final StreamSubscription<String> stderrSub;
|
||||
// Listen for well-known output from specific templates to determine
|
||||
// if they've executed correctly. These templates won't exit on their
|
||||
// own, so we'll need to terminate the process once we've verified it
|
||||
|
||||
@@ -79,7 +79,7 @@ void devtools() {
|
||||
final devToolsServedCompleter = Completer<void>();
|
||||
final dtdServedCompleter = Completer<void>();
|
||||
|
||||
late StreamSubscription sub;
|
||||
late final StreamSubscription<String> sub;
|
||||
sub = process!.stdout
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
@@ -157,7 +157,7 @@ void devtools() {
|
||||
bool startedDds = false;
|
||||
bool startedDtd = false;
|
||||
final devToolsServedCompleter = Completer<void>();
|
||||
late StreamSubscription sub;
|
||||
late final StreamSubscription<String> sub;
|
||||
sub = process.stdout
|
||||
.transform<String>(utf8.decoder)
|
||||
.transform<String>(const LineSplitter())
|
||||
@@ -228,7 +228,7 @@ Future<void> main() async {
|
||||
);
|
||||
|
||||
final serviceUriCompleter = Completer<String>();
|
||||
late StreamSubscription sub;
|
||||
late final StreamSubscription<String> sub;
|
||||
sub = targetProjectInstance!.stdout
|
||||
.transform(utf8.decoder)
|
||||
.transform(const LineSplitter())
|
||||
|
||||
@@ -33,7 +33,7 @@ void command() {
|
||||
test('description formatting', () {
|
||||
DartdevRunner(['--suppress-analytics'])
|
||||
.commands
|
||||
.forEach((String commandKey, Command command) {
|
||||
.forEach((String commandKey, Command<int> command) {
|
||||
expect(commandKey, isNotEmpty);
|
||||
expect(command.description, isNotEmpty);
|
||||
expect(command.description.split('\n').first, endsWith('.'));
|
||||
@@ -45,7 +45,7 @@ void command() {
|
||||
test('argParser usageLineLength', () {
|
||||
DartdevRunner(['--suppress-analytics'])
|
||||
.commands
|
||||
.forEach((String commandKey, Command command) {
|
||||
.forEach((String commandKey, Command<int> command) {
|
||||
if (command.name != 'help' &&
|
||||
command.name != 'format' &&
|
||||
command.name != 'pub' &&
|
||||
|
||||
@@ -22,7 +22,7 @@ void help() {
|
||||
];
|
||||
DartdevRunner(['--suppress-analytics'])
|
||||
.commands
|
||||
.forEach((String commandKey, Command command) {
|
||||
.forEach((String commandKey, Command<int> command) {
|
||||
if (!commandsNotTested.contains(commandKey)) {
|
||||
test('(help $commandKey == $commandKey --help)', () async {
|
||||
p = project();
|
||||
@@ -57,7 +57,7 @@ void help() {
|
||||
test('(--help flags also have -h abbr)', () {
|
||||
DartdevRunner(['--suppress-analytics'])
|
||||
.commands
|
||||
.forEach((String commandKey, Command command) {
|
||||
.forEach((String commandKey, Command<int> command) {
|
||||
var helpOption = command.argParser.options['help'];
|
||||
// Some commands (like pub which use
|
||||
// "argParser = ArgParser.allowAnything()") may not have the help Option
|
||||
|
||||
@@ -27,7 +27,7 @@ void defineLanguageServerTests() {
|
||||
late utils.TestProject project;
|
||||
Process? process;
|
||||
|
||||
Future runWithLsp(List<String> args) async {
|
||||
Future<void> runWithLsp(List<String> args) async {
|
||||
project = utils.project();
|
||||
|
||||
process = await project.start(args);
|
||||
|
||||
@@ -531,7 +531,7 @@ void main(List<String> args) => print("$b $args");
|
||||
p.relativeFilePath,
|
||||
]);
|
||||
final completer = Completer<void>();
|
||||
late StreamSubscription sub;
|
||||
late final StreamSubscription<String> sub;
|
||||
sub = process.stdout.transform(utf8.decoder).listen((event) async {
|
||||
if (event.contains(dartVMServiceRegExp)) {
|
||||
await sub.cancel();
|
||||
@@ -834,7 +834,7 @@ main() => print('b:b');
|
||||
final readyCompleter = Completer<void>();
|
||||
final completer = Completer<void>();
|
||||
|
||||
late StreamSubscription sub;
|
||||
late final StreamSubscription<String> sub;
|
||||
sub = process.stdout.transform(utf8.decoder).listen((event) async {
|
||||
if (event.contains('ready')) {
|
||||
readyCompleter.complete();
|
||||
@@ -912,8 +912,8 @@ main() => print('b:b');
|
||||
|
||||
final completer = Completer<void>();
|
||||
|
||||
late StreamSubscription sub;
|
||||
late String uri;
|
||||
late final StreamSubscription<String> sub;
|
||||
late final String uri;
|
||||
sub = process.stdout.transform(utf8.decoder).listen((event) async {
|
||||
if (event.contains(dartVMServiceRegExp)) {
|
||||
uri = dartVMServiceRegExp.firstMatch(event)!.group(1)!;
|
||||
|
||||
@@ -185,7 +185,7 @@ void main() {
|
||||
RegExp(r'(http:\/\/127.0.0.1:\d*\/[\da-zA-Z-_]*=\/)');
|
||||
final process = await p.start(['test', '--pause-after-load']);
|
||||
final completer = Completer<Uri>();
|
||||
late StreamSubscription sub;
|
||||
late final StreamSubscription<String> sub;
|
||||
sub = process.stdout
|
||||
.transform(utf8.decoder)
|
||||
.transform(const LineSplitter())
|
||||
|
||||
@@ -107,7 +107,7 @@ void main() {
|
||||
],
|
||||
);
|
||||
final completer = Completer<void>();
|
||||
late StreamSubscription sub;
|
||||
late final StreamSubscription<String> sub;
|
||||
bool sawServiceMsg = false;
|
||||
void onData(event) {
|
||||
print(event);
|
||||
|
||||
@@ -55,7 +55,8 @@ void main(List<String> arguments) {
|
||||
|
||||
String sizeMB(int size) => '${(size / (1024.0 * 1024)).toStringAsFixed(1)}MB';
|
||||
|
||||
Map build(FileSystemEntity entity, {Map<String, String> extra = const {}}) {
|
||||
Map<String, Object?> build(FileSystemEntity entity,
|
||||
{Map<String, String> extra = const {}}) {
|
||||
const fsBlockSize = 4096.0;
|
||||
|
||||
if (entity is File) {
|
||||
|
||||
Reference in New Issue
Block a user