-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port
redundant/if_without_then_else
from JSON BinPack (#209)
Signed-off-by: Juan Cruz Viotti <[email protected]>
- Loading branch information
Showing
11 changed files
with
92 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
class IfWithoutThenElse final : public Rule { | ||
public: | ||
IfWithoutThenElse() | ||
: Rule{"if_without_then_else", | ||
"The `if` keyword is meaningless " | ||
"without the presence of the `then` or `else` keywords"} {}; | ||
|
||
[[nodiscard]] auto | ||
condition(const sourcemeta::jsontoolkit::JSON &schema, const std::string &, | ||
const std::set<std::string> &vocabularies, | ||
const sourcemeta::jsontoolkit::Pointer &) const -> bool override { | ||
return contains_any( | ||
vocabularies, | ||
{"https://json-schema.org/draft/2020-12/vocab/applicator", | ||
"https://json-schema.org/draft/2019-09/vocab/applicator", | ||
"http://json-schema.org/draft-07/schema#"}) && | ||
schema.is_object() && schema.defines("if") && | ||
!schema.defines("then") && !schema.defines("else"); | ||
} | ||
|
||
auto transform(Transformer &transformer) const -> void override { | ||
transformer.erase("if"); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters