50b01ec8c7e461ea009eae086bb198b72bbd660c
[smo/teiv.git] /
1 /*
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
9  *
10  *        http://www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  *
18  *  SPDX-License-Identifier: Apache-2.0
19  *  ============LICENSE_END=========================================================
20  */
21 package org.oran.smo.yangtools.parser.findings;
22
23 /**
24  * A collection of finding types by the parser.
25  * <p/>
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.
28  *
29  * @author Mark Hollmann
30  */
31 public enum ParserFindingType {
32
33     // Basic processing errors
34
35     /**
36      * Usually thrown if there is a code error, typically a NPE caused by the model being really bad.
37      */
38     P000_UNSPECIFIED_ERROR,
39     /**
40      * Couldn't read the file. Or the stream.
41      */
42     P001_BASIC_FILE_READ_ERROR,
43     /**
44      * The type-safe class for an extension does not have the correct constructor.
45      */
46     P002_INVALID_EXTENSION_STATEMENT_CLASS,
47     /**
48      * The exact same input has been supplied twice. Usually means the exact same file has been
49      * supplied twice for parsing.
50      */
51     P003_DUPLICATE_INPUT,
52     /**
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.
56      */
57     P004_SAME_MODULE_DUPLICATE_IMPLEMENTS,
58     /**
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.
61      */
62     P005_NO_IMPLEMENTS,
63     /**
64      * There is a mismatch in conformance type between a module and its submodules.
65      */
66     P006_IMPLEMENT_IMPORT_MISMATCH,
67     /**
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.
70      */
71     P007_MODULE_NAMESPACE_MISMATCH,
72
73     /**
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.
76      */
77     P009_FAIL_FAST,
78
79     // Basic syntax errors not relating to any particular statement or language construct.
80
81     /**
82      * There are certain rules in YANG about how characters can be escaped in quoted text.
83      */
84     P011_INVALID_CHARACTER_ESCAPING_IN_QUOTED_TEXT,
85     /**
86      * Same, just for unquoted text.
87      */
88     P012_INVALID_CHARACTER_IN_UNQUOTED_TEXT,
89     /**
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.
92      */
93     P013_INVALID_SYNTAX_AT_DOCUMENT_ROOT,
94     /**
95      * Usually due to a mismatch of curly braces.
96      */
97     P014_INVALID_SYNTAX_AT_DOCUMENT_END,
98     /**
99      * Bit of a catch-all finding for any syntax that is wrong in a document (not just Yang,
100      * also XML/JSON documents).
101      */
102     P015_INVALID_SYNTAX_IN_DOCUMENT,
103     /**
104      * This statement is not allowed here.
105      */
106     P018_ILLEGAL_CHILD_STATEMENT,
107     /**
108      * A mandatory statement is missing.
109      */
110     P019_MISSING_REQUIRED_CHILD_STATEMENT,
111
112     /*
113      *
114      */
115     P025_INVALID_EXTENSION,
116
117     // The following relate to prefix, import's etc.
118
119     /**
120      * In a YAM a declared prefix is not unique. This is a serious issue.
121      */
122     P031_PREFIX_NOT_UNIQUE,
123     /**
124      * A YAM does not have a revision. While this is allowed in Yang, it is very poor modeling.
125      */
126     P032_MISSING_REVISION,
127     /**
128      * A prefix is used and cannot be resolved. This is usually a typo in the prefix.
129      */
130     P033_UNRESOLVEABLE_PREFIX,
131     /**
132      * There is an 'import' statement, but the module has not been supplied in the input.
133      */
134     P034_UNRESOLVABLE_IMPORT,
135     /**
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.
139      */
140     P035_AMBIGUOUS_IMPORT,
141     /**
142      * A YAM is importing the same module (possibly of different revision) multiple times.
143      */
144     P036_MODULE_IMPORTED_MULTIPLE_TIMES,
145     /**
146      * A module includes a submodule, but the submodule has not been found in the input.
147      */
148     P037_UNRESOLVABLE_INCLUDE,
149     /**
150      * Multiple revisions of a submodule are in the input. Not allowed.
151      */
152     P038_AMBIGUOUS_INCLUDE,
153     /**
154      * A submodule refers to a module, but the module is not in the input.
155      */
156     P039_UNRESOLVABLE_BELONGS_TO,
157     /**
158      * Submodules include each other. Extremely bad modeling.
159      */
160     P040_CIRCULAR_INCLUDE_REFERENCES,
161     /**
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.
164      */
165     P041_DIFFERENT_YANG_VERSIONS_BETWEEN_MODULE_AND_SUBMODULES,
166     /**
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.
169      */
170     P042_UNREFERENCED_IMPORTED_FILE,
171     /**
172      * If a module of different revisions is supplied more than once in the input, only one of
173      * them can have conformance IMPLEMENT.
174      */
175     P043_SAME_MODULE_IMPLEMENTS_MORE_THAN_ONCE,
176     /**
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.
179      */
180     P044_SAME_MODULE_IMPLEMENTS_AND_IMPORTS,
181     /**
182      * An 'include' resolves to a module, not a submodule.
183      */
184     P045_NOT_A_SUBMODULE,
185     /**
186      * An 'belongs-to' resolves to a submodule, not a module.
187      */
188     P046_NOT_A_MODULE,
189     /**
190      * There is a mismatch between the 'include' and 'belongs-to' statements between a module
191      * and a submodule.
192      */
193     P047_SUBMODULE_OWNERSHIP_MISMATCH,
194     /**
195      * A submodule is in the input, but its owning module is not in the input.
196      */
197     P048_ORPHAN_SUBMODULE,
198     /**
199      * Two 'revision' statements (not latest) inside a YAM have the same date.
200      */
201     P049_DUPLICATE_REVISION,
202     /**
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.
207      */
208     P050_DUPLICATE_LATEST_REVISION,
209
210     // Other generic YANG issues
211
212     /**
213      * The cardinality of a statement is incorrect.
214      */
215     P051_INVALID_STATEMENT_CARDINALITY,
216     /**
217      * Syntax error on a Yang identifier. Yang only allows a relatively small set of non-alphanumeric
218      * characters.
219      */
220     P052_INVALID_YANG_IDENTIFIER,
221     /**
222      * A value is used part of a statement, but the value is not valid in the context where it
223      * is used.
224      */
225     P053_INVALID_VALUE,
226     /**
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.
230      */
231     P054_UNRESOLVABLE_PATH,
232     /**
233      * Stuff in the YAM that need not be there.
234      */
235     P055_SUPERFLUOUS_STATEMENT,
236     /**
237      * TODO - check this.
238      */
239     P056_CONSTRAINT_NARROWED,
240     /**
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.
243      */
244     P057_DATA_TYPE_CHANGED,
245
246     // Relating to instance data
247
248     P064_ANNOTATION_USAGE,
249     P065_CANNOT_CONVERT,
250     P066_NO_SETTER,
251     P067_NOT_SINGLE_INSTANCE,
252
253     // Relating to instance data
254
255     /**
256      * During parsing of annotation data a mismatch between leaf/leaf-list data and annotations
257      * was found.
258      */
259     P069_UNEXPECTED_JSON_VALUE,
260     /**
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)
263      */
264     P070_WRONG_JSON_VALUE_TYPE,
265     /**
266      * The root XML element of an XML file containing data is wrong. Only certain elements are
267      * supported.
268      */
269     P071_INCORRECT_ROOT_ELEMENT_OF_DATA_FILE,
270     /**
271      * When building an instance data tree the key value for a list instance was not found.
272      */
273     P072_MISSING_KEY_VALUE,
274     /**
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.
277      */
278     P073_LEAF_VALUE_ALREADY_SET,
279     /**
280      * Data has been attempted to be set for a schema node that is not a data node.
281      */
282     P074_NOT_A_DATA_NODE,
283     /**
284      * Data has been supplied for a data node that has not been found in the schema.
285      */
286     P075_CORRESPONDING_SCHEMA_NODE_NOT_FOUND,
287     /**
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).
290      */
291     P076_DUPLICATE_INSTANCE_DATA,
292     /**
293      * There is a prefix in the XML file that has not been declared.
294      */
295     P077_UNRESOLVABLE_PREFIX,
296     /**
297      * Nothing in the data file.
298      */
299     P079_EMPTY_DATA_FILE,
300     /**
301      * A null value was encountered when building the instance data tree.
302      */
303     P080_NULL_VALUE,
304
305     // Yang Library
306
307     /**
308      * Some data in the Yang Library is wrong.
309      */
310     P081_INCORRECT_YANG_LIBRARY_DATA,
311     /**
312      * A mandatory piece of information from the data.
313      */
314     P082_YANG_LIBRARY_MANDATORY_VALUE_MISSING,
315     /**
316      * There is a feature listed inside the Yang Library, but this feature has not been defined
317      * in the corresponding module.
318      */
319     P083_FEATURE_LISTED_IN_YANG_LIBRARY_NOT_FOUND,
320     /**
321      * There is more than one YL in the input
322      */
323     P084_MULTIPLE_YANG_LIBRARIES_IN_INPUT,
324     /**
325      * What has been supplied as input in terms of modules does not match up with the modules
326      * listed in the Yang Library.
327      */
328     P085_MISMATCH_BETWEEN_INPUT_MODULES_AND_YANG_LIBRARY,
329     /**
330      * A feature has been marked as supported, but it depends on other features that are not supported.
331      */
332     P086_FEATURE_CANNOT_BE_SUPPORTED,
333
334     // Collector
335
336     /**
337      * The same module has been found twice by the collector.
338      */
339     P091_COLLECTOR_DUPLICATE_INPUT,
340     /**
341      * The collector found an input that does not appear to be a valid YAM.
342      */
343     P092_COLLECTOR_NOT_A_VALID_YAM,
344     /**
345      * A dependent module was not found by a collector.
346      */
347     P093_COLLECTOR_MODULE_NOT_FOUND,
348
349     // NACM
350
351     /**
352      * Some data in NACM is wrong.
353      */
354     P096_INCORRECT_NACM_DATA,
355
356     // Specific issues, general statements
357
358     /**
359      * A description statement has no content (which is a bit pointless)
360      */
361     P101_EMPTY_DOCUMENTATION_VALUE,
362     /**
363      * A schema node has an illegal status
364      */
365     P102_INVALID_STATUS,
366     /**
367      * The syntax of an 'if-feature' statement is wrong.
368      */
369     P103_ILLEGAL_IF_FEATURE_SYNTAX,
370     /**
371      * A deprecated statement is being used.
372      */
373     P104_USAGE_OF_DEPRECATED_ELEMENT,
374
375     // Specific issues: typedef
376
377     /**
378      * typedefs have a circular dependency.
379      */
380     P111_CIRCULAR_TYPEDEF_REFERENCES,
381     /**
382      * There is a lot of nesting of typedefs. Typically makes the model unreadable.
383      */
384     P112_EXCESSIVE_TYPEDEF_DEPTH,
385     /**
386      * A derived type could not be resolved.
387      */
388     P113_UNRESOLVABLE_DERIVED_TYPE,
389     /**
390      * A typedef is not being used. Not necessarily an issue, but might indicate a buggy model.
391      */
392     P114_TYPEDEF_NOT_USED,
393     /**
394      * A typedef is only used once. Doesn't really make sense, why not simply inline the content?
395      */
396     P115_TYPEDEF_USED_ONCE_ONLY,
397     /**
398      * A derived type refers to yet another derived type, but that one is not resolvable.
399      */
400     P116_NESTED_DERIVED_TYPE_NOT_RESOLVABLE,
401     /**
402      * A derived type is restricting the base type in illegal manner.
403      */
404     P117_ILLEGAL_DATA_TYPE_RESTRICTION,
405
406     // Specific issues: uses / grouping
407
408     /**
409      * uses have a circular dependency.
410      */
411     P121_CIRCULAR_USES_REFERENCES,
412     /**
413      * There is a lot of nesting of uses/grouping. Typically makes the model unreadable.
414      */
415     P122_EXCESSIVE_USES_DEPTH,
416     /**
417      * An 'augment' part of a 'uses' augments a schema node that may not be augmented.
418      */
419     P123_INVALID_USES_AUGMENT_TARGET_NODE,
420     /**
421      * A 'refine' part of a 'uses' refines a schema node that may not be refined.
422      */
423     P124_INVALID_REFINE_TARGET_NODE,
424     /**
425      * A uses statement could be resolved to a grouping.
426      */
427     P131_UNRESOLVABLE_GROUPING,
428     /**
429      * A grouping is not being used.
430      */
431     P132_GROUPING_NOT_USED,
432     /**
433      * A grouping is used only once (why not inline?)
434      */
435     P133_GROUPING_USED_ONCE_ONLY,
436     /**
437      * A 'uses' points to a 'grouping' that itself has a 'uses', and that 'uses' is not resolvable.
438      */
439     P134_NESTED_USES_NOT_RESOLVABLE,
440
441     // Specific issues: enum / bits
442
443     /**
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.
447      */
448     P141_WHITESPACE_IN_ENUM,
449     /**
450      * An enum member name contains characters that are usually disallowed as part of enums in
451      * major programming languages. Expect issues downstream.
452      */
453     P142_UNUSUAL_CHARACTERS_IN_ENUM,
454     /**
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.
458      */
459     P143_ENUM_WITHOUT_VALUE,
460     /**
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.
464      */
465     P144_BIT_WITHOUT_POSITION,
466
467     // Specific issues: augmentation
468
469     /**
470      * An 'augment's target schema node may not be augmented.
471      */
472     P151_TARGET_NODE_CANNOT_BE_AUGMENTED,
473     /**
474      * The 'augment' and its target sit in the same module. Bad modeling.
475      */
476     P152_AUGMENT_TARGET_NODE_IN_SAME_MODULE,
477
478     // Specific issues: deviation
479
480     /**
481      * Invalid operation for a deviate.
482      */
483     P161_INVALID_DEVIATE_OPERATION,
484     /**
485      * The 'deviation' and its target sit in the same module. Bad modeling.
486      */
487     P162_DEVIATION_TARGET_NODE_IN_SAME_MODULE,
488     /**
489      * There are two 'deviate replace' statements that modify the exact same schema node.
490      */
491     P163_AMBIGUOUS_DEVIATE_REPLACE_OF_SAME_STATEMENT,
492     /**
493      * A statement that has been added previously has now been replaced.
494      */
495     P164_DEVIATE_REPLACE_OF_DEVIATE_ADDED_STATEMENT,
496     /**
497      * A statement that has been modified via a deviation has now also beed deleted.
498      */
499     P165_DEVIATE_DELETE_OF_DEVIATED_STATEMENT,
500     /**
501      * The deviate would result in a statement cardinality validation.
502      */
503     P166_DEVIATE_RESULTS_IN_CHILD_CARDINALITY_VIOLATION,
504     /**
505      * Certain statements cannot be added or deleted, only replaced. This is a hint.
506      */
507     P167_CANNOT_USE_UNDER_DEVIATE_ADD_OR_DELETE
508
509     /*
510      * Values 200+ reserved for downstream tooling, so don't go beyond P199
511      */
512 }