Finish removing null-safety mode, checks, and reporting. (#163153)

Closes https://github.com/flutter/flutter/issues/162846.

At HEAD, including before this PR, it was impossible to use, or pass-in,
an unsound null-safety mode, but we still had code checking for it, and
reported analytics (I think? Some of these are `package:usage` specific
which is defunct).

This PR eradicates the otherwise unused code.
This commit is contained in:
Matan Lurey
2025-02-12 13:52:02 -08:00
committed by GitHub
parent d2a60f6c22
commit 063f80d40f
27 changed files with 14 additions and 380 deletions

View File

@@ -103,35 +103,6 @@ void main() {
},
);
testUsingContext(
'supports --no-sound-null-safety with an overridden NonNullSafeBuilds',
() async {
fileSystem.file('lib/main.dart').createSync(recursive: true);
fileSystem.file('pubspec.yaml').createSync();
fileSystem.file('.dart_tool/package_config.json').createSync(recursive: true);
final FakeDevice device = FakeDevice(
isLocalEmulator: true,
platformType: PlatformType.android,
);
testDeviceManager.devices = <Device>[device];
final TestRunCommandThatOnlyValidates command = TestRunCommandThatOnlyValidates();
await createTestCommandRunner(command).run(const <String>[
'run',
'--use-application-binary=app/bar/faz',
'--no-sound-null-safety',
]);
},
overrides: <Type, Generator>{
DeviceManager: () => testDeviceManager,
FileSystem: () => fileSystem,
Logger: () => logger,
NonNullSafeBuilds: () => NonNullSafeBuilds.allowed,
ProcessManager: () => FakeProcessManager.any(),
},
);
testUsingContext(
'does not support "--use-application-binary" and "--fast-start"',
() async {

View File

@@ -287,7 +287,6 @@ void main() {
expect(buildInfo.splitDebugInfoPath, '/project-name/v1.2.3/');
expect(buildInfo.dartObfuscation, isTrue);
expect(buildInfo.dartDefines.contains('foo=bar'), isTrue);
expect(buildInfo.nullSafetyMode, NullSafetyMode.sound);
}, overrides: <Type, Generator>{AndroidBuilder: () => fakeAndroidBuilder});
});

View File

@@ -11,7 +11,6 @@ import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/signals.dart';
import 'package:flutter_tools/src/base/terminal.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/commands/attach.dart';
import 'package:flutter_tools/src/commands/build.dart';
@@ -97,20 +96,6 @@ void main() {
}
});
testUsingContext('BuildSubCommand displays current null safety mode', () async {
const BuildInfo unsound = BuildInfo(
BuildMode.debug,
'',
nullSafetyMode: NullSafetyMode.unsound,
treeShakeIcons: false,
packageConfigPath: '.dart_tool/package_config.json',
);
final BufferLogger logger = BufferLogger.test();
FakeBuildSubCommand(logger).test(unsound);
expect(logger.statusText, contains('Building without sound null safety ⚠️'));
});
testUsingContext('Include only supported sub commands', () {
final BufferLogger logger = BufferLogger.test();
final MemoryFileSystem fs = MemoryFileSystem.test();
@@ -126,22 +111,3 @@ void main() {
}
});
}
class FakeBuildSubCommand extends BuildSubCommand {
FakeBuildSubCommand(Logger logger) : super(logger: logger, verboseHelp: false);
@override
String get description => throw UnimplementedError();
@override
String get name => throw UnimplementedError();
void test(BuildInfo buildInfo) {
displayNullSafetyMode(buildInfo);
}
@override
Future<FlutterCommandResult> runCommand() {
throw UnimplementedError();
}
}

View File

@@ -2,10 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/doctor_validator.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
import 'package:package_config/package_config.dart';
import '../../src/common.dart';
@@ -58,100 +56,6 @@ void main() {
contains(const TestUsageEvent('doctor-result', 'FakeGroupedValidator', label: 'crash')),
);
});
testWithoutContext('Reports null safe analytics events', () {
final TestUsage usage = TestUsage();
final PackageConfig packageConfig = PackageConfig(<Package>[
Package('foo', Uri.parse('file:///foo/'), languageVersion: LanguageVersion(2, 12)),
Package('bar', Uri.parse('file:///fizz/'), languageVersion: LanguageVersion(2, 1)),
Package('baz', Uri.parse('file:///bar/'), languageVersion: LanguageVersion(2, 2)),
]);
NullSafetyAnalysisEvent(packageConfig, NullSafetyMode.sound, 'foo', usage).send();
expect(
usage.events,
unorderedEquals(<TestUsageEvent>[
const TestUsageEvent(
NullSafetyAnalysisEvent.kNullSafetyCategory,
'runtime-mode',
label: 'NullSafetyMode.sound',
),
TestUsageEvent(
NullSafetyAnalysisEvent.kNullSafetyCategory,
'stats',
parameters: CustomDimensions.fromMap(<String, String>{'cd49': '1', 'cd50': '3'}),
),
const TestUsageEvent(
NullSafetyAnalysisEvent.kNullSafetyCategory,
'language-version',
label: '2.12',
),
]),
);
});
testWithoutContext('Does not crash if main package is missing', () {
final TestUsage usage = TestUsage();
final PackageConfig packageConfig = PackageConfig(<Package>[
Package('foo', Uri.parse('file:///foo/lib/'), languageVersion: LanguageVersion(2, 12)),
Package('bar', Uri.parse('file:///fizz/lib/'), languageVersion: LanguageVersion(2, 1)),
Package('baz', Uri.parse('file:///bar/lib/'), languageVersion: LanguageVersion(2, 2)),
]);
NullSafetyAnalysisEvent(
packageConfig,
NullSafetyMode.sound,
'something-unrelated',
usage,
).send();
expect(
usage.events,
unorderedEquals(<TestUsageEvent>[
const TestUsageEvent(
NullSafetyAnalysisEvent.kNullSafetyCategory,
'runtime-mode',
label: 'NullSafetyMode.sound',
),
TestUsageEvent(
NullSafetyAnalysisEvent.kNullSafetyCategory,
'stats',
parameters: CustomDimensions.fromMap(<String, String>{'cd49': '1', 'cd50': '3'}),
),
]),
);
});
testWithoutContext('a null language version is treated as unmigrated', () {
final TestUsage usage = TestUsage();
final PackageConfig packageConfig = PackageConfig(<Package>[
Package('foo', Uri.parse('file:///foo/lib/')),
]);
NullSafetyAnalysisEvent(
packageConfig,
NullSafetyMode.sound,
'something-unrelated',
usage,
).send();
expect(
usage.events,
unorderedEquals(<TestUsageEvent>[
const TestUsageEvent(
NullSafetyAnalysisEvent.kNullSafetyCategory,
'runtime-mode',
label: 'NullSafetyMode.sound',
),
TestUsageEvent(
NullSafetyAnalysisEvent.kNullSafetyCategory,
'stats',
parameters: CustomDimensions.fromMap(<String, String>{'cd49': '0', 'cd50': '1'}),
),
]),
);
});
}
class FakeGroupedValidator extends GroupedValidator {

View File

@@ -916,7 +916,6 @@ void main() {
BuildMode.debug,
'',
treeShakeIcons: false,
nullSafetyMode: NullSafetyMode.unsound,
packageConfigPath: '.dart_tool/package_config.json',
),
enableDwds: false,