From 6463dcb9253831dccfa52aff5f633e501337df30 Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Wed, 11 Dec 2019 20:33:06 -0600 Subject: [PATCH] meta-schemas: Add check for unnecessary minItems/maxItems If we have an 'items' list and minItems/maxItems both define the same number of items, then they are not necessary and can be removed. The fixups will add them automatically. Signed-off-by: Rob Herring --- meta-schemas/core.yaml | 1 + meta-schemas/items.yaml | 155 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 156 insertions(+) create mode 100644 meta-schemas/items.yaml diff --git a/meta-schemas/core.yaml b/meta-schemas/core.yaml index b329c26e..146f5e0b 100644 --- a/meta-schemas/core.yaml +++ b/meta-schemas/core.yaml @@ -48,6 +48,7 @@ definitions: $ref: "#/definitions/all-properties" allOf: + - $ref: "items.yaml#" - if: type: object properties: diff --git a/meta-schemas/items.yaml b/meta-schemas/items.yaml new file mode 100644 index 00000000..7138b4dd --- /dev/null +++ b/meta-schemas/items.yaml @@ -0,0 +1,155 @@ +# SPDX-License-Identifier: BSD-2-Clause +# Copyright 2019 Arm Ltd. +%YAML 1.2 +--- +$id: "http://devicetree.org/meta-schemas/items.yaml#" +$schema: "http://json-schema.org/draft-07/schema#" + +description: + Meta-schema for 'items' schema. This meta-schema checks that an 'items' list + doesn't have 'minItems' and 'maxItems' with the same value as the length of + the list. + +properties: + allOf: + items: + $ref: '#' + anyOf: + items: + $ref: '#' + oneOf: + items: + $ref: '#' + then: + $ref: '#' + +allOf: + - if: + required: + - items + - minItems + - maxItems + oneOf: + - properties: + items: + type: array + minItems: 2 + maxItems: 2 + minItems: + const: 2 + maxItems: + const: 2 + - properties: + items: + type: array + minItems: 3 + maxItems: 3 + minItems: + const: 3 + maxItems: + const: 3 + - properties: + items: + type: array + minItems: 4 + maxItems: 4 + minItems: + const: 4 + maxItems: + const: 4 + - properties: + items: + type: array + minItems: 5 + maxItems: 5 + minItems: + const: 5 + maxItems: + const: 5 + - properties: + items: + type: array + minItems: 6 + maxItems: 6 + minItems: + const: 6 + maxItems: + const: 6 + - properties: + items: + type: array + minItems: 7 + maxItems: 7 + minItems: + const: 7 + maxItems: + const: 7 + - properties: + items: + type: array + minItems: 8 + maxItems: 8 + minItems: + const: 8 + maxItems: + const: 8 + - properties: + items: + type: array + minItems: 9 + maxItems: 9 + minItems: + const: 9 + maxItems: + const: 9 + - properties: + items: + type: array + minItems: 10 + maxItems: 10 + minItems: + const: 10 + maxItems: + const: 10 + - properties: + items: + type: array + minItems: 11 + maxItems: 11 + minItems: + const: 11 + maxItems: + const: 11 + - properties: + items: + type: array + minItems: 12 + maxItems: 12 + minItems: + const: 12 + maxItems: + const: 12 + - properties: + items: + type: array + minItems: 16 + maxItems: 16 + minItems: + const: 16 + maxItems: + const: 16 + - properties: + items: + type: array + minItems: 32 + maxItems: 32 + minItems: + const: 32 + maxItems: + const: 32 + then: + properties: + minItems: false + maxItems: false + +...