From 21eb39e148c720ab8577bbf3bf089556a113eb10 Mon Sep 17 00:00:00 2001 From: Sigurd Meldgaard Date: Tue, 18 Apr 2023 09:38:04 +0200 Subject: [PATCH] Don't pass --fatal-infos to `dart analyze` in validation (#3877) --- lib/src/validator/analyze.dart | 7 +------ test/validator/analyze_test.dart | 28 +++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/lib/src/validator/analyze.dart b/lib/src/validator/analyze.dart index d22da8d5d..c29fa9edd 100644 --- a/lib/src/validator/analyze.dart +++ b/lib/src/validator/analyze.dart @@ -22,12 +22,7 @@ class AnalyzeValidator extends Validator { .where(dirExists); final result = await runProcess( Platform.resolvedExecutable, - [ - 'analyze', - '--fatal-infos', - ...dirsToAnalyze, - p.join(entrypoint.rootDir, 'pubspec.yaml') - ], + ['analyze', ...dirsToAnalyze, p.join(entrypoint.rootDir, 'pubspec.yaml')], ); if (result.exitCode != 0) { final limitedOutput = limitLength(result.stdout.join('\n'), 1000); diff --git a/test/validator/analyze_test.dart b/test/validator/analyze_test.dart index 5a1e8b404..55c9779d8 100644 --- a/test/validator/analyze_test.dart +++ b/test/validator/analyze_test.dart @@ -34,7 +34,7 @@ void main() { }); test( - 'follows analysis_options.yaml and should warn if package contains errors in pubspec.yaml', + 'follows analysis_options.yaml and should not warn if package contains only infos', () async { await d.dir(appPath, [ d.libPubspec( @@ -53,6 +53,32 @@ linter: ''') ]).create(); + await expectValidation(); + }); + + test( + 'follows analysis_options.yaml and should warn if package contains warnings in pubspec.yaml', + () async { + await d.dir(appPath, [ + d.libPubspec( + 'test_pkg', '1.0.0', + sdk: '^3.0.0', + // Using http where https is recommended. + extras: {'repository': 'http://repo.org/'}, + ), + d.file('LICENSE', 'Eh, do what you want.'), + d.file('README.md', "This package isn't real."), + d.file('CHANGELOG.md', '# 1.0.0\nFirst version\n'), + d.file('analysis_options.yaml', ''' +linter: + rules: + - secure_pubspec_urls +analyzer: + errors: + secure_pubspec_urls: warning +''') + ]).create(); + await expectValidation( error: allOf([ contains(