prefer_const_declarations on local variables (#14358)
This commit is contained in:
committed by
GitHub
parent
b0e17949aa
commit
841d5d7bd5
@@ -15,7 +15,7 @@ import '../src/context.dart';
|
||||
void main() {
|
||||
group('android_device', () {
|
||||
testUsingContext('stores the requested id', () {
|
||||
final String deviceId = '1234';
|
||||
const String deviceId = '1234';
|
||||
final AndroidDevice device = new AndroidDevice(deviceId);
|
||||
expect(device.id, deviceId);
|
||||
});
|
||||
|
||||
@@ -130,7 +130,7 @@ $fontsSection
|
||||
testUsingContext('App font uses font file from package', () async {
|
||||
establishFlutterRoot();
|
||||
|
||||
final String fontsSection = '''
|
||||
const String fontsSection = '''
|
||||
- family: foo
|
||||
fonts:
|
||||
- asset: packages/test_package/bar
|
||||
@@ -139,10 +139,10 @@ $fontsSection
|
||||
writePackagesFile('test_package:p/p/lib/');
|
||||
writePubspecFile('p/p/pubspec.yaml', 'test_package');
|
||||
|
||||
final String font = 'bar';
|
||||
const String font = 'bar';
|
||||
writeFontAsset('p/p/lib/', font);
|
||||
|
||||
final String expectedFontManifest =
|
||||
const String expectedFontManifest =
|
||||
'[{"fonts":[{"asset":"packages/test_package/bar"}],"family":"foo"}]';
|
||||
await buildAndVerifyFonts(
|
||||
<String>[],
|
||||
@@ -155,7 +155,7 @@ $fontsSection
|
||||
testUsingContext('App font uses local font file and package font file', () async {
|
||||
establishFlutterRoot();
|
||||
|
||||
final String fontsSection = '''
|
||||
const String fontsSection = '''
|
||||
- family: foo
|
||||
fonts:
|
||||
- asset: packages/test_package/bar
|
||||
@@ -165,9 +165,9 @@ $fontsSection
|
||||
writePackagesFile('test_package:p/p/lib/');
|
||||
writePubspecFile('p/p/pubspec.yaml', 'test_package');
|
||||
|
||||
final String packageFont = 'bar';
|
||||
const String packageFont = 'bar';
|
||||
writeFontAsset('p/p/lib/', packageFont);
|
||||
final String localFont = 'a/bar';
|
||||
const String localFont = 'a/bar';
|
||||
writeFontAsset('', localFont);
|
||||
|
||||
final String expectedFontManifest =
|
||||
@@ -186,7 +186,7 @@ $fontsSection
|
||||
|
||||
writePubspecFile('pubspec.yaml', 'test');
|
||||
writePackagesFile('test_package:p/p/lib/');
|
||||
final String fontsSection = '''
|
||||
const String fontsSection = '''
|
||||
- family: foo
|
||||
fonts:
|
||||
- asset: a/bar
|
||||
@@ -197,7 +197,7 @@ $fontsSection
|
||||
fontsSection: fontsSection,
|
||||
);
|
||||
|
||||
final String font = 'a/bar';
|
||||
const String font = 'a/bar';
|
||||
writeFontAsset('p/p/', font);
|
||||
|
||||
final String expectedFontManifest =
|
||||
@@ -216,7 +216,7 @@ $fontsSection
|
||||
|
||||
writePubspecFile('pubspec.yaml', 'test');
|
||||
writePackagesFile('test_package:p/p/lib/\ntest_package2:p2/p/lib/');
|
||||
final String fontsSection = '''
|
||||
const String fontsSection = '''
|
||||
- family: foo
|
||||
fonts:
|
||||
- asset: packages/test_package2/bar
|
||||
@@ -228,7 +228,7 @@ $fontsSection
|
||||
);
|
||||
writePubspecFile('p2/p/pubspec.yaml', 'test_package2');
|
||||
|
||||
final String font = 'bar';
|
||||
const String font = 'bar';
|
||||
writeFontAsset('p2/p/lib/', font);
|
||||
|
||||
final String expectedFontManifest =
|
||||
@@ -248,7 +248,7 @@ $fontsSection
|
||||
writePubspecFile('pubspec.yaml', 'test');
|
||||
writePackagesFile('test_package:p/p/lib/');
|
||||
|
||||
final String pubspec = '''
|
||||
const String pubspec = '''
|
||||
- family: foo
|
||||
fonts:
|
||||
- style: italic
|
||||
@@ -260,7 +260,7 @@ $fontsSection
|
||||
'test_package',
|
||||
fontsSection: pubspec,
|
||||
);
|
||||
final String font = 'a/bar';
|
||||
const String font = 'a/bar';
|
||||
writeFontAsset('p/p/', font);
|
||||
|
||||
final String expectedFontManifest =
|
||||
@@ -277,7 +277,7 @@ $fontsSection
|
||||
testUsingContext('App uses local font and package font with own font file.', () async {
|
||||
establishFlutterRoot();
|
||||
|
||||
final String fontsSection = '''
|
||||
const String fontsSection = '''
|
||||
- family: foo
|
||||
fonts:
|
||||
- asset: a/bar
|
||||
@@ -294,7 +294,7 @@ $fontsSection
|
||||
fontsSection: fontsSection,
|
||||
);
|
||||
|
||||
final String font = 'a/bar';
|
||||
const String font = 'a/bar';
|
||||
writeFontAsset('', font);
|
||||
writeFontAsset('p/p/', font);
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ $assetsSection
|
||||
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
||||
await bundle.build(manifestPath: 'pubspec.yaml');
|
||||
expect(bundle.entries.length, 2); // LICENSE, AssetManifest
|
||||
final String expectedAssetManifest = '{}';
|
||||
const String expectedAssetManifest = '{}';
|
||||
expect(
|
||||
UTF8.decode(await bundle.entries['AssetManifest.json'].contentsAsBytes()),
|
||||
expectedAssetManifest,
|
||||
@@ -145,7 +145,7 @@ $assetsSection
|
||||
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
||||
await bundle.build(manifestPath: 'pubspec.yaml');
|
||||
expect(bundle.entries.length, 2); // LICENSE, AssetManifest
|
||||
final String expectedAssetManifest = '{}';
|
||||
const String expectedAssetManifest = '{}';
|
||||
expect(
|
||||
UTF8.decode(await bundle.entries['AssetManifest.json'].contentsAsBytes()),
|
||||
expectedAssetManifest,
|
||||
|
||||
@@ -56,8 +56,8 @@ void main() {
|
||||
// Create a temporary directory and write a single file into it.
|
||||
final Directory tempDir = fs.systemTempDirectory.createTempSync();
|
||||
final String projectRoot = tempDir.path;
|
||||
final String assetPath = 'banana.txt';
|
||||
final String assetContents = 'banana';
|
||||
const String assetPath = 'banana.txt';
|
||||
const String assetContents = 'banana';
|
||||
final File tempFile = fs.file(fs.path.join(projectRoot, assetPath));
|
||||
tempFile.parent.createSync(recursive: true);
|
||||
tempFile.writeAsBytesSync(UTF8.encode(assetContents));
|
||||
@@ -111,7 +111,7 @@ void main() {
|
||||
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
||||
await bundle.build(manifestPath: 'pubspec.yaml');
|
||||
expect(bundle.entries.length, 1);
|
||||
final String expectedAssetManifest = '{}';
|
||||
const String expectedAssetManifest = '{}';
|
||||
expect(
|
||||
UTF8.decode(await bundle.entries['AssetManifest.json'].contentsAsBytes()),
|
||||
expectedAssetManifest,
|
||||
|
||||
@@ -34,7 +34,7 @@ void main() {
|
||||
/// Copies between 2 instances of file systems which is also supported by copyDirectorySync().
|
||||
test('test directory copy', () async {
|
||||
final MemoryFileSystem sourceMemoryFs = new MemoryFileSystem();
|
||||
final String sourcePath = '/some/origin';
|
||||
const String sourcePath = '/some/origin';
|
||||
final Directory sourceDirectory = await sourceMemoryFs.directory(sourcePath).create(recursive: true);
|
||||
sourceMemoryFs.currentDirectory = sourcePath;
|
||||
final File sourceFile1 = sourceMemoryFs.file('some_file.txt')..writeAsStringSync('bleh');
|
||||
@@ -44,7 +44,7 @@ void main() {
|
||||
|
||||
// Copy to another memory file system instance.
|
||||
final MemoryFileSystem targetMemoryFs = new MemoryFileSystem();
|
||||
final String targetPath = '/some/non-existent/target';
|
||||
const String targetPath = '/some/non-existent/target';
|
||||
final Directory targetDirectory = targetMemoryFs.directory(targetPath);
|
||||
copyDirectorySync(sourceDirectory, targetDirectory);
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ void main() {
|
||||
testUsingContext('moved flutter sdk', () async {
|
||||
final Directory destinationPath = fs.systemTempDirectory.createTempSync('dependency_checker_test_');
|
||||
// Copy the golden input and let the test run in an isolated temporary in-memory file system.
|
||||
final LocalFileSystem localFileSystem = const LocalFileSystem();
|
||||
const LocalFileSystem localFileSystem = const LocalFileSystem();
|
||||
final Directory sourcePath = localFileSystem.directory(localFileSystem.path.join(dataPath, 'changed_sdk_location'));
|
||||
copyDirectorySync(sourcePath, destinationPath);
|
||||
fs.currentDirectory = destinationPath;
|
||||
|
||||
@@ -186,7 +186,7 @@ void main() {
|
||||
});
|
||||
|
||||
testUsingContext('add new package with double slashes in URI', () async {
|
||||
final String packageName = 'doubleslashpkg';
|
||||
const String packageName = 'doubleslashpkg';
|
||||
await _createPackage(fs, packageName, 'somefile.txt', doubleSlash: true);
|
||||
|
||||
final Set<String> fileFilter = new Set<String>();
|
||||
|
||||
@@ -27,7 +27,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('has no fonts or assets when the "flutter" section is empty', () async {
|
||||
final String manifest = '''
|
||||
const String manifest = '''
|
||||
name: test
|
||||
dependencies:
|
||||
flutter:
|
||||
@@ -44,7 +44,7 @@ dependencies:
|
||||
});
|
||||
|
||||
test('knows if material design is used', () async {
|
||||
final String manifest = '''
|
||||
const String manifest = '''
|
||||
name: test
|
||||
dependencies:
|
||||
flutter:
|
||||
@@ -57,7 +57,7 @@ flutter:
|
||||
});
|
||||
|
||||
test('has two assets', () async {
|
||||
final String manifest = '''
|
||||
const String manifest = '''
|
||||
name: test
|
||||
dependencies:
|
||||
flutter:
|
||||
@@ -75,7 +75,7 @@ flutter:
|
||||
});
|
||||
|
||||
test('has one font family with one asset', () async {
|
||||
final String manifest = '''
|
||||
const String manifest = '''
|
||||
name: test
|
||||
dependencies:
|
||||
flutter:
|
||||
@@ -93,7 +93,7 @@ flutter:
|
||||
final List<Font> fonts = flutterManifest.fonts;
|
||||
expect(fonts.length, 1);
|
||||
final Font font = fonts[0];
|
||||
final String fontDescriptor = '{family: foo, fonts: [{asset: a/bar}]}';
|
||||
const String fontDescriptor = '{family: foo, fonts: [{asset: a/bar}]}';
|
||||
expect(font.descriptor.toString(), fontDescriptor);
|
||||
expect(font.familyName, 'foo');
|
||||
final List<FontAsset> assets = font.fontAssets;
|
||||
@@ -105,7 +105,7 @@ flutter:
|
||||
});
|
||||
|
||||
test('has one font family with a simple asset and one with weight', () async {
|
||||
final String manifest = '''
|
||||
const String manifest = '''
|
||||
name: test
|
||||
dependencies:
|
||||
flutter:
|
||||
@@ -121,12 +121,12 @@ flutter:
|
||||
''';
|
||||
final FlutterManifest flutterManifest = await FlutterManifest.createFromString(manifest);
|
||||
|
||||
final String expectedFontsDescriptor = '[{fonts: [{asset: a/bar}, {weight: 400, asset: a/bar}], family: foo}]';
|
||||
const String expectedFontsDescriptor = '[{fonts: [{asset: a/bar}, {weight: 400, asset: a/bar}], family: foo}]';
|
||||
expect(flutterManifest.fontsDescriptor.toString(), expectedFontsDescriptor);
|
||||
final List<Font> fonts = flutterManifest.fonts;
|
||||
expect(fonts.length, 1);
|
||||
final Font font = fonts[0];
|
||||
final String fontDescriptor = '{family: foo, fonts: [{asset: a/bar}, {weight: 400, asset: a/bar}]}';
|
||||
const String fontDescriptor = '{family: foo, fonts: [{asset: a/bar}, {weight: 400, asset: a/bar}]}';
|
||||
expect(font.descriptor.toString(), fontDescriptor);
|
||||
expect(font.familyName, 'foo');
|
||||
final List<FontAsset> assets = font.fontAssets;
|
||||
@@ -142,7 +142,7 @@ flutter:
|
||||
});
|
||||
|
||||
test('has one font family with a simple asset and one with weight and style', () async {
|
||||
final String manifest = '''
|
||||
const String manifest = '''
|
||||
name: test
|
||||
dependencies:
|
||||
flutter:
|
||||
@@ -159,12 +159,12 @@ flutter:
|
||||
''';
|
||||
final FlutterManifest flutterManifest = await FlutterManifest.createFromString(manifest);
|
||||
|
||||
final String expectedFontsDescriptor = '[{fonts: [{asset: a/bar}, {style: italic, weight: 400, asset: a/bar}], family: foo}]';
|
||||
const String expectedFontsDescriptor = '[{fonts: [{asset: a/bar}, {style: italic, weight: 400, asset: a/bar}], family: foo}]';
|
||||
expect(flutterManifest.fontsDescriptor.toString(), expectedFontsDescriptor);
|
||||
final List<Font> fonts = flutterManifest.fonts;
|
||||
expect(fonts.length, 1);
|
||||
final Font font = fonts[0];
|
||||
final String fontDescriptor = '{family: foo, fonts: [{asset: a/bar}, {weight: 400, style: italic, asset: a/bar}]}';
|
||||
const String fontDescriptor = '{family: foo, fonts: [{asset: a/bar}, {weight: 400, style: italic, asset: a/bar}]}';
|
||||
expect(font.descriptor.toString(), fontDescriptor);
|
||||
expect(font.familyName, 'foo');
|
||||
final List<FontAsset> assets = font.fontAssets;
|
||||
@@ -180,7 +180,7 @@ flutter:
|
||||
});
|
||||
|
||||
test('has two font families, each with one simple asset and one with weight and style', () async {
|
||||
final String manifest = '''
|
||||
const String manifest = '''
|
||||
name: test
|
||||
dependencies:
|
||||
flutter:
|
||||
@@ -210,7 +210,7 @@ flutter:
|
||||
expect(fonts.length, 2);
|
||||
|
||||
final Font fooFont = fonts[0];
|
||||
final String barFontDescriptor = '{family: foo, fonts: [{asset: a/bar}, {weight: 400, style: italic, asset: a/bar}]}';
|
||||
const String barFontDescriptor = '{family: foo, fonts: [{asset: a/bar}, {weight: 400, style: italic, asset: a/bar}]}';
|
||||
expect(fooFont.descriptor.toString(), barFontDescriptor);
|
||||
expect(fooFont.familyName, 'foo');
|
||||
final List<FontAsset> fooAassets = fooFont.fontAssets;
|
||||
@@ -225,7 +225,7 @@ flutter:
|
||||
expect(fooFontAsset1.style, 'italic');
|
||||
|
||||
final Font barFont = fonts[1];
|
||||
final String fontDescriptor = '{family: bar, fonts: [{asset: a/baz}, {weight: 400, style: italic, asset: a/baz}]}';
|
||||
const String fontDescriptor = '{family: bar, fonts: [{asset: a/baz}, {weight: 400, style: italic, asset: a/baz}]}';
|
||||
expect(barFont.descriptor.toString(), fontDescriptor);
|
||||
expect(barFont.familyName, 'bar');
|
||||
final List<FontAsset> barAssets = barFont.fontAssets;
|
||||
@@ -241,7 +241,7 @@ flutter:
|
||||
});
|
||||
|
||||
testUsingContext('has only one of two font familes when one declaration is missing the "family" option', () async {
|
||||
final String manifest = '''
|
||||
const String manifest = '''
|
||||
name: test
|
||||
dependencies:
|
||||
flutter:
|
||||
@@ -270,7 +270,7 @@ flutter:
|
||||
final List<Font> fonts = flutterManifest.fonts;
|
||||
expect(fonts.length, 1);
|
||||
final Font fooFont = fonts[0];
|
||||
final String barFontDescriptor = '{family: foo, fonts: [{asset: a/bar}, {weight: 400, style: italic, asset: a/bar}]}';
|
||||
const String barFontDescriptor = '{family: foo, fonts: [{asset: a/bar}, {weight: 400, style: italic, asset: a/bar}]}';
|
||||
expect(fooFont.descriptor.toString(), barFontDescriptor);
|
||||
expect(fooFont.familyName, 'foo');
|
||||
final List<FontAsset> fooAassets = fooFont.fontAssets;
|
||||
@@ -286,7 +286,7 @@ flutter:
|
||||
});
|
||||
|
||||
testUsingContext('has only one of two font familes when one declaration is missing the "fonts" option', () async {
|
||||
final String manifest = '''
|
||||
const String manifest = '''
|
||||
name: test
|
||||
dependencies:
|
||||
flutter:
|
||||
@@ -310,7 +310,7 @@ flutter:
|
||||
final List<Font> fonts = flutterManifest.fonts;
|
||||
expect(fonts.length, 1);
|
||||
final Font fooFont = fonts[0];
|
||||
final String barFontDescriptor = '{family: foo, fonts: [{asset: a/bar}, {weight: 400, style: italic, asset: a/bar}]}';
|
||||
const String barFontDescriptor = '{family: foo, fonts: [{asset: a/bar}, {weight: 400, style: italic, asset: a/bar}]}';
|
||||
expect(fooFont.descriptor.toString(), barFontDescriptor);
|
||||
expect(fooFont.familyName, 'foo');
|
||||
final List<FontAsset> fooAassets = fooFont.fontAssets;
|
||||
@@ -326,7 +326,7 @@ flutter:
|
||||
});
|
||||
|
||||
testUsingContext('has no font family when declaration is missing the "asset" option', () async {
|
||||
final String manifest = '''
|
||||
const String manifest = '''
|
||||
name: test
|
||||
dependencies:
|
||||
flutter:
|
||||
@@ -340,7 +340,7 @@ flutter:
|
||||
''';
|
||||
final FlutterManifest flutterManifest = await FlutterManifest.createFromString(manifest);
|
||||
|
||||
final String expectedFontsDescriptor = '[{fonts: [{weight: 400}], family: foo}]';
|
||||
const String expectedFontsDescriptor = '[{fonts: [{weight: 400}], family: foo}]';
|
||||
expect(flutterManifest.fontsDescriptor.toString(), expectedFontsDescriptor);
|
||||
final List<Font> fonts = flutterManifest.fonts;
|
||||
expect(fonts.length, 0);
|
||||
|
||||
@@ -113,7 +113,7 @@ void main() {
|
||||
});
|
||||
|
||||
testUsingContext('xcodeSelectPath returns path when xcode-select is installed', () {
|
||||
final String xcodePath = '/Applications/Xcode8.0.app/Contents/Developer';
|
||||
const String xcodePath = '/Applications/Xcode8.0.app/Contents/Developer';
|
||||
when(mockProcessManager.runSync(<String>['/usr/bin/xcode-select', '--print-path']))
|
||||
.thenReturn(new ProcessResult(1, 0, xcodePath, ''));
|
||||
expect(xcode.xcodeSelectPath, xcodePath);
|
||||
|
||||
@@ -6,7 +6,7 @@ import 'package:flutter_tools/src/ios/xcodeproj.dart';
|
||||
void main() {
|
||||
group('Xcode project properties', () {
|
||||
test('properties from default project can be parsed', () {
|
||||
final String output = '''
|
||||
const String output = '''
|
||||
Information about project "Runner":
|
||||
Targets:
|
||||
Runner
|
||||
@@ -27,7 +27,7 @@ Information about project "Runner":
|
||||
expect(info.buildConfigurations, <String>['Debug', 'Release']);
|
||||
});
|
||||
test('properties from project with custom schemes can be parsed', () {
|
||||
final String output = '''
|
||||
const String output = '''
|
||||
Information about project "Runner":
|
||||
Targets:
|
||||
Runner
|
||||
|
||||
Reference in New Issue
Block a user