Skip to content

Commit a84147a

Browse files
srawlinsCommit Queue
authored andcommitted
analyzer: fix analysis of empty section in analysis options
With a recent change, I noticed that I was getting a lot of "invalid section" warnings, with valid YAML. Change-Id: I7ee64fc793cb74d54e74d9ebeb21b350c5bb7584 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/446563 Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 185d607 commit a84147a

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

pkg/analyzer/lib/src/analysis_options/options_file_validator.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,9 +1077,9 @@ class _TopLevelOptionValidator extends OptionsValidator {
10771077
@override
10781078
void validate(DiagnosticReporter reporter, YamlMap options) {
10791079
var node = options.valueAt(pluginName);
1080-
if (node == null) {
1081-
return;
1082-
}
1080+
if (node == null) return;
1081+
if (node is YamlScalar && node.value == null) return;
1082+
10831083
if (node is! YamlMap) {
10841084
reporter.atSourceSpan(
10851085
node.span,

pkg/analyzer/test/src/options/options_file_validator_test.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,13 @@ analyzer:
143143
);
144144
}
145145

146+
test_analyzer_empty() {
147+
registerLintRule(TestRule());
148+
validate('''
149+
analyzer:
150+
''', []);
151+
}
152+
146153
test_analyzer_enableExperiment_badValue() {
147154
validate(
148155
'''

0 commit comments

Comments
 (0)