From 5d938942647843f63d94288c94e844c70392dda0 Mon Sep 17 00:00:00 2001 From: Lucas Britto Date: Wed, 26 Oct 2022 20:44:25 +0400 Subject: [PATCH] [flutter_tools] Decouple fatal-warnings check from fatal-infos (#113748) --- .../lib/src/commands/analyze_once.dart | 3 +-- .../integration.shard/analyze_once_test.dart | 26 ++++++++++++++++++- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/packages/flutter_tools/lib/src/commands/analyze_once.dart b/packages/flutter_tools/lib/src/commands/analyze_once.dart index 35808c8fd9..c9f61818de 100644 --- a/packages/flutter_tools/lib/src/commands/analyze_once.dart +++ b/packages/flutter_tools/lib/src/commands/analyze_once.dart @@ -167,8 +167,7 @@ class AnalyzeOnce extends AnalyzeBase { if (severityLevel == AnalysisSeverity.error) { return true; } - if (severityLevel == AnalysisSeverity.warning && - (argResults['fatal-warnings'] as bool || argResults['fatal-infos'] as bool)) { + if (severityLevel == AnalysisSeverity.warning && argResults['fatal-warnings'] as bool) { return true; } if (severityLevel == AnalysisSeverity.info && argResults['fatal-infos'] as bool) { diff --git a/packages/flutter_tools/test/integration.shard/analyze_once_test.dart b/packages/flutter_tools/test/integration.shard/analyze_once_test.dart index 391acce9bd..5b3b3488a9 100644 --- a/packages/flutter_tools/test/integration.shard/analyze_once_test.dart +++ b/packages/flutter_tools/test/integration.shard/analyze_once_test.dart @@ -339,7 +339,7 @@ int analyze() {} ); }); - testWithoutContext('analyze once only fatal-infos has warning issue finally exit code 1.', () async { + testWithoutContext('analyze once only fatal-infos has warning issue finally exit code 0.', () async { const String warningSourceCode = ''' int analyze() {} '''; @@ -359,6 +359,30 @@ analyzer: 'missing_return', ], exitMessageContains: '1 issue found.', + ); + }); + + + testWithoutContext('analyze once only fatal-warnings has warning issue finally exit code 1.', () async { + const String warningSourceCode = ''' +int analyze() {} +'''; + + final File optionsFile = fileSystem.file(fileSystem.path.join(projectPath, 'analysis_options.yaml')); + optionsFile.writeAsStringSync(''' +analyzer: + errors: + missing_return: warning + '''); + + fileSystem.directory(projectPath).childFile('main.dart').writeAsStringSync(warningSourceCode); + await runCommand( + arguments: ['analyze','--no-pub', '--no-fatal-infos', '--fatal-warnings'], + statusTextContains: [ + 'warning', + 'missing_return', + ], + exitMessageContains: '1 issue found.', exitCode: 1, ); });