Skip to content

Commit

Permalink
Reject invalid onlyIssues CLI usage (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
lexaknyazev authored Oct 18, 2024
1 parent 1c107cd commit 6033ce9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 8 additions & 3 deletions lib/cmd_line.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ ValidationOptions _getValidationOptionsFromYaml(String fileName) {
const kOverride = 'override';

void abort(Object e) {
stderr.write(e);
stderr.writeln(e);
exit(kErrorCode);
}

Expand Down Expand Up @@ -135,7 +135,7 @@ ValidationOptions _getValidationOptionsFromYaml(String fileName) {
}
}, growable: false);
} else if (yamlIgnoredIssues != null) {
abort("$kYamlError 'ignored' must be a sequence.");
abort("$kYamlError '$kIgnore' must be a sequence.");
}

final Object yamlOnlyIssues = yaml[kOnly];
Expand All @@ -150,7 +150,12 @@ ValidationOptions _getValidationOptionsFromYaml(String fileName) {
}
}, growable: false);
} else if (yamlOnlyIssues != null) {
abort("$kYamlError 'only' must be a sequence.");
abort("$kYamlError '$kOnly' must be a sequence.");
}

if (onlyIssues != null && ignoredIssues != null) {
abort("$kYamlError option '$kOnly' cannot be used "
"along with option '$kIgnore'.");
}

final Object yamlSeveritiesMap = yaml[kOverride];
Expand Down
4 changes: 2 additions & 2 deletions node/gltf_validator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ Context _getContextFromOptions(_JSValidationOptions options) {
}

if (options.onlyIssues != null && options.ignoredIssues != null) {
throw ArgumentError(
'options.onlyIssues cannot be used along with options.ignoredIssues.');
throw ArgumentError('options.onlyIssues cannot be used '
'along with options.ignoredIssues.');
}

if (options.onlyIssues != null) {
Expand Down

0 comments on commit 6033ce9

Please sign in to comment.