You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[analyzer] Prioritize errors in analysis_options/pubspec errors when running "dart analyze"
This changes the (non-machine/json) output of "dart analyze" when there are errors in pubspec.yaml/analysis_options.
Before:
```
Analyzing myapp...
error • analysis_options.yaml:3:1 • Expected ':'. Parse errors in analysis_options.yaml may result in other incorrect diagnostics. • parse_error
error • lib\main.dart:1:16 • A value of type 'Null' can't be returned from the function 'foo' because it has a return type of 'int'. • return_of_invalid_type
2 issues found.
```
After:
```
Analyzing myapp...
Errors were found in pubspec.yaml or analysis_options.yaml which may result in other incorrect errors.
error • analysis_options.yaml:3:1 • Expected ':'. Parse errors in analysis_options.yaml may result in other incorrect diagnostics. • parse_error
Errors in other files that might be caused by those above.
error • lib\main.dart:1:16 • A value of type 'Null' can't be returned from the function 'foo' because it has a return type of 'int'. • return_of_invalid_type
2 issues found.
```
Fixes#55987
Change-Id: I25ae7b200463f2cd3f2046ea9f5f8ddc5c62cc60
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372080
Reviewed-by: Sam Rawlins <[email protected]>
Commit-Queue: Brian Wilkerson <[email protected]>
Reviewed-by: Brian Wilkerson <[email protected]>
Errors were found in 'pubspec.yaml' and/or 'analysis_options.yaml' which might result in either invalid diagnostics being produced or valid diagnostics being missed.
611
+
612
+
error - analysis_options.yaml:2:1 - Could not find expected ':' for simple key. - parse_error
613
+
614
+
Errors in remaining files.
615
+
616
+
error - lib${path.separator}main.dart:1:16 - A value of type 'Null' can't be returned from the function 'foo' because it has a return type of 'int'. - return_of_invalid_type
617
+
618
+
2 issues found.
619
+
''';
620
+
expect(stdout.trim(), expectedOutput.trim());
621
+
});
622
+
623
+
test('prioritizes errors in analysis_options.yaml (without other errors)',
Errors were found in 'pubspec.yaml' and/or 'analysis_options.yaml' which might result in either invalid diagnostics being produced or valid diagnostics being missed.
638
+
639
+
error - analysis_options.yaml:2:1 - Could not find expected ':' for simple key. - parse_error
640
+
641
+
1 issue found.
642
+
''';
643
+
expect(stdout.trim(), expectedOutput.trim());
644
+
});
645
+
646
+
test('does not prioritize warnings in analysis_options.yaml', () async {
error - lib${path.separator}main.dart:1:16 - A value of type 'Null' can't be returned from the function 'foo' because it has a return type of 'int'. - return_of_invalid_type
660
+
warning - analysis_options.yaml:1:10 - The include file 'package:lints/recommended.yaml' in '${p.analysisOptionsPath}' can't be found when analyzing '${p.dirPath}'. - include_file_not_found
0 commit comments