Enable lint prefer asserts in initializer lists (#12903)
* enable lint prefer_asserts_in_initializer_lists * enable --assert-initializer
This commit is contained in:
committed by
GitHub
parent
a75f003b9c
commit
15601fe55c
@@ -21,9 +21,8 @@ abstract class ApplicationPackage {
|
||||
/// Package ID from the Android Manifest or equivalent.
|
||||
final String id;
|
||||
|
||||
ApplicationPackage({ @required this.id }) {
|
||||
assert(id != null);
|
||||
}
|
||||
ApplicationPackage({ @required this.id })
|
||||
: assert(id != null);
|
||||
|
||||
String get name;
|
||||
|
||||
@@ -46,10 +45,9 @@ class AndroidApk extends ApplicationPackage {
|
||||
String id,
|
||||
@required this.apkPath,
|
||||
@required this.launchActivity
|
||||
}) : super(id: id) {
|
||||
assert(apkPath != null);
|
||||
assert(launchActivity != null);
|
||||
}
|
||||
}) : assert(apkPath != null),
|
||||
assert(launchActivity != null),
|
||||
super(id: id);
|
||||
|
||||
/// Creates a new AndroidApk from an existing APK.
|
||||
factory AndroidApk.fromApk(String applicationBinary) {
|
||||
|
||||
@@ -21,9 +21,8 @@ GenSnapshot get genSnapshot => context.putIfAbsent(GenSnapshot, () => const GenS
|
||||
|
||||
/// A snapshot build configuration.
|
||||
class SnapshotType {
|
||||
SnapshotType(this.platform, this.mode) {
|
||||
assert(mode != null);
|
||||
}
|
||||
SnapshotType(this.platform, this.mode)
|
||||
: assert(mode != null);
|
||||
|
||||
final TargetPlatform platform;
|
||||
final BuildMode mode;
|
||||
|
||||
@@ -17,9 +17,8 @@ Flags get flags => context?.getVariable(Flags) ?? const _EmptyFlags();
|
||||
/// the Flutter tool (immediately after the arguments have been parsed in
|
||||
/// [FlutterCommandRunner]) and is available via the [flags] global property.
|
||||
class Flags {
|
||||
Flags(this._globalResults) {
|
||||
assert(_globalResults != null);
|
||||
}
|
||||
Flags(this._globalResults)
|
||||
: assert(_globalResults != null);
|
||||
|
||||
final ArgResults _globalResults;
|
||||
|
||||
|
||||
@@ -177,8 +177,8 @@ class BufferLogger extends Logger {
|
||||
}
|
||||
|
||||
class VerboseLogger extends Logger {
|
||||
VerboseLogger(this.parent) {
|
||||
assert(terminal != null);
|
||||
VerboseLogger(this.parent)
|
||||
: assert(terminal != null) {
|
||||
stopwatch.start();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,9 +21,7 @@ class ApkKeystoreInfo {
|
||||
this.password,
|
||||
this.keyAlias,
|
||||
@required this.keyPassword,
|
||||
}) {
|
||||
assert(keystore != null);
|
||||
}
|
||||
}) : assert(keystore != null);
|
||||
|
||||
final String keystore;
|
||||
final String password;
|
||||
|
||||
@@ -297,7 +297,7 @@ Future<Null> _runTests(List<String> testArgs, String observatoryUri) async {
|
||||
..add('-rexpanded');
|
||||
final String dartVmPath = fs.path.join(dartSdkPath, 'bin', 'dart');
|
||||
final int result = await runCommandAndStreamOutput(
|
||||
<String>[dartVmPath]..addAll(args),
|
||||
<String>[dartVmPath]..addAll(dartVmFlags)..addAll(args),
|
||||
environment: <String, String>{ 'VM_SERVICE_URL': observatoryUri }
|
||||
);
|
||||
if (result != 0)
|
||||
|
||||
@@ -104,8 +104,8 @@ Future<String> compile(
|
||||
/// The wrapper is intended to stay resident in memory as user changes, reloads,
|
||||
/// restarts the Flutter app.
|
||||
class ResidentCompiler {
|
||||
ResidentCompiler(this._sdkRoot) {
|
||||
assert(_sdkRoot != null);
|
||||
ResidentCompiler(this._sdkRoot)
|
||||
: assert(_sdkRoot != null) {
|
||||
// This is a URI, not a file path, so the forward slash is correct even on Windows.
|
||||
if (!_sdkRoot.endsWith('/'))
|
||||
_sdkRoot = '$_sdkRoot/';
|
||||
|
||||
@@ -11,6 +11,9 @@ String get dartSdkPath {
|
||||
return fs.path.join(Cache.flutterRoot, 'bin', 'cache', 'dart-sdk');
|
||||
}
|
||||
|
||||
/// The required Dart language flags
|
||||
const List<String> dartVmFlags = const <String>['--assert-initializer'];
|
||||
|
||||
/// Return the platform specific name for the given Dart SDK binary. So, `pub`
|
||||
/// ==> `pub.bat`. The default SDK location can be overridden with a specified
|
||||
/// [sdkLocation].
|
||||
|
||||
@@ -102,11 +102,10 @@ class FlutterManifest {
|
||||
}
|
||||
|
||||
class Font {
|
||||
Font(this.familyName, this.fontAssets) {
|
||||
assert(familyName != null);
|
||||
assert(fontAssets != null);
|
||||
assert(fontAssets.isNotEmpty);
|
||||
}
|
||||
Font(this.familyName, this.fontAssets)
|
||||
: assert(familyName != null),
|
||||
assert(fontAssets != null),
|
||||
assert(fontAssets.isNotEmpty);
|
||||
|
||||
final String familyName;
|
||||
final List<FontAsset> fontAssets;
|
||||
@@ -123,9 +122,8 @@ class Font {
|
||||
}
|
||||
|
||||
class FontAsset {
|
||||
FontAsset(this.asset, {this.weight, this.style}) {
|
||||
assert(asset != null);
|
||||
}
|
||||
FontAsset(this.asset, {this.weight, this.style})
|
||||
: assert(asset != null);
|
||||
|
||||
final String asset;
|
||||
final int weight;
|
||||
|
||||
@@ -18,9 +18,9 @@ class ProtocolDiscovery {
|
||||
this.portForwarder,
|
||||
this.hostPort,
|
||||
this.defaultHostPort,
|
||||
}) : _prefix = '$serviceName listening on ' {
|
||||
assert(logReader != null);
|
||||
assert(portForwarder == null || defaultHostPort != null);
|
||||
}) : assert(logReader != null),
|
||||
assert(portForwarder == null || defaultHostPort != null),
|
||||
_prefix = '$serviceName listening on ' {
|
||||
_deviceLogSubscription = logReader.logLines.listen(_handleLine);
|
||||
}
|
||||
|
||||
|
||||
@@ -88,9 +88,7 @@ class _FlutterPlatform extends PlatformPlugin {
|
||||
this.startPaused,
|
||||
this.explicitObservatoryPort,
|
||||
this.host,
|
||||
}) {
|
||||
assert(shellPath != null);
|
||||
}
|
||||
}) : assert(shellPath != null);
|
||||
|
||||
final String shellPath;
|
||||
final TestWatcher watcher;
|
||||
|
||||
@@ -209,12 +209,12 @@ void main() {
|
||||
// TODO(pq): enable when sky_shell is available
|
||||
if (!io.Platform.isWindows) {
|
||||
// Verify that the sample widget test runs cleanly.
|
||||
final List<String> args = <String>[
|
||||
fs.path.absolute(fs.path.join('bin', 'flutter_tools.dart')),
|
||||
'test',
|
||||
'--no-color',
|
||||
fs.path.join(projectDir.path, 'test', 'widget_test.dart'),
|
||||
];
|
||||
final List<String> args = <String>[]
|
||||
..addAll(dartVmFlags)
|
||||
..add(fs.path.absolute(fs.path.join('bin', 'flutter_tools.dart')))
|
||||
..add('test')
|
||||
..add('--no-color')
|
||||
..add(fs.path.join(projectDir.path, 'test', 'widget_test.dart'));
|
||||
|
||||
final ProcessResult result = await Process.run(
|
||||
fs.path.join(dartSdkPath, 'bin', 'dart'),
|
||||
@@ -338,7 +338,10 @@ Future<Null> _analyzeProject(String workingDir, {String target}) async {
|
||||
'flutter_tools.dart',
|
||||
));
|
||||
|
||||
final List<String> args = <String>[flutterToolsPath, 'analyze'];
|
||||
final List<String> args = <String>[]
|
||||
..addAll(dartVmFlags)
|
||||
..add(flutterToolsPath)
|
||||
..add('analyze');
|
||||
if (target != null)
|
||||
args.add(target);
|
||||
|
||||
|
||||
@@ -143,11 +143,13 @@ Future<ProcessResult> _runFlutterTest(
|
||||
if (!testFile.existsSync())
|
||||
fail('missing test file: $testFile');
|
||||
|
||||
final List<String> args = <String>[
|
||||
fs.path.absolute(fs.path.join('bin', 'flutter_tools.dart')),
|
||||
'test',
|
||||
'--no-color'
|
||||
]..addAll(extraArgs)..add(testFilePath);
|
||||
final List<String> args = <String>[]
|
||||
..addAll(dartVmFlags)
|
||||
..add(fs.path.absolute(fs.path.join('bin', 'flutter_tools.dart')))
|
||||
..add('test')
|
||||
..add('--no-color')
|
||||
..addAll(extraArgs)
|
||||
..add(testFilePath);
|
||||
|
||||
while (_testExclusionLock != null)
|
||||
await _testExclusionLock;
|
||||
|
||||
Reference in New Issue
Block a user