2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2024 Ericsson
4 * Modifications Copyright (C) 2024 OpenInfra Foundation Europe
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
21 package org.oran.smo.yangtools.parser.findings;
24 * A collection of finding types by the parser.
26 * Note that although these are defined as an enum, the finding type is of data type string. It is
27 * therefore possible to use finding types declared outside of this enum.
29 * @author Mark Hollmann
31 public enum ParserFindingType {
33 // Basic processing errors
36 * Usually thrown if there is a code error, typically a NPE caused by the model being really bad.
38 P000_UNSPECIFIED_ERROR,
40 * Couldn't read the file. Or the stream.
42 P001_BASIC_FILE_READ_ERROR,
44 * The type-safe class for an extension does not have the correct constructor.
46 P002_INVALID_EXTENSION_STATEMENT_CLASS,
48 * The exact same input has been supplied twice. Usually means the exact same file has been
49 * supplied twice for parsing.
53 * A module may only be implemented once by a server. It is possible that the same module, of
54 * different revisions, is listed multiple times in the input - but then only one of them can
55 * be conformance IMPLEMENT, the other ones must be conformance IMPORT.
57 P004_SAME_MODULE_DUPLICATE_IMPLEMENTS,
59 * There is no module in the input that has a conformance of IMPLEMENTS. Hence there will be
60 * no data nodes in the schema, which is rather pointless.
64 * There is a mismatch in conformance type between a module and its submodules.
66 P006_IMPLEMENT_IMPORT_MISMATCH,
68 * Two or more modules are in the input with the same module name but different namespace;
69 * or the other way around. This is a serious issue.
71 P007_MODULE_NAMESPACE_MISMATCH,
74 * Fail-fast. Denotes that during parsing some issues were found that are so severe that it
75 * does not really make sense to keep processing the schema, and the parser exists out.
79 // Basic syntax errors not relating to any particular statement or language construct.
82 * There are certain rules in YANG about how characters can be escaped in quoted text.
84 P011_INVALID_CHARACTER_ESCAPING_IN_QUOTED_TEXT,
86 * Same, just for unquoted text.
88 P012_INVALID_CHARACTER_IN_UNQUOTED_TEXT,
90 * Something wrong at the start of the document. May also indicate that the file is not
91 * Yang at all but something else entirely.
93 P013_INVALID_SYNTAX_AT_DOCUMENT_ROOT,
95 * Usually due to a mismatch of curly braces.
97 P014_INVALID_SYNTAX_AT_DOCUMENT_END,
99 * Bit of a catch-all finding for any syntax that is wrong in a document (not just Yang,
100 * also XML/JSON documents).
102 P015_INVALID_SYNTAX_IN_DOCUMENT,
104 * This statement is not allowed here.
106 P018_ILLEGAL_CHILD_STATEMENT,
108 * A mandatory statement is missing.
110 P019_MISSING_REQUIRED_CHILD_STATEMENT,
115 P025_INVALID_EXTENSION,
117 // The following relate to prefix, import's etc.
120 * In a YAM a declared prefix is not unique. This is a serious issue.
122 P031_PREFIX_NOT_UNIQUE,
124 * A YAM does not have a revision. While this is allowed in Yang, it is very poor modeling.
126 P032_MISSING_REVISION,
128 * A prefix is used and cannot be resolved. This is usually a typo in the prefix.
130 P033_UNRESOLVEABLE_PREFIX,
132 * There is an 'import' statement, but the module has not been supplied in the input.
134 P034_UNRESOLVABLE_IMPORT,
136 * Yang allows for multiple revisions of the same name to be part of the schema, as long as
137 * only at most one of them is of conformance IMPLEMENT. In those situations, other modules
138 * importing such modules must use an explicit revision-date.
140 P035_AMBIGUOUS_IMPORT,
142 * A YAM is importing the same module (possibly of different revision) multiple times.
144 P036_MODULE_IMPORTED_MULTIPLE_TIMES,
146 * A module includes a submodule, but the submodule has not been found in the input.
148 P037_UNRESOLVABLE_INCLUDE,
150 * Multiple revisions of a submodule are in the input. Not allowed.
152 P038_AMBIGUOUS_INCLUDE,
154 * A submodule refers to a module, but the module is not in the input.
156 P039_UNRESOLVABLE_BELONGS_TO,
158 * Submodules include each other. Extremely bad modeling.
160 P040_CIRCULAR_INCLUDE_REFERENCES,
162 * There is a mix of Yang 1 and Yang 1.1 versions between the module and its submodule(s).
163 * We don't really care, but technically that's not allowed by the spec.
165 P041_DIFFERENT_YANG_VERSIONS_BETWEEN_MODULE_AND_SUBMODULES,
167 * A YAM of conformance IMPORT is in the input but not referred-to from any other module.
168 * Not really an issue, but should be removed.
170 P042_UNREFERENCED_IMPORTED_FILE,
172 * If a module of different revisions is supplied more than once in the input, only one of
173 * them can have conformance IMPLEMENT.
175 P043_SAME_MODULE_IMPLEMENTS_MORE_THAN_ONCE,
177 * The same module is supplied as both conformance IMPLEMENT and IMPORT. That is not
178 * necessarily a problem, it may well be intentioned to be that way.
180 P044_SAME_MODULE_IMPLEMENTS_AND_IMPORTS,
182 * An 'include' resolves to a module, not a submodule.
184 P045_NOT_A_SUBMODULE,
186 * An 'belongs-to' resolves to a submodule, not a module.
190 * There is a mismatch between the 'include' and 'belongs-to' statements between a module
193 P047_SUBMODULE_OWNERSHIP_MISMATCH,
195 * A submodule is in the input, but its owning module is not in the input.
197 P048_ORPHAN_SUBMODULE,
199 * Two 'revision' statements (not latest) inside a YAM have the same date.
201 P049_DUPLICATE_REVISION,
203 * Two 'revision' statements (latest) inside a YAM have the same date. This is potentially
204 * a very serious problem. It indicates that the module content was updated, the revision
205 * statement was copied/pasted, but the date not updated. As a consequence there might be
206 * two modules in circulation having different content but the same revision date.
208 P050_DUPLICATE_LATEST_REVISION,
210 // Other generic YANG issues
213 * The cardinality of a statement is incorrect.
215 P051_INVALID_STATEMENT_CARDINALITY,
217 * Syntax error on a Yang identifier. Yang only allows a relatively small set of non-alphanumeric
220 P052_INVALID_YANG_IDENTIFIER,
222 * A value is used part of a statement, but the value is not valid in the context where it
227 * A path could not be resolved. This is usually due to typos, or the model designer forgetting
228 * to include all schema node names along the path. There is possibly also a prefix missing as
229 * part of one of the path elements.
231 P054_UNRESOLVABLE_PATH,
233 * Stuff in the YAM that need not be there.
235 P055_SUPERFLUOUS_STATEMENT,
239 P056_CONSTRAINT_NARROWED,
241 * It is possible to change the data type of data nodes by means of a deviation. This is likely
242 * to cause problems for clients that expect the original data type.
244 P057_DATA_TYPE_CHANGED,
246 // Relating to instance data
248 P064_ANNOTATION_USAGE,
251 P067_NOT_SINGLE_INSTANCE,
253 // Relating to instance data
256 * During parsing of annotation data a mismatch between leaf/leaf-list data and annotations
259 P069_UNEXPECTED_JSON_VALUE,
261 * During parsing of JSON data a JSON element of the wrong type was encountered (e.g. an
262 * array where an object was expected)
264 P070_WRONG_JSON_VALUE_TYPE,
266 * The root XML element of an XML file containing data is wrong. Only certain elements are
269 P071_INCORRECT_ROOT_ELEMENT_OF_DATA_FILE,
271 * When building an instance data tree the key value for a list instance was not found.
273 P072_MISSING_KEY_VALUE,
275 * During the merge of data from different sources into an instance data tree a leaf was
276 * encountered whose value differs between the inputs.
278 P073_LEAF_VALUE_ALREADY_SET,
280 * Data has been attempted to be set for a schema node that is not a data node.
282 P074_NOT_A_DATA_NODE,
284 * Data has been supplied for a data node that has not been found in the schema.
286 P075_CORRESPONDING_SCHEMA_NODE_NOT_FOUND,
288 * The same data node is declared more than once in the data (e.g., the same leaf is listed
289 * twice in the data).
291 P076_DUPLICATE_INSTANCE_DATA,
293 * There is a prefix in the XML file that has not been declared.
295 P077_UNRESOLVABLE_PREFIX,
297 * Nothing in the data file.
299 P079_EMPTY_DATA_FILE,
301 * A null value was encountered when building the instance data tree.
308 * Some data in the Yang Library is wrong.
310 P081_INCORRECT_YANG_LIBRARY_DATA,
312 * A mandatory piece of information from the data.
314 P082_YANG_LIBRARY_MANDATORY_VALUE_MISSING,
316 * There is a feature listed inside the Yang Library, but this feature has not been defined
317 * in the corresponding module.
319 P083_FEATURE_LISTED_IN_YANG_LIBRARY_NOT_FOUND,
321 * There is more than one YL in the input
323 P084_MULTIPLE_YANG_LIBRARIES_IN_INPUT,
325 * What has been supplied as input in terms of modules does not match up with the modules
326 * listed in the Yang Library.
328 P085_MISMATCH_BETWEEN_INPUT_MODULES_AND_YANG_LIBRARY,
330 * A feature has been marked as supported, but it depends on other features that are not supported.
332 P086_FEATURE_CANNOT_BE_SUPPORTED,
337 * The same module has been found twice by the collector.
339 P091_COLLECTOR_DUPLICATE_INPUT,
341 * The collector found an input that does not appear to be a valid YAM.
343 P092_COLLECTOR_NOT_A_VALID_YAM,
345 * A dependent module was not found by a collector.
347 P093_COLLECTOR_MODULE_NOT_FOUND,
352 * Some data in NACM is wrong.
354 P096_INCORRECT_NACM_DATA,
356 // Specific issues, general statements
359 * A description statement has no content (which is a bit pointless)
361 P101_EMPTY_DOCUMENTATION_VALUE,
363 * A schema node has an illegal status
367 * The syntax of an 'if-feature' statement is wrong.
369 P103_ILLEGAL_IF_FEATURE_SYNTAX,
371 * A deprecated statement is being used.
373 P104_USAGE_OF_DEPRECATED_ELEMENT,
375 // Specific issues: typedef
378 * typedefs have a circular dependency.
380 P111_CIRCULAR_TYPEDEF_REFERENCES,
382 * There is a lot of nesting of typedefs. Typically makes the model unreadable.
384 P112_EXCESSIVE_TYPEDEF_DEPTH,
386 * A derived type could not be resolved.
388 P113_UNRESOLVABLE_DERIVED_TYPE,
390 * A typedef is not being used. Not necessarily an issue, but might indicate a buggy model.
392 P114_TYPEDEF_NOT_USED,
394 * A typedef is only used once. Doesn't really make sense, why not simply inline the content?
396 P115_TYPEDEF_USED_ONCE_ONLY,
398 * A derived type refers to yet another derived type, but that one is not resolvable.
400 P116_NESTED_DERIVED_TYPE_NOT_RESOLVABLE,
402 * A derived type is restricting the base type in illegal manner.
404 P117_ILLEGAL_DATA_TYPE_RESTRICTION,
406 // Specific issues: uses / grouping
409 * uses have a circular dependency.
411 P121_CIRCULAR_USES_REFERENCES,
413 * There is a lot of nesting of uses/grouping. Typically makes the model unreadable.
415 P122_EXCESSIVE_USES_DEPTH,
417 * An 'augment' part of a 'uses' augments a schema node that may not be augmented.
419 P123_INVALID_USES_AUGMENT_TARGET_NODE,
421 * A 'refine' part of a 'uses' refines a schema node that may not be refined.
423 P124_INVALID_REFINE_TARGET_NODE,
425 * A uses statement could be resolved to a grouping.
427 P131_UNRESOLVABLE_GROUPING,
429 * A grouping is not being used.
431 P132_GROUPING_NOT_USED,
433 * A grouping is used only once (why not inline?)
435 P133_GROUPING_USED_ONCE_ONLY,
437 * A 'uses' points to a 'grouping' that itself has a 'uses', and that 'uses' is not resolvable.
439 P134_NESTED_USES_NOT_RESOLVABLE,
441 // Specific issues: enum / bits
444 * There is a whitespace in the name of an enum member. While this is technically allowed by
445 * the RFC, it is very bad modeling, as it goes against the coding convention of every major
446 * programming language and it will lead to problems downstream somewhere.
448 P141_WHITESPACE_IN_ENUM,
450 * An enum member name contains characters that are usually disallowed as part of enums in
451 * major programming languages. Expect issues downstream.
453 P142_UNUSUAL_CHARACTERS_IN_ENUM,
455 * An enum member does not have a value. This is allowed in Yang as the values can be auto-generated,
456 * but it is dangerous as a new / removed enum inside the enumeration will cause the auto-generated
457 * values to change in an incompatible manner.
459 P143_ENUM_WITHOUT_VALUE,
461 * A bit does not have a position. This is allowed in Yang as the positions can be auto-generated,
462 * but it is dangerous as a new / removed bits cause the auto-generated positions to change in an
463 * incompatible manner.
465 P144_BIT_WITHOUT_POSITION,
467 // Specific issues: augmentation
470 * An 'augment's target schema node may not be augmented.
472 P151_TARGET_NODE_CANNOT_BE_AUGMENTED,
474 * The 'augment' and its target sit in the same module. Bad modeling.
476 P152_AUGMENT_TARGET_NODE_IN_SAME_MODULE,
478 // Specific issues: deviation
481 * Invalid operation for a deviate.
483 P161_INVALID_DEVIATE_OPERATION,
485 * The 'deviation' and its target sit in the same module. Bad modeling.
487 P162_DEVIATION_TARGET_NODE_IN_SAME_MODULE,
489 * There are two 'deviate replace' statements that modify the exact same schema node.
491 P163_AMBIGUOUS_DEVIATE_REPLACE_OF_SAME_STATEMENT,
493 * A statement that has been added previously has now been replaced.
495 P164_DEVIATE_REPLACE_OF_DEVIATE_ADDED_STATEMENT,
497 * A statement that has been modified via a deviation has now also beed deleted.
499 P165_DEVIATE_DELETE_OF_DEVIATED_STATEMENT,
501 * The deviate would result in a statement cardinality validation.
503 P166_DEVIATE_RESULTS_IN_CHILD_CARDINALITY_VIOLATION,
505 * Certain statements cannot be added or deleted, only replaced. This is a hint.
507 P167_CANNOT_USE_UNDER_DEVIATE_ADD_OR_DELETE
510 * Values 200+ reserved for downstream tooling, so don't go beyond P199