Skip to content

Commit 5d93894

Browse files
authored
[flutter_tools] Decouple fatal-warnings check from fatal-infos (#113748)
1 parent d988c11 commit 5d93894

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

packages/flutter_tools/lib/src/commands/analyze_once.dart

+1-2
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,7 @@ class AnalyzeOnce extends AnalyzeBase {
167167
if (severityLevel == AnalysisSeverity.error) {
168168
return true;
169169
}
170-
if (severityLevel == AnalysisSeverity.warning &&
171-
(argResults['fatal-warnings'] as bool || argResults['fatal-infos'] as bool)) {
170+
if (severityLevel == AnalysisSeverity.warning && argResults['fatal-warnings'] as bool) {
172171
return true;
173172
}
174173
if (severityLevel == AnalysisSeverity.info && argResults['fatal-infos'] as bool) {

packages/flutter_tools/test/integration.shard/analyze_once_test.dart

+25-1
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ int analyze() {}
339339
);
340340
});
341341

342-
testWithoutContext('analyze once only fatal-infos has warning issue finally exit code 1.', () async {
342+
testWithoutContext('analyze once only fatal-infos has warning issue finally exit code 0.', () async {
343343
const String warningSourceCode = '''
344344
int analyze() {}
345345
''';
@@ -359,6 +359,30 @@ analyzer:
359359
'missing_return',
360360
],
361361
exitMessageContains: '1 issue found.',
362+
);
363+
});
364+
365+
366+
testWithoutContext('analyze once only fatal-warnings has warning issue finally exit code 1.', () async {
367+
const String warningSourceCode = '''
368+
int analyze() {}
369+
''';
370+
371+
final File optionsFile = fileSystem.file(fileSystem.path.join(projectPath, 'analysis_options.yaml'));
372+
optionsFile.writeAsStringSync('''
373+
analyzer:
374+
errors:
375+
missing_return: warning
376+
''');
377+
378+
fileSystem.directory(projectPath).childFile('main.dart').writeAsStringSync(warningSourceCode);
379+
await runCommand(
380+
arguments: <String>['analyze','--no-pub', '--no-fatal-infos', '--fatal-warnings'],
381+
statusTextContains: <String>[
382+
'warning',
383+
'missing_return',
384+
],
385+
exitMessageContains: '1 issue found.',
362386
exitCode: 1,
363387
);
364388
});

0 commit comments

Comments
 (0)