Declare locals final where not reassigned (flutter_tools) (#8570)

This commit is contained in:
Chris Bracken
2017-03-03 17:50:46 -08:00
committed by GitHub
parent 46291903e0
commit 7a09316cd0
123 changed files with 1315 additions and 1315 deletions

View File

@@ -32,19 +32,19 @@ void main() {
/// Test file_systems.copyDirectorySync() using MemoryFileSystem.
/// Copies between 2 instances of file systems which is also supported by copyDirectorySync().
test('test directory copy', () async {
MemoryFileSystem sourceMemoryFs = new MemoryFileSystem();
String sourcePath = '/some/origin';
Directory sourceDirectory = await sourceMemoryFs.directory(sourcePath).create(recursive: true);
final MemoryFileSystem sourceMemoryFs = new MemoryFileSystem();
final String sourcePath = '/some/origin';
final Directory sourceDirectory = await sourceMemoryFs.directory(sourcePath).create(recursive: true);
sourceMemoryFs.currentDirectory = sourcePath;
File sourceFile1 = sourceMemoryFs.file('some_file.txt')..writeAsStringSync('bleh');
DateTime writeTime = sourceFile1.lastModifiedSync();
final File sourceFile1 = sourceMemoryFs.file('some_file.txt')..writeAsStringSync('bleh');
final DateTime writeTime = sourceFile1.lastModifiedSync();
sourceMemoryFs.file('sub_dir/another_file.txt').createSync(recursive: true);
sourceMemoryFs.directory('empty_directory').createSync();
// Copy to another memory file system instance.
MemoryFileSystem targetMemoryFs = new MemoryFileSystem();
String targetPath = '/some/non-existent/target';
Directory targetDirectory = targetMemoryFs.directory(targetPath);
final MemoryFileSystem targetMemoryFs = new MemoryFileSystem();
final String targetPath = '/some/non-existent/target';
final Directory targetDirectory = targetMemoryFs.directory(targetPath);
copyDirectorySync(sourceDirectory, targetDirectory);
expect(targetDirectory.existsSync(), true);

View File

@@ -11,7 +11,7 @@ import 'package:flutter_tools/src/runner/flutter_command.dart';
import 'package:flutter_tools/src/runner/flutter_command_runner.dart';
CommandRunner<Null> createTestCommandRunner([FlutterCommand command]) {
FlutterCommandRunner runner = new FlutterCommandRunner();
final FlutterCommandRunner runner = new FlutterCommandRunner();
if (command != null)
runner.addCommand(command);
return runner;
@@ -21,7 +21,7 @@ CommandRunner<Null> createTestCommandRunner([FlutterCommand command]) {
void updateFileModificationTime(String path,
DateTime baseTime,
int seconds) {
DateTime modificationTime = baseTime.add(new Duration(seconds: seconds));
final DateTime modificationTime = baseTime.add(new Duration(seconds: seconds));
fs.file(path).setLastModifiedSync(modificationTime);
}

View File

@@ -38,7 +38,7 @@ void testUsingContext(String description, dynamic testMethod(), {
bool skip, // should default to `false`, but https://github.com/dart-lang/test/issues/545 doesn't allow this
}) {
test(description, () async {
AppContext testContext = new AppContext();
final AppContext testContext = new AppContext();
// Initialize the test context with some default mocks.
// Seed these context entries first since others depend on them
@@ -58,7 +58,7 @@ void testUsingContext(String description, dynamic testMethod(), {
testContext.putIfAbsent(OperatingSystemUtils, () => new MockOperatingSystemUtils());
testContext.putIfAbsent(Xcode, () => new Xcode());
testContext.putIfAbsent(IOSSimulatorUtils, () {
MockIOSSimulatorUtils mock = new MockIOSSimulatorUtils();
final MockIOSSimulatorUtils mock = new MockIOSSimulatorUtils();
when(mock.getAttachedDevices()).thenReturn(<IOSSimulator>[]);
return mock;
});
@@ -82,7 +82,7 @@ void testUsingContext(String description, dynamic testMethod(), {
});
} catch (error) {
if (testContext[Logger] is BufferLogger) {
BufferLogger bufferLogger = testContext[Logger];
final BufferLogger bufferLogger = testContext[Logger];
if (bufferLogger.errorText.isNotEmpty)
print(bufferLogger.errorText);
}

View File

@@ -21,27 +21,27 @@ void main() {
testUsingContext('Emit missing status when nothing is installed', () async {
when(xcode.isInstalled).thenReturn(false);
when(xcode.xcodeSelectPath).thenReturn(null);
IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget()
final IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget()
..hasPythonSixModule = false
..hasHomebrew = false
..hasIosDeploy = false;
ValidationResult result = await workflow.validate();
final ValidationResult result = await workflow.validate();
expect(result.type, ValidationType.missing);
}, overrides: <Type, Generator>{ Xcode: () => xcode });
testUsingContext('Emits partial status when Xcode is not installed', () async {
when(xcode.isInstalled).thenReturn(false);
when(xcode.xcodeSelectPath).thenReturn(null);
IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget();
ValidationResult result = await workflow.validate();
final IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget();
final ValidationResult result = await workflow.validate();
expect(result.type, ValidationType.partial);
}, overrides: <Type, Generator>{ Xcode: () => xcode });
testUsingContext('Emits partial status when Xcode is partially installed', () async {
when(xcode.isInstalled).thenReturn(false);
when(xcode.xcodeSelectPath).thenReturn('/Library/Developer/CommandLineTools');
IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget();
ValidationResult result = await workflow.validate();
final IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget();
final ValidationResult result = await workflow.validate();
expect(result.type, ValidationType.partial);
}, overrides: <Type, Generator>{ Xcode: () => xcode });
@@ -51,8 +51,8 @@ void main() {
.thenReturn('Xcode 7.0.1\nBuild version 7C1002\n');
when(xcode.isInstalledAndMeetsVersionCheck).thenReturn(false);
when(xcode.eulaSigned).thenReturn(true);
IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget();
ValidationResult result = await workflow.validate();
final IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget();
final ValidationResult result = await workflow.validate();
expect(result.type, ValidationType.partial);
}, overrides: <Type, Generator>{ Xcode: () => xcode });
@@ -62,8 +62,8 @@ void main() {
.thenReturn('Xcode 8.2.1\nBuild version 8C1002\n');
when(xcode.isInstalledAndMeetsVersionCheck).thenReturn(true);
when(xcode.eulaSigned).thenReturn(false);
IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget();
ValidationResult result = await workflow.validate();
final IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget();
final ValidationResult result = await workflow.validate();
expect(result.type, ValidationType.partial);
}, overrides: <Type, Generator>{ Xcode: () => xcode });
@@ -73,9 +73,9 @@ void main() {
.thenReturn('Xcode 8.2.1\nBuild version 8C1002\n');
when(xcode.isInstalledAndMeetsVersionCheck).thenReturn(true);
when(xcode.eulaSigned).thenReturn(true);
IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget()
final IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget()
..hasPythonSixModule = false;
ValidationResult result = await workflow.validate();
final ValidationResult result = await workflow.validate();
expect(result.type, ValidationType.partial);
}, overrides: <Type, Generator>{ Xcode: () => xcode });
@@ -85,9 +85,9 @@ void main() {
.thenReturn('Xcode 8.2.1\nBuild version 8C1002\n');
when(xcode.isInstalledAndMeetsVersionCheck).thenReturn(true);
when(xcode.eulaSigned).thenReturn(true);
IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget()
final IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget()
..hasHomebrew = false;
ValidationResult result = await workflow.validate();
final ValidationResult result = await workflow.validate();
expect(result.type, ValidationType.partial);
}, overrides: <Type, Generator>{ Xcode: () => xcode });
@@ -97,9 +97,9 @@ void main() {
.thenReturn('Xcode 8.2.1\nBuild version 8C1002\n');
when(xcode.isInstalledAndMeetsVersionCheck).thenReturn(true);
when(xcode.eulaSigned).thenReturn(true);
IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget()
final IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget()
..hasIosDeploy = false;
ValidationResult result = await workflow.validate();
final ValidationResult result = await workflow.validate();
expect(result.type, ValidationType.partial);
}, overrides: <Type, Generator>{ Xcode: () => xcode });
@@ -109,9 +109,9 @@ void main() {
.thenReturn('Xcode 8.2.1\nBuild version 8C1002\n');
when(xcode.isInstalledAndMeetsVersionCheck).thenReturn(true);
when(xcode.eulaSigned).thenReturn(true);
IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget()
final IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget()
..iosDeployVersionText = '1.8.0';
ValidationResult result = await workflow.validate();
final ValidationResult result = await workflow.validate();
expect(result.type, ValidationType.partial);
}, overrides: <Type, Generator>{ Xcode: () => xcode });
@@ -121,7 +121,7 @@ void main() {
.thenReturn('Xcode 8.2.1\nBuild version 8C1002\n');
when(xcode.isInstalledAndMeetsVersionCheck).thenReturn(true);
when(xcode.eulaSigned).thenReturn(true);
ValidationResult result = await new IOSWorkflowTestTarget().validate();
final ValidationResult result = await new IOSWorkflowTestTarget().validate();
expect(result.type, ValidationType.installed);
}, overrides: <Type, Generator>{ Xcode: () => xcode });
});

View File

@@ -18,7 +18,7 @@ void main() {
group('compareIosVersions', () {
test('compares correctly', () {
// This list must be sorted in ascending preference order
List<String> testList = <String>[
final List<String> testList = <String>[
'8', '8.0', '8.1', '8.2',
'9', '9.0', '9.1', '9.2',
'10', '10.0', '10.1',
@@ -40,7 +40,7 @@ void main() {
group('compareIphoneVersions', () {
test('compares correctly', () {
// This list must be sorted in ascending preference order
List<String> testList = <String>[
final List<String> testList = <String>[
'com.apple.CoreSimulator.SimDeviceType.iPhone-4s',
'com.apple.CoreSimulator.SimDeviceType.iPhone-5',
'com.apple.CoreSimulator.SimDeviceType.iPhone-5s',
@@ -132,7 +132,7 @@ void main() {
when(mockXcode.xcodeMajorVersion).thenReturn(8);
when(mockXcode.xcodeMinorVersion).thenReturn(2);
expect(deviceUnderTest.supportsScreenshot, true);
MockFile mockFile = new MockFile();
final MockFile mockFile = new MockFile();
when(mockFile.path).thenReturn(fs.path.join('some', 'path', 'to', 'screenshot.png'));
deviceUnderTest.takeScreenshot(mockFile);
verify(mockProcessManager.runSync(

View File

@@ -80,7 +80,7 @@ class BasicMock {
final List<String> messages = new List<String>();
void expectMessages(List<String> expectedMessages) {
List<String> actualMessages = new List<String>.from(messages);
final List<String> actualMessages = new List<String>.from(messages);
messages.clear();
expect(actualMessages, unorderedEquals(expectedMessages));
}
@@ -88,7 +88,7 @@ class BasicMock {
bool contains(String match) {
print('Checking for `$match` in:');
print(messages);
bool result = messages.contains(match);
final bool result = messages.contains(match);
messages.clear();
return result;
}