-
-
Notifications
You must be signed in to change notification settings - Fork 15
Better distinguish between invalid or missing schema linter titles #634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,9 +47,15 @@ static auto extract_description(const sourcemeta::core::JSON &schema) | |
| } | ||
|
|
||
| static auto extract_title(const sourcemeta::core::JSON &schema) -> std::string { | ||
| if (!schema.defines("title") || !schema.at("title").is_string()) { | ||
| throw LinterInvalidNameError( | ||
| "", "The schema rule title is missing or not a string"); | ||
| if (!schema.defines("title")) { | ||
| throw LinterMissingNameError{}; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This changes the exception type for a missing Severity: medium 🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage. |
||
| } | ||
|
|
||
| if (!schema.at("title").is_string()) { | ||
| std::ostringstream result; | ||
| sourcemeta::core::stringify(schema.at("title"), result); | ||
| throw LinterInvalidNameError(std::move(result).str(), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For non-string Severity: low 🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage. |
||
| "The schema rule title is not a string"); | ||
| } | ||
|
|
||
| auto title{schema.at("title").to_string()}; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docstring says this is a “missing rule name”, but the error is specifically about a missing schema
title(andwhat()also says “title”); consider aligning the terminology so the public API/docs/message are consistent.Severity: low
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.