Skip to content

Commit fe07eda

Browse files
authored
Better detect unreferenced definitions in the linter (#595)
Signed-off-by: Juan Cruz Viotti <[email protected]>
1 parent cfd763b commit fe07eda

File tree

14 files changed

+486
-29
lines changed

14 files changed

+486
-29
lines changed

DEPENDENCIES

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
vendorpull https://github.com/sourcemeta/vendorpull 1dcbac42809cf87cb5b045106b863e17ad84ba02
2-
core https://github.com/sourcemeta/core e4d7ae9358710fc138d2afd3179db6d850e4190f
2+
core https://github.com/sourcemeta/core 9985d96665aae0a8dfabf63f59b0732b92c64771
33
jsonbinpack https://github.com/sourcemeta/jsonbinpack 8fae212dc7ec02af4bb0cd4e7fccd42a2471f1c1
44
blaze https://github.com/sourcemeta/blaze 8dba65f8aebfe1ac976168b76e01c20dd406c517
55
hydra https://github.com/sourcemeta/hydra af9f2c54709d620872ead0c3f8f683c15a0fa702

src/command_lint.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,6 @@ auto sourcemeta::jsonschema::lint(const sourcemeta::core::Options &options)
127127
bundle.add<sourcemeta::blaze::ValidDefault>(
128128
sourcemeta::blaze::default_schema_compiler);
129129

130-
// TODO: This rule has known problems we are working hard to fix right now
131-
// See https://github.com/sourcemeta/core/pull/2145
132-
bundle.remove("orphan_definitions");
133-
134130
if (options.contains("only")) {
135131
if (options.contains("exclude")) {
136132
throw OptionConflictError{

test/lint/pass_lint_list_exclude.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ non_applicable_type_specific_keywords
139139
not_false
140140
Setting the `not` keyword to `false` imposes no constraints. Negating `false` yields the always-true schema
141141
142+
orphan_definitions
143+
Schema definitions in `$defs` or `definitions` that are never internally referenced can be removed
144+
142145
pattern_properties_default
143146
Setting the `patternProperties` keyword to the empty object does not add any further constraint
144147
@@ -205,13 +208,16 @@ unnecessary_allof_ref_wrapper_modern
205208
unnecessary_allof_wrapper
206209
Keywords inside `allOf` that do not conflict with the parent schema can be elevated
207210
211+
unsatisfiable_in_place_applicator_type
212+
An in-place applicator branch that defines a `type` with no overlap with the parent `type` can never be satisfied
213+
208214
unsatisfiable_max_contains
209215
Setting the `maxContains` keyword to a number greater than or equal to the array upper bound does not add any further constraint
210216
211217
unsatisfiable_min_properties
212218
Setting `minProperties` to a number less than `required` does not add any further constraint
213219
214-
Number of rules: 67
220+
Number of rules: 69
215221
EOF
216222

217223
diff "$TMP/output.txt" "$TMP/expected.txt"

test/lint/pass_lint_list_long.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ non_applicable_type_specific_keywords
145145
not_false
146146
Setting the `not` keyword to `false` imposes no constraints. Negating `false` yields the always-true schema
147147
148+
orphan_definitions
149+
Schema definitions in `$defs` or `definitions` that are never internally referenced can be removed
150+
148151
pattern_properties_default
149152
Setting the `patternProperties` keyword to the empty object does not add any further constraint
150153
@@ -211,13 +214,16 @@ unnecessary_allof_ref_wrapper_modern
211214
unnecessary_allof_wrapper
212215
Keywords inside `allOf` that do not conflict with the parent schema can be elevated
213216
217+
unsatisfiable_in_place_applicator_type
218+
An in-place applicator branch that defines a `type` with no overlap with the parent `type` can never be satisfied
219+
214220
unsatisfiable_max_contains
215221
Setting the `maxContains` keyword to a number greater than or equal to the array upper bound does not add any further constraint
216222
217223
unsatisfiable_min_properties
218224
Setting `minProperties` to a number less than `required` does not add any further constraint
219225
220-
Number of rules: 69
226+
Number of rules: 71
221227
EOF
222228

223229
diff "$TMP/output.txt" "$TMP/expected.txt"

test/lint/pass_lint_list_short.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ non_applicable_type_specific_keywords
145145
not_false
146146
Setting the `not` keyword to `false` imposes no constraints. Negating `false` yields the always-true schema
147147
148+
orphan_definitions
149+
Schema definitions in `$defs` or `definitions` that are never internally referenced can be removed
150+
148151
pattern_properties_default
149152
Setting the `patternProperties` keyword to the empty object does not add any further constraint
150153
@@ -211,13 +214,16 @@ unnecessary_allof_ref_wrapper_modern
211214
unnecessary_allof_wrapper
212215
Keywords inside `allOf` that do not conflict with the parent schema can be elevated
213216
217+
unsatisfiable_in_place_applicator_type
218+
An in-place applicator branch that defines a `type` with no overlap with the parent `type` can never be satisfied
219+
214220
unsatisfiable_max_contains
215221
Setting the `maxContains` keyword to a number greater than or equal to the array upper bound does not add any further constraint
216222
217223
unsatisfiable_min_properties
218224
Setting `minProperties` to a number less than `required` does not add any further constraint
219225
220-
Number of rules: 69
226+
Number of rules: 71
221227
EOF
222228

223229
diff "$TMP/output.txt" "$TMP/expected.txt"

vendor/core/src/core/jsonpointer/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/core/src/core/jsonpointer/include/sourcemeta/core/jsonpointer.h

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/core/src/core/jsonpointer/include/sourcemeta/core/jsonpointer_pointer.h

Lines changed: 49 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)