mirror of
https://github.com/flutter/packages.git
synced 2025-08-06 00:42:13 +08:00
Switch script/tools over to the new analysis options (#3777)
Removes the legacy analysis options override and fixes all resulting issues. This is a combination of dart fix and manual changes (mostly mechanical, but some small restructuring to address warnings more cleanly, such as creating typed structs from args when they are used repeatedly to avoid repeated casting, or making things that were unnecessarily public private). One small opportunistic extra cleanup is that the handling of null-safety prerelease versions is removed, as any new plugin would be written null-safe from the start, so we no longer need to allow those versions. Part of flutter/flutter#76229
This commit is contained in:
@ -3,11 +3,13 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io' as io;
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:file/file.dart';
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:platform/platform.dart';
|
||||
import 'package:flutter_plugin_tools/src/common.dart';
|
||||
import 'package:quiver/collection.dart';
|
||||
@ -16,7 +18,7 @@ import 'package:quiver/collection.dart';
|
||||
// for each test, to eliminate the chance of files from one test interfering
|
||||
// with another test.
|
||||
FileSystem mockFileSystem = MemoryFileSystem(
|
||||
style: LocalPlatform().isWindows
|
||||
style: const LocalPlatform().isWindows
|
||||
? FileSystemStyle.windows
|
||||
: FileSystemStyle.posix);
|
||||
Directory mockPackagesDir;
|
||||
@ -83,20 +85,19 @@ Directory createFakePlugin(
|
||||
final Directory exampleDir = pluginDirectory.childDirectory('example')
|
||||
..createSync();
|
||||
createFakePubspec(exampleDir,
|
||||
name: "${name}_example", isFlutter: isFlutter);
|
||||
name: '${name}_example', isFlutter: isFlutter);
|
||||
} else if (withExamples.isNotEmpty) {
|
||||
final Directory exampleDir = pluginDirectory.childDirectory('example')
|
||||
..createSync();
|
||||
for (String example in withExamples) {
|
||||
for (final String example in withExamples) {
|
||||
final Directory currentExample = exampleDir.childDirectory(example)
|
||||
..createSync();
|
||||
createFakePubspec(currentExample, name: example, isFlutter: isFlutter);
|
||||
}
|
||||
}
|
||||
|
||||
for (List<String> file in withExtraFiles) {
|
||||
final List<String> newFilePath = <String>[pluginDirectory.path]
|
||||
..addAll(file);
|
||||
for (final List<String> file in withExtraFiles) {
|
||||
final List<String> newFilePath = <String>[pluginDirectory.path, ...file];
|
||||
final File newFile =
|
||||
mockFileSystem.file(mockFileSystem.path.joinAll(newFilePath));
|
||||
newFile.createSync(recursive: true);
|
||||
@ -195,7 +196,7 @@ void cleanupPackages() {
|
||||
/// Run the command [runner] with the given [args] and return
|
||||
/// what was printed.
|
||||
Future<List<String>> runCapturingPrint(
|
||||
CommandRunner<PluginCommand> runner, List<String> args) async {
|
||||
CommandRunner<void> runner, List<String> args) async {
|
||||
final List<String> prints = <String>[];
|
||||
final ZoneSpecification spec = ZoneSpecification(
|
||||
print: (_, __, ___, String message) {
|
||||
@ -237,8 +238,8 @@ class RecordingProcessRunner extends ProcessRunner {
|
||||
Future<io.ProcessResult> run(String executable, List<String> args,
|
||||
{Directory workingDir,
|
||||
bool exitOnError = false,
|
||||
stdoutEncoding = io.systemEncoding,
|
||||
stderrEncoding = io.systemEncoding}) async {
|
||||
Encoding stdoutEncoding = io.systemEncoding,
|
||||
Encoding stderrEncoding = io.systemEncoding}) async {
|
||||
recordedCalls.add(ProcessCall(executable, args, workingDir?.path));
|
||||
io.ProcessResult result;
|
||||
|
||||
@ -279,6 +280,7 @@ class RecordingProcessRunner extends ProcessRunner {
|
||||
}
|
||||
|
||||
/// A recorded process call.
|
||||
@immutable
|
||||
class ProcessCall {
|
||||
const ProcessCall(this.executable, this.args, this.workingDir);
|
||||
|
||||
@ -293,13 +295,10 @@ class ProcessCall {
|
||||
|
||||
@override
|
||||
bool operator ==(dynamic other) {
|
||||
if (other is! ProcessCall) {
|
||||
return false;
|
||||
}
|
||||
final ProcessCall otherCall = other;
|
||||
return executable == otherCall.executable &&
|
||||
listsEqual(args, otherCall.args) &&
|
||||
workingDir == otherCall.workingDir;
|
||||
return other is ProcessCall &&
|
||||
executable == other.executable &&
|
||||
listsEqual(args, other.args) &&
|
||||
workingDir == other.workingDir;
|
||||
}
|
||||
|
||||
@override
|
||||
@ -311,7 +310,7 @@ class ProcessCall {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
final List<String> command = <String>[executable]..addAll(args);
|
||||
final List<String> command = <String>[executable, ...args];
|
||||
return '"${command.join(' ')}" in $workingDir';
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user