[flutter_tool] Use curly braces around single statment control structures (#40446)

This commit is contained in:
Zachary Anderson
2019-09-13 14:51:35 -07:00
committed by GitHub
parent f29524a150
commit e2340c641d
100 changed files with 1465 additions and 757 deletions

View File

@@ -38,8 +38,9 @@ void tryToDelete(Directory directory) {
/// environment variable is set, it will be returned. Otherwise, this will
/// deduce the path from `platform.script`.
String getFlutterRoot() {
if (platform.environment.containsKey('FLUTTER_ROOT'))
if (platform.environment.containsKey('FLUTTER_ROOT')) {
return platform.environment['FLUTTER_ROOT'];
}
Error invalidScript() => StateError('Invalid script: ${platform.script}');
@@ -51,8 +52,9 @@ String getFlutterRoot() {
case 'data':
final RegExp flutterTools = RegExp(r'(file://[^"]*[/\\]flutter_tools[/\\][^"]+\.dart)', multiLine: true);
final Match match = flutterTools.firstMatch(Uri.decodeFull(platform.script.path));
if (match == null)
if (match == null) {
throw invalidScript();
}
scriptUri = Uri.parse(match.group(1));
break;
default:
@@ -61,16 +63,18 @@ String getFlutterRoot() {
final List<String> parts = fs.path.split(fs.path.fromUri(scriptUri));
final int toolsIndex = parts.indexOf('flutter_tools');
if (toolsIndex == -1)
if (toolsIndex == -1) {
throw invalidScript();
}
final String toolsPath = fs.path.joinAll(parts.sublist(0, toolsIndex + 1));
return fs.path.normalize(fs.path.join(toolsPath, '..', '..'));
}
CommandRunner<void> createTestCommandRunner([ FlutterCommand command ]) {
final FlutterCommandRunner runner = FlutterCommandRunner();
if (command != null)
if (command != null) {
runner.addCommand(command);
}
return runner;
}
@@ -87,10 +91,12 @@ void updateFileModificationTime(
/// Matcher for functions that throw [ToolExit].
Matcher throwsToolExit({ int exitCode, Pattern message }) {
Matcher matcher = isToolExit;
if (exitCode != null)
if (exitCode != null) {
matcher = allOf(matcher, (ToolExit e) => e.exitCode == exitCode);
if (message != null)
}
if (message != null) {
matcher = allOf(matcher, (ToolExit e) => e.message.contains(message));
}
return throwsA(matcher);
}

View File

@@ -129,8 +129,9 @@ void testUsingContext(
void _printBufferedErrors(AppContext testContext) {
if (testContext.get<Logger>() is BufferLogger) {
final BufferLogger bufferLogger = testContext.get<Logger>();
if (bufferLogger.errorText.isNotEmpty)
if (bufferLogger.errorText.isNotEmpty) {
print(bufferLogger.errorText);
}
bufferLogger.clear();
}
}
@@ -142,8 +143,9 @@ class FakeDeviceManager implements DeviceManager {
@override
String get specifiedDeviceId {
if (_specifiedDeviceId == null || _specifiedDeviceId == 'all')
if (_specifiedDeviceId == null || _specifiedDeviceId == 'all') {
return null;
}
return _specifiedDeviceId;
}

View File

@@ -77,8 +77,9 @@ class MockAndroidSdk extends Mock implements AndroidSdk {
_createSdkFile(dir, 'build-tools/19.1.0/aapt$exe');
_createSdkFile(dir, 'build-tools/22.0.1/aapt$exe');
_createSdkFile(dir, 'build-tools/23.0.2/aapt$exe');
if (withAndroidN)
if (withAndroidN) {
_createSdkFile(dir, 'build-tools/24.0.0-preview/aapt$exe');
}
}
_createSdkFile(dir, 'platforms/android-22/android.jar');
@@ -88,8 +89,9 @@ class MockAndroidSdk extends Mock implements AndroidSdk {
_createSdkFile(dir, 'platforms/android-N/build.prop', contents: _buildProp);
}
if (withSdkManager)
if (withSdkManager) {
_createSdkFile(dir, 'tools/bin/sdkmanager$bat');
}
if (withNdkDir != null) {
final String ndkToolchainBin = fs.path.join(
@@ -307,8 +309,9 @@ class PromptingProcess implements Process {
// Echo stdin to stdout.
_stdoutController.add(bytesOnStdin);
if (bytesOnStdin[0] == utf8.encode('y')[0]) {
for (final String line in outputLines)
for (final String line in outputLines) {
_stdoutController.add(utf8.encode('$line\n'));
}
}
await _stdoutController.close();
}
@@ -343,8 +346,9 @@ class CompleterIOSink extends MemoryIOSink {
@override
void add(List<int> data) {
if (!_completer.isCompleted)
if (!_completer.isCompleted) {
_completer.complete(data);
}
super.add(data);
}
}
@@ -434,8 +438,9 @@ class MemoryStdout extends MemoryIOSink implements io.Stdout {
@override
int get terminalColumns {
if (_terminalColumns != null)
if (_terminalColumns != null) {
return _terminalColumns;
}
throw const io.StdoutException('unspecified mock value');
}
set terminalColumns(int value) => _terminalColumns = value;
@@ -443,8 +448,9 @@ class MemoryStdout extends MemoryIOSink implements io.Stdout {
@override
int get terminalLines {
if (_terminalLines != null)
if (_terminalLines != null) {
return _terminalLines;
}
throw const io.StdoutException('unspecified mock value');
}
set terminalLines(int value) => _terminalLines = value;