Unverified Commit b5e7fb07 authored by Phil Quitslund's avatar Phil Quitslund Committed by GitHub

[flutter_tools] rename local functions with `_`s (#102688)

parent a03f59cd
......@@ -249,7 +249,7 @@ class AndroidStudio implements Comparable<AndroidStudio> {
static List<AndroidStudio> _allMacOS() {
final List<FileSystemEntity> candidatePaths = <FileSystemEntity>[];
void _checkForStudio(String path) {
void checkForStudio(String path) {
if (!globals.fs.isDirectorySync(path)) {
return;
}
......@@ -264,7 +264,7 @@ class AndroidStudio implements Comparable<AndroidStudio> {
if (name.startsWith('Android Studio') && name.endsWith('.app')) {
candidatePaths.add(directory);
} else if (!directory.path.endsWith('.app')) {
_checkForStudio(directory.path);
checkForStudio(directory.path);
}
}
} on Exception catch (e) {
......@@ -272,10 +272,10 @@ class AndroidStudio implements Comparable<AndroidStudio> {
}
}
_checkForStudio('/Applications');
checkForStudio('/Applications');
final String? homeDirPath = globals.fsUtils.homeDirPath;
if (homeDirPath != null) {
_checkForStudio(globals.fs.path.join(
checkForStudio(globals.fs.path.join(
homeDirPath,
'Applications',
));
......@@ -321,7 +321,7 @@ class AndroidStudio implements Comparable<AndroidStudio> {
static List<AndroidStudio> _allLinuxOrWindows() {
final List<AndroidStudio> studios = <AndroidStudio>[];
bool _hasStudioAt(String path, { Version? newerThan }) {
bool hasStudioAt(String path, { Version? newerThan }) {
return studios.any((AndroidStudio studio) {
if (studio.directory != path) {
return false;
......@@ -363,7 +363,7 @@ class AndroidStudio implements Comparable<AndroidStudio> {
for (final Directory entity in entities) {
final AndroidStudio? studio = AndroidStudio.fromHomeDot(entity);
if (studio != null && !_hasStudioAt(studio.directory, newerThan: studio.version)) {
if (studio != null && !hasStudioAt(studio.directory, newerThan: studio.version)) {
studios.removeWhere((AndroidStudio other) => other.directory == studio.directory);
studios.add(studio);
}
......@@ -394,7 +394,7 @@ class AndroidStudio implements Comparable<AndroidStudio> {
version: Version.parse(version),
studioAppName: title,
);
if (studio != null && !_hasStudioAt(studio.directory, newerThan: studio.version)) {
if (studio != null && !hasStudioAt(studio.directory, newerThan: studio.version)) {
studios.removeWhere((AndroidStudio other) => other.directory == studio.directory);
studios.add(studio);
}
......@@ -405,21 +405,21 @@ class AndroidStudio implements Comparable<AndroidStudio> {
}
final String? configuredStudioDir = globals.config.getValue('android-studio-dir') as String?;
if (configuredStudioDir != null && !_hasStudioAt(configuredStudioDir)) {
if (configuredStudioDir != null && !hasStudioAt(configuredStudioDir)) {
studios.add(AndroidStudio(configuredStudioDir,
configured: configuredStudioDir));
}
if (globals.platform.isLinux) {
void _checkWellKnownPath(String path) {
if (globals.fs.isDirectorySync(path) && !_hasStudioAt(path)) {
void checkWellKnownPath(String path) {
if (globals.fs.isDirectorySync(path) && !hasStudioAt(path)) {
studios.add(AndroidStudio(path));
}
}
// Add /opt/android-studio and $HOME/android-studio, if they exist.
_checkWellKnownPath('/opt/android-studio');
_checkWellKnownPath('${globals.fsUtils.homeDirPath}/android-studio');
checkWellKnownPath('/opt/android-studio');
checkWellKnownPath('${globals.fsUtils.homeDirPath}/android-studio');
}
return studios;
}
......
......@@ -366,7 +366,7 @@ class AndroidLicenseValidator extends DoctorValidator {
Future<LicensesAccepted> get licensesAccepted async {
LicensesAccepted? status;
void _handleLine(String line) {
void handleLine(String line) {
if (licenseCounts.hasMatch(line)) {
final Match? match = licenseCounts.firstMatch(line);
if (match?.group(1) != match?.group(2)) {
......@@ -399,12 +399,12 @@ class AndroidLicenseValidator extends DoctorValidator {
final Future<void> output = process.stdout
.transform<String>(const Utf8Decoder(reportErrors: false))
.transform<String>(const LineSplitter())
.listen(_handleLine)
.listen(handleLine)
.asFuture<void>(null);
final Future<void> errors = process.stderr
.transform<String>(const Utf8Decoder(reportErrors: false))
.transform<String>(const LineSplitter())
.listen(_handleLine)
.listen(handleLine)
.asFuture<void>(null);
await Future.wait<void>(<Future<void>>[output, errors]);
return status ?? LicensesAccepted.unknown;
......
......@@ -46,21 +46,21 @@ Future<void> validateBitcode(BuildMode buildMode, TargetPlatform targetPlatform,
Version _parseVersionFromClang(String? clangVersion) {
final RegExp pattern = RegExp(r'Apple (LLVM|clang) version (\d+\.\d+\.\d+) ');
Never _invalid() {
Never invalid() {
throwToolExit('Unable to parse Clang version from "$clangVersion". '
'Expected a string like "Apple (LLVM|clang) #.#.# (clang-####.#.##.#)".');
}
if (clangVersion == null || clangVersion.isEmpty) {
_invalid();
invalid();
}
final RegExpMatch? match = pattern.firstMatch(clangVersion);
if (match == null || match.groupCount != 2) {
_invalid();
invalid();
}
final Version? version = Version.parse(match.group(2));
if (version == null) {
_invalid();
invalid();
}
return version;
}
......@@ -301,7 +301,7 @@ class XcodeProjectInterpreter {
const int missingProjectExitCode = 66;
// The exit code returned by 'xcodebuild -list' when the project is corrupted.
const int corruptedProjectExitCode = 74;
bool _allowedFailures(int c) => c == missingProjectExitCode || c == corruptedProjectExitCode;
bool allowedFailures(int c) => c == missingProjectExitCode || c == corruptedProjectExitCode;
final RunResult result = await _processUtils.run(
<String>[
...xcrunCommand(),
......@@ -310,10 +310,10 @@ class XcodeProjectInterpreter {
if (projectFilename != null) ...<String>['-project', projectFilename],
],
throwOnError: true,
allowedFailures: _allowedFailures,
allowedFailures: allowedFailures,
workingDirectory: projectPath,
);
if (_allowedFailures(result.exitCode)) {
if (allowedFailures(result.exitCode)) {
// User configuration error, tool exit instead of crashing.
throwToolExit('Unable to get Xcode project information:\n ${result.stderr}');
}
......
......@@ -254,7 +254,7 @@ class WebAssetServer implements AssetReader {
// Return a version string for all active modules. This is populated
// along with the `moduleProvider` update logic.
Future<Map<String, String>> _digestProvider() async => digests;
Future<Map<String, String>> digestProvider() async => digests;
// Ensure dwds is present and provide middleware to avoid trying to
// load the through the isolate APIs.
......@@ -295,7 +295,7 @@ class WebAssetServer implements AssetReader {
loadStrategy: FrontendServerRequireStrategyProvider(
ReloadConfiguration.none,
server,
_digestProvider,
digestProvider,
).strategy,
expressionCompiler: expressionCompiler,
spawnDds: enableDds,
......
......@@ -358,7 +358,7 @@ class Message {
if (attributes == null) {
void _throwEmptyAttributes(final RegExp regExp, final String type) {
void throwEmptyAttributes(final RegExp regExp, final String type) {
final RegExpMatch? match = regExp.firstMatch(_value(bundle, resourceId));
final bool isMatch = match != null && match.groupCount == 1;
if (isMatch) {
......@@ -369,8 +369,8 @@ class Message {
}
}
_throwEmptyAttributes(_pluralRE, 'plural');
_throwEmptyAttributes(_selectRE, 'select');
throwEmptyAttributes(_pluralRE, 'plural');
throwEmptyAttributes(_selectRE, 'select');
}
return attributes as Map<String, Object?>?;
......
......@@ -55,7 +55,7 @@ void main() {
});
void _createSampleProject(Directory directory, { bool brokenCode = false }) {
void createSampleProject(Directory directory, { bool brokenCode = false }) {
final File pubspecFile = fileSystem.file(fileSystem.path.join(directory.path, 'pubspec.yaml'));
pubspecFile.writeAsStringSync('''
name: foo_project
......@@ -75,7 +75,7 @@ void main() {
group('analyze --watch', () {
testUsingContext('AnalysisServer success', () async {
_createSampleProject(tempDir);
createSampleProject(tempDir);
final Pub pub = Pub(
fileSystem: fileSystem,
......@@ -113,7 +113,7 @@ void main() {
});
testUsingContext('AnalysisServer errors', () async {
_createSampleProject(tempDir, brokenCode: true);
createSampleProject(tempDir, brokenCode: true);
final Pub pub = Pub(
fileSystem: fileSystem,
......
......@@ -22,7 +22,7 @@ void main() {
Directory intellijDir;
Directory toolsDir;
Map<String, String> _getFilesystemContents([ Directory root ]) {
Map<String, String> getFilesystemContents([ Directory root ]) {
final String tempPath = tempDir.absolute.path;
final List<String> paths =
(root ?? tempDir).listSync(recursive: true).map((FileSystemEntity entity) {
......@@ -41,7 +41,7 @@ void main() {
return contents;
}
Map<String, String> _getManifest(Directory base, String marker, { bool isTemplate = false }) {
Map<String, String> getManifest(Directory base, String marker, { bool isTemplate = false }) {
final String basePath = globals.fs.path.relative(base.path, from: tempDir.absolute.path);
final String suffix = isTemplate ? Template.copyTemplateExtension : '';
return <String, String>{
......@@ -57,7 +57,7 @@ void main() {
};
}
void _populateDir(Map<String, String> manifest) {
void populateDir(Map<String, String> manifest) {
for (final String key in manifest.keys) {
if (manifest[key] == 'dir') {
tempDir.childDirectory(key).createSync(recursive: true);
......@@ -72,12 +72,12 @@ void main() {
}
}
bool _fileOrDirectoryExists(String path) {
bool fileOrDirectoryExists(String path) {
final String absPath = globals.fs.path.join(tempDir.absolute.path, path);
return globals.fs.file(absPath).existsSync() || globals.fs.directory(absPath).existsSync();
}
Future<void> _updateIdeConfig({
Future<void> updateIdeConfig({
Directory dir,
List<String> args = const <String>[],
Map<String, String> expectedContents = const <String, String>{},
......@@ -94,7 +94,7 @@ void main() {
for (final String path in expectedContents.keys) {
final String absPath = globals.fs.path.join(tempDir.absolute.path, path);
expect(_fileOrDirectoryExists(globals.fs.path.join(dir.path, path)), true,
expect(fileOrDirectoryExists(globals.fs.path.join(dir.path, path)), true,
reason: "$path doesn't exist");
if (globals.fs.file(absPath).existsSync()) {
expect(globals.fs.file(absPath).readAsStringSync(), equals(expectedContents[path]),
......@@ -102,7 +102,7 @@ void main() {
}
}
for (final String path in unexpectedPaths) {
expect(_fileOrDirectoryExists(globals.fs.path.join(dir.path, path)), false, reason: '$path exists');
expect(fileOrDirectoryExists(globals.fs.path.join(dir.path, path)), false, reason: '$path exists');
}
}
......@@ -123,56 +123,56 @@ void main() {
});
testUsingContext("doesn't touch existing files without --overwrite", () async {
final Map<String, String> templateManifest = _getManifest(
final Map<String, String> templateManifest = getManifest(
intellijDir,
'template',
isTemplate: true,
);
final Map<String, String> flutterManifest = _getManifest(
final Map<String, String> flutterManifest = getManifest(
tempDir,
'existing',
);
_populateDir(templateManifest);
_populateDir(flutterManifest);
final Map<String, String> expectedContents = _getFilesystemContents();
return _updateIdeConfig(
populateDir(templateManifest);
populateDir(flutterManifest);
final Map<String, String> expectedContents = getFilesystemContents();
return updateIdeConfig(
expectedContents: expectedContents,
);
});
testUsingContext('creates non-existent files', () async {
final Map<String, String> templateManifest = _getManifest(
final Map<String, String> templateManifest = getManifest(
intellijDir,
'template',
isTemplate: true,
);
final Map<String, String> flutterManifest = _getManifest(
final Map<String, String> flutterManifest = getManifest(
tempDir,
'template',
);
_populateDir(templateManifest);
populateDir(templateManifest);
final Map<String, String> expectedContents = <String, String>{
...templateManifest,
...flutterManifest,
};
return _updateIdeConfig(
return updateIdeConfig(
expectedContents: expectedContents,
);
});
testUsingContext('overwrites existing files with --overwrite', () async {
final Map<String, String> templateManifest = _getManifest(
final Map<String, String> templateManifest = getManifest(
intellijDir,
'template',
isTemplate: true,
);
final Map<String, String> flutterManifest = _getManifest(
final Map<String, String> flutterManifest = getManifest(
tempDir,
'existing',
);
_populateDir(templateManifest);
_populateDir(flutterManifest);
final Map<String, String> overwrittenManifest = _getManifest(
populateDir(templateManifest);
populateDir(flutterManifest);
final Map<String, String> overwrittenManifest = getManifest(
tempDir,
'template',
);
......@@ -180,14 +180,14 @@ void main() {
...templateManifest,
...overwrittenManifest,
};
return _updateIdeConfig(
return updateIdeConfig(
args: <String>['--overwrite'],
expectedContents: expectedContents,
);
});
testUsingContext('only adds new templates without --overwrite', () async {
final Map<String, String> templateManifest = _getManifest(
final Map<String, String> templateManifest = getManifest(
intellijDir,
'template',
isTemplate: true,
......@@ -200,36 +200,36 @@ void main() {
'flutter.iml${Template.copyTemplateExtension}',
);
templateManifest.remove(flutterIml);
_populateDir(templateManifest);
populateDir(templateManifest);
templateManifest[flutterIml] = 'flutter existing';
final Map<String, String> flutterManifest = _getManifest(
final Map<String, String> flutterManifest = getManifest(
tempDir,
'existing',
);
_populateDir(flutterManifest);
populateDir(flutterManifest);
final Map<String, String> expectedContents = <String, String>{
...flutterManifest,
...templateManifest,
};
return _updateIdeConfig(
return updateIdeConfig(
args: <String>['--update-templates'],
expectedContents: expectedContents,
);
});
testUsingContext('update all templates with --overwrite', () async {
final Map<String, String> templateManifest = _getManifest(
final Map<String, String> templateManifest = getManifest(
intellijDir,
'template',
isTemplate: true,
);
_populateDir(templateManifest);
final Map<String, String> flutterManifest = _getManifest(
populateDir(templateManifest);
final Map<String, String> flutterManifest = getManifest(
tempDir,
'existing',
);
_populateDir(flutterManifest);
final Map<String, String> updatedTemplates = _getManifest(
populateDir(flutterManifest);
final Map<String, String> updatedTemplates = getManifest(
intellijDir,
'existing',
isTemplate: true,
......@@ -238,26 +238,26 @@ void main() {
...flutterManifest,
...updatedTemplates,
};
return _updateIdeConfig(
return updateIdeConfig(
args: <String>['--update-templates', '--overwrite'],
expectedContents: expectedContents,
);
});
testUsingContext('removes deleted imls with --overwrite', () async {
final Map<String, String> templateManifest = _getManifest(
final Map<String, String> templateManifest = getManifest(
intellijDir,
'template',
isTemplate: true,
);
_populateDir(templateManifest);
final Map<String, String> flutterManifest = _getManifest(
populateDir(templateManifest);
final Map<String, String> flutterManifest = getManifest(
tempDir,
'existing',
);
flutterManifest.remove('flutter.iml');
_populateDir(flutterManifest);
final Map<String, String> updatedTemplates = _getManifest(
populateDir(flutterManifest);
final Map<String, String> updatedTemplates = getManifest(
intellijDir,
'existing',
isTemplate: true,
......@@ -274,26 +274,26 @@ void main() {
...flutterManifest,
...updatedTemplates,
};
return _updateIdeConfig(
return updateIdeConfig(
args: <String>['--update-templates', '--overwrite'],
expectedContents: expectedContents,
);
});
testUsingContext('removes deleted imls with --overwrite, including empty parent dirs', () async {
final Map<String, String> templateManifest = _getManifest(
final Map<String, String> templateManifest = getManifest(
intellijDir,
'template',
isTemplate: true,
);
_populateDir(templateManifest);
final Map<String, String> flutterManifest = _getManifest(
populateDir(templateManifest);
final Map<String, String> flutterManifest = getManifest(
tempDir,
'existing',
);
flutterManifest.remove(globals.fs.path.join('packages', 'new', 'deep.iml'));
_populateDir(flutterManifest);
final Map<String, String> updatedTemplates = _getManifest(
populateDir(flutterManifest);
final Map<String, String> updatedTemplates = getManifest(
intellijDir,
'existing',
isTemplate: true,
......@@ -315,7 +315,7 @@ void main() {
...flutterManifest,
...updatedTemplates,
};
return _updateIdeConfig(
return updateIdeConfig(
args: <String>['--update-templates', '--overwrite'],
expectedContents: expectedContents,
);
......
......@@ -14,7 +14,7 @@ void main() {
final FakePlatform linuxPlatform = FakePlatform();
final FakePlatform windowsPlatform = FakePlatform(operatingSystem: 'windows');
void _checkInstallationURL(_InstallationMessage message) {
void checkInstallationURL(_InstallationMessage message) {
expect(message(macPlatform), contains('https://flutter.dev/docs/get-started/install/macos#android-setup'));
expect(message(linuxPlatform), contains('https://flutter.dev/docs/get-started/install/linux#android-setup'));
expect(message(windowsPlatform), contains('https://flutter.dev/docs/get-started/install/windows#android-setup'));
......@@ -23,11 +23,11 @@ void main() {
testWithoutContext('Android installation instructions', () {
final UserMessages userMessages = UserMessages();
_checkInstallationURL((Platform platform) => userMessages.androidMissingSdkInstructions(platform));
_checkInstallationURL((Platform platform) => userMessages.androidSdkInstallHelp(platform));
_checkInstallationURL((Platform platform) => userMessages.androidMissingSdkManager('/', platform));
_checkInstallationURL((Platform platform) => userMessages.androidCannotRunSdkManager('/', '', platform));
_checkInstallationURL((Platform platform) => userMessages.androidSdkBuildToolsOutdated(0, '', platform));
_checkInstallationURL((Platform platform) => userMessages.androidStudioInstallation(platform));
checkInstallationURL((Platform platform) => userMessages.androidMissingSdkInstructions(platform));
checkInstallationURL((Platform platform) => userMessages.androidSdkInstallHelp(platform));
checkInstallationURL((Platform platform) => userMessages.androidMissingSdkManager('/', platform));
checkInstallationURL((Platform platform) => userMessages.androidCannotRunSdkManager('/', '', platform));
checkInstallationURL((Platform platform) => userMessages.androidSdkBuildToolsOutdated(0, '', platform));
checkInstallationURL((Platform platform) => userMessages.androidStudioInstallation(platform));
});
}
......@@ -35,7 +35,7 @@ void main() {
late String fontSubsetPath;
late List<String> fontSubsetArgs;
List<String> _getConstFinderArgs(String appDillPath) => <String>[
List<String> getConstFinderArgs(String appDillPath) => <String>[
dartPath,
'--disable-dart-dev',
constFinderPath,
......@@ -44,21 +44,21 @@ void main() {
'--class-name', 'IconData',
];
void _addConstFinderInvocation(
void addConstFinderInvocation(
String appDillPath, {
int exitCode = 0,
String stdout = '',
String stderr = '',
}) {
processManager.addCommand(FakeCommand(
command: _getConstFinderArgs(appDillPath),
command: getConstFinderArgs(appDillPath),
exitCode: exitCode,
stdout: stdout,
stderr: stderr,
));
}
void _resetFontSubsetInvocation({
void resetFontSubsetInvocation({
int exitCode = 0,
String stdout = '',
String stderr = '',
......@@ -99,7 +99,7 @@ void main() {
..writeAsBytesSync(_kTtfHeaderBytes);
});
Environment _createEnvironment(Map<String, String> defines) {
Environment createEnvironment(Map<String, String> defines) {
return Environment.test(
fileSystem.directory('/icon_test')..createSync(recursive: true),
defines: defines,
......@@ -111,7 +111,7 @@ void main() {
}
testWithoutContext('Prints error in debug mode environment', () async {
final Environment environment = _createEnvironment(<String, String>{
final Environment environment = createEnvironment(<String, String>{
kIconTreeShakerFlag: 'true',
kBuildMode: 'debug',
});
......@@ -142,7 +142,7 @@ void main() {
});
testWithoutContext('Does not get enabled without font manifest', () {
final Environment environment = _createEnvironment(<String, String>{
final Environment environment = createEnvironment(<String, String>{
kIconTreeShakerFlag: 'true',
kBuildMode: 'release',
});
......@@ -165,7 +165,7 @@ void main() {
});
testWithoutContext('Gets enabled', () {
final Environment environment = _createEnvironment(<String, String>{
final Environment environment = createEnvironment(<String, String>{
kIconTreeShakerFlag: 'true',
kBuildMode: 'release',
});
......@@ -188,7 +188,7 @@ void main() {
});
test('No app.dill throws exception', () async {
final Environment environment = _createEnvironment(<String, String>{
final Environment environment = createEnvironment(<String, String>{
kIconTreeShakerFlag: 'true',
kBuildMode: 'release',
});
......@@ -214,7 +214,7 @@ void main() {
});
testWithoutContext('Can subset a font', () async {
final Environment environment = _createEnvironment(<String, String>{
final Environment environment = createEnvironment(<String, String>{
kIconTreeShakerFlag: 'true',
kBuildMode: 'release',
});
......@@ -231,8 +231,8 @@ void main() {
);
final CompleterIOSink stdinSink = CompleterIOSink();
_addConstFinderInvocation(appDill.path, stdout: validConstFinderResult);
_resetFontSubsetInvocation(stdinSink: stdinSink);
addConstFinderInvocation(appDill.path, stdout: validConstFinderResult);
resetFontSubsetInvocation(stdinSink: stdinSink);
bool subsetted = await iconTreeShaker.subsetFont(
input: fileSystem.file(inputPath),
......@@ -240,7 +240,7 @@ void main() {
relativePath: relativePath,
);
expect(stdinSink.getAndClear(), '59470\n');
_resetFontSubsetInvocation(stdinSink: stdinSink);
resetFontSubsetInvocation(stdinSink: stdinSink);
expect(subsetted, true);
subsetted = await iconTreeShaker.subsetFont(
......@@ -254,7 +254,7 @@ void main() {
});
testWithoutContext('Does not subset a non-supported font', () async {
final Environment environment = _createEnvironment(<String, String>{
final Environment environment = createEnvironment(<String, String>{
kIconTreeShakerFlag: 'true',
kBuildMode: 'release',
});
......@@ -271,8 +271,8 @@ void main() {
);
final CompleterIOSink stdinSink = CompleterIOSink();
_addConstFinderInvocation(appDill.path, stdout: validConstFinderResult);
_resetFontSubsetInvocation(stdinSink: stdinSink);
addConstFinderInvocation(appDill.path, stdout: validConstFinderResult);
resetFontSubsetInvocation(stdinSink: stdinSink);
final File notAFont = fileSystem.file('input/foo/bar.txt')
..createSync(recursive: true)
......@@ -286,7 +286,7 @@ void main() {
});
testWithoutContext('Does not subset an invalid ttf font', () async {
final Environment environment = _createEnvironment(<String, String>{
final Environment environment = createEnvironment(<String, String>{
kIconTreeShakerFlag: 'true',
kBuildMode: 'release',
});
......@@ -303,8 +303,8 @@ void main() {
);
final CompleterIOSink stdinSink = CompleterIOSink();
_addConstFinderInvocation(appDill.path, stdout: validConstFinderResult);
_resetFontSubsetInvocation(stdinSink: stdinSink);
addConstFinderInvocation(appDill.path, stdout: validConstFinderResult);
resetFontSubsetInvocation(stdinSink: stdinSink);
final File notAFont = fileSystem.file(inputPath)
..writeAsBytesSync(<int>[0, 1, 2]);
......@@ -318,7 +318,7 @@ void main() {
});
testWithoutContext('Non-constant instances', () async {
final Environment environment = _createEnvironment(<String, String>{
final Environment environment = createEnvironment(<String, String>{
kIconTreeShakerFlag: 'true',
kBuildMode: 'release',
});
......@@ -334,7 +334,7 @@ void main() {
artifacts: artifacts,
);
_addConstFinderInvocation(appDill.path, stdout: constFinderResultWithInvalid);
addConstFinderInvocation(appDill.path, stdout: constFinderResultWithInvalid);
await expectLater(
() => iconTreeShaker.subsetFont(
......@@ -352,7 +352,7 @@ void main() {
});
testWithoutContext('Non-zero font-subset exit code', () async {
final Environment environment = _createEnvironment(<String, String>{
final Environment environment = createEnvironment(<String, String>{
kIconTreeShakerFlag: 'true',
kBuildMode: 'release',
});
......@@ -370,8 +370,8 @@ void main() {
);
final CompleterIOSink stdinSink = CompleterIOSink();
_addConstFinderInvocation(appDill.path, stdout: validConstFinderResult);
_resetFontSubsetInvocation(exitCode: -1, stdinSink: stdinSink);
addConstFinderInvocation(appDill.path, stdout: validConstFinderResult);
resetFontSubsetInvocation(exitCode: -1, stdinSink: stdinSink);
await expectLater(
() => iconTreeShaker.subsetFont(
......@@ -385,7 +385,7 @@ void main() {
});
testWithoutContext('font-subset throws on write to sdtin', () async {
final Environment environment = _createEnvironment(<String, String>{
final Environment environment = createEnvironment(<String, String>{
kIconTreeShakerFlag: 'true',
kBuildMode: 'release',
});
......@@ -402,8 +402,8 @@ void main() {
);
final CompleterIOSink stdinSink = CompleterIOSink(throwOnAdd: true);
_addConstFinderInvocation(appDill.path, stdout: validConstFinderResult);
_resetFontSubsetInvocation(exitCode: -1, stdinSink: stdinSink);
addConstFinderInvocation(appDill.path, stdout: validConstFinderResult);
resetFontSubsetInvocation(exitCode: -1, stdinSink: stdinSink);
await expectLater(
() => iconTreeShaker.subsetFont(
......@@ -417,7 +417,7 @@ void main() {
});
testWithoutContext('Invalid font manifest', () async {
final Environment environment = _createEnvironment(<String, String>{
final Environment environment = createEnvironment(<String, String>{
kIconTreeShakerFlag: 'true',
kBuildMode: 'release',
});
......@@ -435,7 +435,7 @@ void main() {
artifacts: artifacts,
);
_addConstFinderInvocation(appDill.path, stdout: validConstFinderResult);
addConstFinderInvocation(appDill.path, stdout: validConstFinderResult);
await expectLater(
() => iconTreeShaker.subsetFont(
......@@ -449,7 +449,7 @@ void main() {
});
testWithoutContext('ConstFinder non-zero exit', () async {
final Environment environment = _createEnvironment(<String, String>{
final Environment environment = createEnvironment(<String, String>{
kIconTreeShakerFlag: 'true',
kBuildMode: 'release',
});
......@@ -467,7 +467,7 @@ void main() {
artifacts: artifacts,
);
_addConstFinderInvocation(appDill.path, exitCode: -1);
addConstFinderInvocation(appDill.path, exitCode: -1);
await expectLater(
() async => iconTreeShaker.subsetFont(
......
......@@ -15,7 +15,7 @@ import 'xcresult_test_data.dart';
void main() {
// Creates a FakeCommand for the xcresult get call to build the app
// in the given configuration.
FakeCommand _setUpFakeXCResultGetCommand({
FakeCommand setUpFakeXCResultGetCommand({
required String stdout,
required String tempResultPath,
required Xcode xcode,
......@@ -54,7 +54,7 @@ void main() {
exitCode: 1,
);
XCResultGenerator _setupGenerator({
XCResultGenerator setupGenerator({
required String resultJson,
int exitCode = 0,
String stderr = '',
......@@ -73,7 +73,7 @@ void main() {
);
fakeProcessManager.addCommands(
<FakeCommand>[
_setUpFakeXCResultGetCommand(
setUpFakeXCResultGetCommand(
stdout: resultJson,
tempResultPath: _tempResultPath,
xcode: xcode,
......@@ -95,7 +95,7 @@ void main() {
testWithoutContext(
'correctly parse sample result json when there are issues.', () async {
final XCResultGenerator generator = _setupGenerator(resultJson: kSampleResultJsonWithIssues);
final XCResultGenerator generator = setupGenerator(resultJson: kSampleResultJsonWithIssues);
final XCResult result = await generator.generate();
expect(result.issues.length, 2);
expect(result.issues.first.type, XCResultIssueType.error);
......@@ -112,7 +112,7 @@ void main() {
testWithoutContext(
'correctly parse sample result json when there are issues but invalid url.', () async {
final XCResultGenerator generator = _setupGenerator(resultJson: kSampleResultJsonWithIssuesAndInvalidUrl);
final XCResultGenerator generator = setupGenerator(resultJson: kSampleResultJsonWithIssuesAndInvalidUrl);
final XCResult result = await generator.generate();
expect(result.issues.length, 2);
expect(result.issues.first.type, XCResultIssueType.error);
......@@ -130,7 +130,7 @@ void main() {
testWithoutContext(
'correctly parse sample result json and discard all warnings', () async {
final XCResultGenerator generator = _setupGenerator(resultJson: kSampleResultJsonWithIssues);
final XCResultGenerator generator = setupGenerator(resultJson: kSampleResultJsonWithIssues);
final XCResultIssueDiscarder discarder = XCResultIssueDiscarder(typeMatcher: XCResultIssueType.warning);
final XCResult result = await generator.generate(issueDiscarders: <XCResultIssueDiscarder>[discarder]);
expect(result.issues.length, 1);
......@@ -144,7 +144,7 @@ void main() {
testWithoutContext(
'correctly parse sample result json and discard base on subType', () async {
final XCResultGenerator generator = _setupGenerator(resultJson: kSampleResultJsonWithIssues);
final XCResultGenerator generator = setupGenerator(resultJson: kSampleResultJsonWithIssues);
final XCResultIssueDiscarder discarder = XCResultIssueDiscarder(subTypeMatcher: RegExp(r'^Warning$'));
final XCResult result = await generator.generate(issueDiscarders: <XCResultIssueDiscarder>[discarder]);
expect(result.issues.length, 1);
......@@ -158,7 +158,7 @@ void main() {
testWithoutContext(
'correctly parse sample result json and discard base on message', () async {
final XCResultGenerator generator = _setupGenerator(resultJson: kSampleResultJsonWithIssues);
final XCResultGenerator generator = setupGenerator(resultJson: kSampleResultJsonWithIssues);
final XCResultIssueDiscarder discarder = XCResultIssueDiscarder(messageMatcher: RegExp(r"^The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99.$"));
final XCResult result = await generator.generate(issueDiscarders: <XCResultIssueDiscarder>[discarder]);
expect(result.issues.length, 1);
......@@ -172,7 +172,7 @@ void main() {
testWithoutContext(
'correctly parse sample result json and discard base on location', () async {
final XCResultGenerator generator = _setupGenerator(resultJson: kSampleResultJsonWithIssues);
final XCResultGenerator generator = setupGenerator(resultJson: kSampleResultJsonWithIssues);
final XCResultIssueDiscarder discarder = XCResultIssueDiscarder(locationMatcher: RegExp(r'/Users/m/Projects/test_create/ios/Runner/AppDelegate.m'));
final XCResult result = await generator.generate(issueDiscarders: <XCResultIssueDiscarder>[discarder]);
expect(result.issues.length, 1);
......@@ -186,7 +186,7 @@ void main() {
testWithoutContext(
'correctly parse sample result json with multiple discarders.', () async {
final XCResultGenerator generator = _setupGenerator(resultJson: kSampleResultJsonWithIssues);
final XCResultGenerator generator = setupGenerator(resultJson: kSampleResultJsonWithIssues);
final XCResultIssueDiscarder discardWarnings = XCResultIssueDiscarder(typeMatcher: XCResultIssueType.warning);
final XCResultIssueDiscarder discardSemanticIssues = XCResultIssueDiscarder(subTypeMatcher: RegExp(r'^Semantic Issue$'));
final XCResult result = await generator.generate(issueDiscarders: <XCResultIssueDiscarder>[discardWarnings, discardSemanticIssues]);
......@@ -197,7 +197,7 @@ void main() {
testWithoutContext('correctly parse sample result json when no issues.',
() async {
final XCResultGenerator generator = _setupGenerator(resultJson: kSampleResultJsonNoIssues);
final XCResultGenerator generator = setupGenerator(resultJson: kSampleResultJsonNoIssues);
final XCResult result = await generator.generate();
expect(result.issues.length, 0);
expect(result.parseSuccess, isTrue);
......@@ -208,7 +208,7 @@ void main() {
'error: `xcresulttool get` process fail should return an `XCResult` with stderr as `parsingErrorMessage`.',
() async {
const String fakeStderr = 'Fake: fail to parse result json.';
final XCResultGenerator generator = _setupGenerator(
final XCResultGenerator generator = setupGenerator(
resultJson: '',
exitCode: 1,
stderr: fakeStderr,
......@@ -221,7 +221,7 @@ void main() {
});
testWithoutContext('error: `xcresulttool get` no stdout', () async {
final XCResultGenerator generator = _setupGenerator(resultJson: '');
final XCResultGenerator generator = setupGenerator(resultJson: '');
final XCResult result = await generator.generate();
expect(result.issues.length, 0);
......@@ -231,7 +231,7 @@ void main() {
});
testWithoutContext('error: wrong top level json format.', () async {
final XCResultGenerator generator = _setupGenerator(resultJson: '[]');
final XCResultGenerator generator = setupGenerator(resultJson: '[]');
final XCResult result = await generator.generate();
expect(result.issues.length, 0);
......@@ -241,7 +241,7 @@ void main() {
});
testWithoutContext('error: fail to parse issue map', () async {
final XCResultGenerator generator = _setupGenerator(resultJson: '{}');
final XCResultGenerator generator = setupGenerator(resultJson: '{}');
final XCResult result = await generator.generate();
expect(result.issues.length, 0);
......@@ -251,7 +251,7 @@ void main() {
});
testWithoutContext('error: invalid issue map', () async {
final XCResultGenerator generator = _setupGenerator(resultJson: kSampleResultJsonInvalidIssuesMap);
final XCResultGenerator generator = setupGenerator(resultJson: kSampleResultJsonInvalidIssuesMap);
final XCResult result = await generator.generate();
expect(result.issues.length, 0);
......
......@@ -1557,7 +1557,7 @@ flutter:
tryToDelete(tempDir);
});
void _createPubspecFile(String yamlString) {
void createPubspecFile(String yamlString) {
projectDir.childFile('pubspec.yaml')..createSync(recursive: true)..writeAsStringSync(yamlString);
}
......@@ -1581,7 +1581,7 @@ flutter:
pluginClass: SomePlugin
package: AndroidPackage
''';
_createPubspecFile(pluginYaml);
createPubspecFile(pluginYaml);
validatePubspecForPlugin(projectDir: projectDir.absolute.path, pluginClass: 'SomePlugin', expectedPlatforms: <String>[
'ios', 'macos', 'windows', 'linux', 'android', 'web',
], androidIdentifier: 'AndroidPackage', webFileName: 'lib/SomeFile.dart');
......
......@@ -274,7 +274,7 @@ void main() {
});
group('$VersionCheckStamp for $channel', () {
void _expectDefault(VersionCheckStamp stamp) {
void expectDefault(VersionCheckStamp stamp) {
expect(stamp.lastKnownRemoteVersion, isNull);
expect(stamp.lastTimeVersionWasChecked, isNull);
expect(stamp.lastTimeWarningWasPrinted, isNull);
......@@ -283,19 +283,19 @@ void main() {
testWithoutContext('loads blank when stamp file missing', () async {
cache.versionStamp = null;
_expectDefault(await VersionCheckStamp.load(cache, BufferLogger.test()));
expectDefault(await VersionCheckStamp.load(cache, BufferLogger.test()));
});
testWithoutContext('loads blank when stamp file is malformed JSON', () async {
cache.versionStamp = '<';
_expectDefault(await VersionCheckStamp.load(cache, BufferLogger.test()));
expectDefault(await VersionCheckStamp.load(cache, BufferLogger.test()));
});
testWithoutContext('loads blank when stamp file is well-formed but invalid JSON', () async {
cache.versionStamp = '[]';
_expectDefault(await VersionCheckStamp.load(cache, BufferLogger.test()));
expectDefault(await VersionCheckStamp.load(cache, BufferLogger.test()));
});
testWithoutContext('loads valid JSON', () async {
......
......@@ -21,7 +21,7 @@ void main() {
});
// Assigns default values for a complete VS installation with necessary components.
void _configureMockVisualStudioAsInstalled() {
void configureMockVisualStudioAsInstalled() {
fakeVisualStudio.isPrerelease = false;
fakeVisualStudio.isRebootRequired = false;
fakeVisualStudio.fullVersion = '16.2';
......@@ -30,7 +30,7 @@ void main() {
}
// Assigns default values for a complete VS installation that is too old.
void _configureMockVisualStudioAsTooOld() {
void configureMockVisualStudioAsTooOld() {
fakeVisualStudio.isAtLeastMinimumVersion = false;
fakeVisualStudio.isPrerelease = false;
fakeVisualStudio.isRebootRequired = false;
......@@ -40,7 +40,7 @@ void main() {
}
// Assigns default values for a missing VS installation.
void _configureMockVisualStudioAsNotInstalled() {
void configureMockVisualStudioAsNotInstalled() {
fakeVisualStudio.isInstalled = false;
fakeVisualStudio.isAtLeastMinimumVersion = false;
fakeVisualStudio.isPrerelease = false;
......@@ -56,7 +56,7 @@ void main() {
userMessages: userMessages,
visualStudio: fakeVisualStudio,
);
_configureMockVisualStudioAsInstalled();
configureMockVisualStudioAsInstalled();
fakeVisualStudio.isPrerelease = true;
final ValidationResult result = await validator.validate();
......@@ -70,7 +70,7 @@ void main() {
userMessages: userMessages,
visualStudio: fakeVisualStudio,
);
_configureMockVisualStudioAsInstalled();
configureMockVisualStudioAsInstalled();
fakeVisualStudio.isComplete = false;
final ValidationResult result = await validator.validate();
......@@ -85,7 +85,7 @@ void main() {
userMessages: userMessages,
visualStudio: fakeVisualStudio,
);
_configureMockVisualStudioAsInstalled();
configureMockVisualStudioAsInstalled();
fakeVisualStudio.isRebootRequired = true;
final ValidationResult result = await validator.validate();
......@@ -100,7 +100,7 @@ void main() {
userMessages: userMessages,
visualStudio: fakeVisualStudio,
);
_configureMockVisualStudioAsInstalled();
configureMockVisualStudioAsInstalled();
fakeVisualStudio.isLaunchable = false;
final ValidationResult result = await validator.validate();
......@@ -115,7 +115,7 @@ void main() {
userMessages: userMessages,
visualStudio: fakeVisualStudio,
);
_configureMockVisualStudioAsTooOld();
configureMockVisualStudioAsTooOld();
final ValidationResult result = await validator.validate();
final ValidationMessage expectedMessage = ValidationMessage.error(
......@@ -134,7 +134,7 @@ void main() {
userMessages: userMessages,
visualStudio: fakeVisualStudio,
);
_configureMockVisualStudioAsInstalled();
configureMockVisualStudioAsInstalled();
fakeVisualStudio.hasNecessaryComponents = false;
final ValidationResult result = await validator.validate();
......@@ -146,7 +146,7 @@ void main() {
userMessages: userMessages,
visualStudio: fakeVisualStudio,
);
_configureMockVisualStudioAsInstalled();
configureMockVisualStudioAsInstalled();
fakeVisualStudio.windows10SDKVersion = null;
final ValidationResult result = await validator.validate();
......@@ -158,7 +158,7 @@ void main() {
userMessages: userMessages,
visualStudio: fakeVisualStudio,
);
_configureMockVisualStudioAsInstalled();
configureMockVisualStudioAsInstalled();
final ValidationResult result = await validator.validate();
final ValidationMessage expectedDisplayNameMessage = ValidationMessage(
......@@ -173,7 +173,7 @@ void main() {
userMessages: userMessages,
visualStudio: fakeVisualStudio,
);
_configureMockVisualStudioAsNotInstalled();
configureMockVisualStudioAsNotInstalled();
final ValidationResult result = await validator.validate();
final ValidationMessage expectedMessage = ValidationMessage.error(
......
......@@ -36,7 +36,7 @@ void main() {
expect(result.stderr, contains(exitMessageContains));
}
void _createDotPackages(String projectPath, [bool nullSafe = false]) {
void createDotPackages(String projectPath, [bool nullSafe = false]) {
final StringBuffer flutterRootUri = StringBuffer('file://');
final String canonicalizedFlutterRootPath = fileSystem.path.canonicalize(getFlutterRoot());
if (platform.isWindows) {
......@@ -84,7 +84,7 @@ void main() {
fileSystem.file(fileSystem.path.join(projectPath, 'pubspec.yaml'))
..createSync(recursive: true)
..writeAsStringSync(pubspecYamlSrc);
_createDotPackages(projectPath);
createDotPackages(projectPath);
libMain = fileSystem.file(fileSystem.path.join(projectPath, 'lib', 'main.dart'))
..createSync(recursive: true)
..writeAsStringSync(mainDartSrc);
......
......@@ -44,7 +44,7 @@ void main() {
tryToDelete(tempDir);
});
void _checkBuildDir() {
void checkBuildDir() {
// The android/app/build directory should not exists
final Directory appBuildDir = fileSystem.directory(fileSystem.path.join(
exampleAppDir.path,
......@@ -65,7 +65,7 @@ void main() {
'apk',
'--target-platform=android-arm',
], workingDirectory: exampleAppDir.path);
_checkBuildDir();
checkBuildDir();
},
);
......@@ -79,7 +79,7 @@ void main() {
'appbundle',
'--target-platform=android-arm',
], workingDirectory: exampleAppDir.path);
_checkBuildDir();
checkBuildDir();
},
);
}
......@@ -17,12 +17,12 @@ void main() {
fileSystem.path.join(flutterTools, 'lib', 'src', 'commands'),
fileSystem.path.join(flutterTools, 'lib', 'src', 'test'),
];
bool _isNotSkipped(FileSystemEntity entity) => skippedPaths.every((String path) => !entity.path.startsWith(path));
bool isNotSkipped(FileSystemEntity entity) => skippedPaths.every((String path) => !entity.path.startsWith(path));
final Iterable<File> files = fileSystem.directory(fileSystem.path.join(flutterTools, 'lib', 'src'))
.listSync(recursive: true)
.where(_isDartFile)
.where(_isNotSkipped)
.where(isNotSkipped)
.map(_asFile);
for (final File file in files) {
for (final String line in file.readAsLinesSync()) {
......@@ -41,13 +41,13 @@ void main() {
test('no imports of globals without a global prefix', () {
final List<String> skippedPaths = <String> [];
bool _isNotSkipped(FileSystemEntity entity) => skippedPaths.every((String path) => !entity.path.startsWith(path));
bool isNotSkipped(FileSystemEntity entity) => skippedPaths.every((String path) => !entity.path.startsWith(path));
final Iterable<File> files = fileSystem.directory(fileSystem.path.join(flutterTools, 'lib', 'src'))
.listSync(recursive: true)
.followedBy(fileSystem.directory(fileSystem.path.join(flutterTools, 'test',)).listSync(recursive: true))
.where(_isDartFile)
.where(_isNotSkipped)
.where(isNotSkipped)
.map(_asFile);
for (final File file in files) {
for (final String line in file.readAsLinesSync()) {
......@@ -70,13 +70,13 @@ void main() {
fileSystem.path.join(flutterTools, 'lib', 'src', 'base', 'error_handling_io.dart'),
fileSystem.path.join(flutterTools, 'lib', 'src', 'base', 'multi_root_file_system.dart'),
];
bool _isNotAllowed(FileSystemEntity entity) => allowedPaths.every((String path) => path != entity.path);
bool isNotAllowed(FileSystemEntity entity) => allowedPaths.every((String path) => path != entity.path);
for (final String dirName in <String>['lib', 'bin']) {
final Iterable<File> files = fileSystem.directory(fileSystem.path.join(flutterTools, dirName))
.listSync(recursive: true)
.where(_isDartFile)
.where(_isNotAllowed)
.where(isNotAllowed)
.map(_asFile);
for (final File file in files) {
for (final String line in file.readAsLinesSync()) {
......@@ -95,13 +95,13 @@ void main() {
// Used only for multi-part file uploads, which are non-trivial to reimplement.
fileSystem.path.join(flutterTools, 'lib', 'src', 'reporting', 'crash_reporting.dart'),
];
bool _isNotAllowed(FileSystemEntity entity) => allowedPaths.every((String path) => path != entity.path);
bool isNotAllowed(FileSystemEntity entity) => allowedPaths.every((String path) => path != entity.path);
for (final String dirName in <String>['lib', 'bin']) {
final Iterable<File> files = fileSystem.directory(fileSystem.path.join(flutterTools, dirName))
.listSync(recursive: true)
.where(_isDartFile)
.where(_isNotAllowed)
.where(isNotAllowed)
.map(_asFile);
for (final File file in files) {
for (final String line in file.readAsLinesSync()) {
......@@ -121,13 +121,13 @@ void main() {
fileSystem.path.join(flutterTools, 'lib', 'src', 'test', 'flutter_web_platform.dart'),
fileSystem.path.join(flutterTools, 'lib', 'src', 'test', 'test_wrapper.dart'),
];
bool _isNotAllowed(FileSystemEntity entity) => allowedPaths.every((String path) => path != entity.path);
bool isNotAllowed(FileSystemEntity entity) => allowedPaths.every((String path) => path != entity.path);
for (final String dirName in <String>['lib']) {
final Iterable<File> files = fileSystem.directory(fileSystem.path.join(flutterTools, dirName))
.listSync(recursive: true)
.where(_isDartFile)
.where(_isNotAllowed)
.where(isNotAllowed)
.map(_asFile);
for (final File file in files) {
for (final String line in file.readAsLinesSync()) {
......@@ -191,13 +191,13 @@ void main() {
fileSystem.path.join(flutterTools, 'lib', 'src', 'convert.dart'),
fileSystem.path.join(flutterTools, 'lib', 'src', 'base', 'error_handling_io.dart'),
];
bool _isNotAllowed(FileSystemEntity entity) => allowedPaths.every((String path) => path != entity.path);
bool isNotAllowed(FileSystemEntity entity) => allowedPaths.every((String path) => path != entity.path);
for (final String dirName in <String>['lib']) {
final Iterable<File> files = fileSystem.directory(fileSystem.path.join(flutterTools, dirName))
.listSync(recursive: true)
.where(_isDartFile)
.where(_isNotAllowed)
.where(isNotAllowed)
.map(_asFile);
for (final File file in files) {
for (final String line in file.readAsLinesSync()) {
......@@ -219,13 +219,13 @@ void main() {
fileSystem.path.join(flutterTools, 'lib', 'devfs_web.dart'),
fileSystem.path.join(flutterTools, 'lib', 'resident_web_runner.dart'),
];
bool _isNotAllowed(FileSystemEntity entity) => allowedPaths.every((String path) => !entity.path.contains(path));
bool isNotAllowed(FileSystemEntity entity) => allowedPaths.every((String path) => !entity.path.contains(path));
for (final String dirName in <String>['lib']) {
final Iterable<File> files = fileSystem.directory(fileSystem.path.join(flutterTools, dirName))
.listSync(recursive: true)
.where(_isDartFile)
.where(_isNotAllowed)
.where(isNotAllowed)
.map(_asFile);
for (final File file in files) {
for (final String line in file.readAsLinesSync()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment