[flutter_tools] update analyze_once_test.dart to be null-safe (#141790)
Fixes https://github.com/flutter/flutter/issues/141743 I should have made this change in https://github.com/flutter/flutter/pull/124039, but it escaped my grep search.
This commit is contained in:
committed by
GitHub
parent
f340d207f6
commit
92094802fe
@@ -63,7 +63,7 @@ void main() {
|
||||
"name": "flutter_project",
|
||||
"rootUri": "../",
|
||||
"packageUri": "lib/",
|
||||
"languageVersion": "2.7"
|
||||
"languageVersion": "2.12"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -170,7 +170,7 @@ void main() {
|
||||
statusTextContains: <String>[
|
||||
'Analyzing',
|
||||
'unused_element',
|
||||
'missing_required_param',
|
||||
'missing_required_argument',
|
||||
],
|
||||
exitMessageContains: '2 issues found.',
|
||||
exitCode: 1,
|
||||
@@ -205,7 +205,7 @@ void main() {
|
||||
'Analyzing',
|
||||
'unused_element',
|
||||
'only_throw_errors',
|
||||
'missing_required_param',
|
||||
'missing_required_argument',
|
||||
],
|
||||
exitMessageContains: '3 issues found.',
|
||||
exitCode: 1,
|
||||
@@ -266,22 +266,15 @@ StringBuffer bar = StringBuffer('baz');
|
||||
|
||||
testWithoutContext('analyze once with default options has info issue finally exit code 1.', () async {
|
||||
const String infoSourceCode = '''
|
||||
int analyze() {}
|
||||
void _analyze() {}
|
||||
''';
|
||||
|
||||
final File optionsFile = fileSystem.file(fileSystem.path.join(projectPath, 'analysis_options.yaml'));
|
||||
optionsFile.writeAsStringSync('''
|
||||
analyzer:
|
||||
errors:
|
||||
missing_return: info
|
||||
''');
|
||||
|
||||
fileSystem.directory(projectPath).childFile('main.dart').writeAsStringSync(infoSourceCode);
|
||||
await runCommand(
|
||||
arguments: <String>['analyze', '--no-pub'],
|
||||
statusTextContains: <String>[
|
||||
'info',
|
||||
'missing_return',
|
||||
'unused_element',
|
||||
],
|
||||
exitMessageContains: '1 issue found.',
|
||||
exitCode: 1,
|
||||
@@ -290,14 +283,14 @@ analyzer:
|
||||
|
||||
testWithoutContext('analyze once with no-fatal-infos has info issue finally exit code 0.', () async {
|
||||
const String infoSourceCode = '''
|
||||
int analyze() {}
|
||||
void _analyze() {}
|
||||
''';
|
||||
|
||||
final File optionsFile = fileSystem.file(fileSystem.path.join(projectPath, 'analysis_options.yaml'));
|
||||
optionsFile.writeAsStringSync('''
|
||||
analyzer:
|
||||
errors:
|
||||
missing_return: info
|
||||
unused_element: info
|
||||
''');
|
||||
|
||||
fileSystem.directory(projectPath).childFile('main.dart').writeAsStringSync(infoSourceCode);
|
||||
@@ -305,7 +298,7 @@ analyzer:
|
||||
arguments: <String>['analyze', '--no-pub', '--no-fatal-infos'],
|
||||
statusTextContains: <String>[
|
||||
'info',
|
||||
'missing_return',
|
||||
'unused_element',
|
||||
],
|
||||
exitMessageContains: '1 issue found.',
|
||||
);
|
||||
@@ -313,14 +306,14 @@ analyzer:
|
||||
|
||||
testWithoutContext('analyze once only fatal-warnings has info issue finally exit code 0.', () async {
|
||||
const String infoSourceCode = '''
|
||||
int analyze() {}
|
||||
void _analyze() {}
|
||||
''';
|
||||
|
||||
final File optionsFile = fileSystem.file(fileSystem.path.join(projectPath, 'analysis_options.yaml'));
|
||||
optionsFile.writeAsStringSync('''
|
||||
analyzer:
|
||||
errors:
|
||||
missing_return: info
|
||||
unused_element: info
|
||||
''');
|
||||
|
||||
fileSystem.directory(projectPath).childFile('main.dart').writeAsStringSync(infoSourceCode);
|
||||
@@ -328,7 +321,7 @@ analyzer:
|
||||
arguments: <String>['analyze', '--no-pub', '--fatal-warnings', '--no-fatal-infos'],
|
||||
statusTextContains: <String>[
|
||||
'info',
|
||||
'missing_return',
|
||||
'unused_element',
|
||||
],
|
||||
exitMessageContains: '1 issue found.',
|
||||
);
|
||||
@@ -336,14 +329,14 @@ analyzer:
|
||||
|
||||
testWithoutContext('analyze once only fatal-infos has warning issue finally exit code 0.', () async {
|
||||
const String warningSourceCode = '''
|
||||
int analyze() {}
|
||||
void _analyze() {}
|
||||
''';
|
||||
|
||||
final File optionsFile = fileSystem.file(fileSystem.path.join(projectPath, 'analysis_options.yaml'));
|
||||
optionsFile.writeAsStringSync('''
|
||||
analyzer:
|
||||
errors:
|
||||
missing_return: warning
|
||||
unused_element: warning
|
||||
''');
|
||||
|
||||
fileSystem.directory(projectPath).childFile('main.dart').writeAsStringSync(warningSourceCode);
|
||||
@@ -351,7 +344,7 @@ analyzer:
|
||||
arguments: <String>['analyze','--no-pub', '--fatal-infos', '--no-fatal-warnings'],
|
||||
statusTextContains: <String>[
|
||||
'warning',
|
||||
'missing_return',
|
||||
'unused_element',
|
||||
],
|
||||
exitMessageContains: '1 issue found.',
|
||||
);
|
||||
@@ -360,14 +353,14 @@ analyzer:
|
||||
|
||||
testWithoutContext('analyze once only fatal-warnings has warning issue finally exit code 1.', () async {
|
||||
const String warningSourceCode = '''
|
||||
int analyze() {}
|
||||
void _analyze() {}
|
||||
''';
|
||||
|
||||
final File optionsFile = fileSystem.file(fileSystem.path.join(projectPath, 'analysis_options.yaml'));
|
||||
optionsFile.writeAsStringSync('''
|
||||
analyzer:
|
||||
errors:
|
||||
missing_return: warning
|
||||
unused_element: warning
|
||||
''');
|
||||
|
||||
fileSystem.directory(projectPath).childFile('main.dart').writeAsStringSync(warningSourceCode);
|
||||
@@ -375,7 +368,7 @@ analyzer:
|
||||
arguments: <String>['analyze','--no-pub', '--no-fatal-infos', '--fatal-warnings'],
|
||||
statusTextContains: <String>[
|
||||
'warning',
|
||||
'missing_return',
|
||||
'unused_element',
|
||||
],
|
||||
exitMessageContains: '1 issue found.',
|
||||
exitCode: 1,
|
||||
@@ -408,7 +401,7 @@ class MyApp extends StatelessWidget {
|
||||
}
|
||||
|
||||
class MyHomePage extends StatefulWidget {
|
||||
MyHomePage({Key key, this.title}) : super(key: key);
|
||||
MyHomePage({Key? key, required this.title}) : super(key: key);
|
||||
|
||||
final String title;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user