Skip to content

Linter: create rules to add syntaxtical sugar when else is set to false #1897

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

Karan-Palan
Copy link
Contributor

No description provided.

@Karan-Palan Karan-Palan changed the title create rule to add syntaxtical sugar when else or then is set to false Linter: create rules to add syntaxtical sugar when else or then is set to false Jul 27, 2025
@Karan-Palan Karan-Palan marked this pull request as draft July 27, 2025 22:05
@Karan-Palan Karan-Palan marked this pull request as ready for review August 6, 2025 19:00
@Karan-Palan Karan-Palan changed the title Linter: create rules to add syntaxtical sugar when else or then is set to false Linter: create rules to add syntaxtical sugar when else is set to false Aug 6, 2025
Signed-off-by: karan-palan <[email protected]>
Signed-off-by: karan-palan <[email protected]>
@Karan-Palan
Copy link
Contributor Author

@jviotti , any comments?

schema.erase("else");
if (if_schema.is_object()) {
for (const auto &entry : if_schema.as_object()) {
if (!schema.defines(entry.first)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add at least one test that covers this case?


auto transform(JSON &schema) const -> void override {
const auto if_schema = schema.at("if");
schema.erase("if");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is 100% correct. If the parent schema contains certain properties and you thus didn't elevate them, then you cannot remove the if? i.e. you have to only remove the if if it is empty?

Can you add tests for this too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants