Skip to content

Conversation

Karan-Palan
Copy link
Contributor

No description provided.

Signed-off-by: karan-palan <karanpalan007@gmail.com>
@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
Signed-off-by: karan-palan <karanpalan007@gmail.com>
Signed-off-by: karan-palan <karanpalan007@gmail.com>
@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 <karanpalan007@gmail.com>
Signed-off-by: karan-palan <karanpalan007@gmail.com>
@Karan-Palan
Copy link
Contributor Author

@jviotti , any comments?

Signed-off-by: karan-palan <karanpalan007@gmail.com>
Signed-off-by: karan-palan <karanpalan007@gmail.com>
Signed-off-by: karan-palan <karanpalan007@gmail.com>
@Karan-Palan Karan-Palan force-pushed the linter/then-else-false branch from 842fb35 to b0c7520 Compare August 15, 2025 00:47
condition(const JSON &schema, const JSON &, const Vocabularies &vocabularies,
const SchemaFrame &, const SchemaFrame::Location &,
const SchemaWalker &, const SchemaResolver &) const
-> SchemaTransformRule::Result override {
Copy link
Member

Choose a reason for hiding this comment

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

I think at this point you can simplify the condition by making it a one liner on a return. That will make it easier to read, as we won't be reading negated conditionals

schema.assign(entry.first, entry.second);
}
}
} else if (if_schema.is_boolean() && !if_schema.to_boolean()) {
Copy link
Member

Choose a reason for hiding this comment

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

I think this branch will be problematic. You are only keeping certain keywords like $schema but we are not being exhaustive. There could be anchors, or any other thing too. Can we just check against this case in the condition? I think we would need another rule to properly handle this and many of its edge cases

Signed-off-by: karan-palan <karanpalan007@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants