feat: Pruefdialog zeigt konkrete Pruefliste
- ValidationReport/ValidationCheck mit geprueft/bestanden je Kategorie - Dialog nennt Umfang und Pruefliste statt Quellenangabe - Kategorien: Kuerzel, Typ, Level, ChSq-Level, Features, Pflichtfeatures, Level aus Features, Einmal pro Programm - Tooltip am Pruefen-Button nennt den Pruefumfang - 54 Validierungs-Assertions, Whiteboard 237 (896 gesamt) - Doku aktualisiert
This commit is contained in:
parent
b788c1be04
commit
b7dd88c65b
11 changed files with 545 additions and 262 deletions
|
|
@ -66,6 +66,8 @@ Implementiert in `rinkplanner/src/core/rules/`:
|
||||||
| `ElementLevelRules` | saisonale Feature-Sätze, Pflichtfeatures und Level-Berechnung |
|
| `ElementLevelRules` | saisonale Feature-Sätze, Pflichtfeatures und Level-Berechnung |
|
||||||
| `RoutineValidator` | prüft Elementdaten gegen Katalog und Level-Regeln |
|
| `RoutineValidator` | prüft Elementdaten gegen Katalog und Level-Regeln |
|
||||||
| `ValidationIssue` | Befund mit Schweregrad, Meldung und Abschnitts-/Segmentbezug |
|
| `ValidationIssue` | Befund mit Schweregrad, Meldung und Abschnitts-/Segmentbezug |
|
||||||
|
| `ValidationReport` | Befunde, Element-/Abschnittszahl und Prüfstatistik |
|
||||||
|
| `ValidationCheck` | eine Prüfkategorie mit geprüft/bestanden/Befunden |
|
||||||
|
|
||||||
### Entscheidungen
|
### Entscheidungen
|
||||||
|
|
||||||
|
|
@ -133,9 +135,11 @@ spätere Validierung kann Abweichungen melden.
|
||||||
**D10 – Validierung liefert Befunde statt eines Ja/Nein.**
|
**D10 – Validierung liefert Befunde statt eines Ja/Nein.**
|
||||||
`RoutineValidator` prüft Elementdaten gegen Katalog und Level-Regeln und
|
`RoutineValidator` prüft Elementdaten gegen Katalog und Level-Regeln und
|
||||||
liefert `ValidationIssue`-Objekte mit Schweregrad (Fehler/Warnung), Meldung
|
liefert `ValidationIssue`-Objekte mit Schweregrad (Fehler/Warnung), Meldung
|
||||||
und Abschnitts-/Segmentbezug. Die Prüfung ist bewusst getrennt von
|
und Abschnitts-/Segmentbezug. `validate_report()` ergänzt eine Prüfstatistik:
|
||||||
`Routine.validate()`: Das Modell prüft Struktur und Pfade, der Validator
|
Element- und Abschnittszahl sowie pro Kategorie, wie viele Fälle geprüft und
|
||||||
prüft fachliche Elementdaten. Die Oberfläche zeigt die Befunde in einem
|
bestanden wurden. Die Prüfung ist bewusst getrennt von `Routine.validate()`:
|
||||||
|
Das Modell prüft Struktur und Pfade, der Validator prüft fachliche
|
||||||
|
Elementdaten. Die Oberfläche zeigt die Prüfliste und die Befunde in einem
|
||||||
Dialog; sie blockiert Speichern oder Export nicht. Noch nicht abgedeckt sind
|
Dialog; sie blockiert Speichern oder Export nicht. Noch nicht abgedeckt sind
|
||||||
Programmtypen, Elementanzahl, Wiederholungs-/Kombinationsregeln und die
|
Programmtypen, Elementanzahl, Wiederholungs-/Kombinationsregeln und die
|
||||||
Begrenzung auf zwei Features pro Fuß.
|
Begrenzung auf zwei Features pro Fuß.
|
||||||
|
|
@ -192,9 +196,11 @@ Begrenzung auf zwei Features pro Fuß.
|
||||||
Punktmarker ausgeblendet, damit die Leiste auch im Landscape kompakt bleibt.
|
Punktmarker ausgeblendet, damit die Leiste auch im Landscape kompakt bleibt.
|
||||||
- **Prüfung:** Der Button „Prüfen“ in der Statusleiste validiert alle
|
- **Prüfung:** Der Button „Prüfen“ in der Statusleiste validiert alle
|
||||||
Elementsegmente gegen Katalog und Level-Regeln. Der Dialog nennt Saison,
|
Elementsegmente gegen Katalog und Level-Regeln. Der Dialog nennt Saison,
|
||||||
Quelle und Anzahl der geprüften Elemente und listet Fehler und Warnungen
|
Element- und Abschnittszahl und zeigt eine Prüfliste (Kürzel, Elementtyp,
|
||||||
mit Abschnitt und Element; ein leeres Ergebnis wird positiv bestätigt.
|
Level, ChSq-Level, Feature-Auswahl, Pflichtfeatures, Level aus Features,
|
||||||
Speichern und Export bleiben möglich.
|
Einmal pro Programm) mit „bestanden/geprüft“-Zählern. Darunter stehen die
|
||||||
|
Befunde mit Abschnitt und Element; ein leeres Ergebnis wird positiv
|
||||||
|
bestätigt. Speichern und Export bleiben möglich.
|
||||||
- **Section-Verwaltung:** Ein Panel rechts zeigt die chronologische
|
- **Section-Verwaltung:** Ein Panel rechts zeigt die chronologische
|
||||||
Abschnittsliste. Neue Sections werden angelegt, umbenannt, gelöscht und
|
Abschnittsliste. Neue Sections werden angelegt, umbenannt, gelöscht und
|
||||||
hoch-/runtergeschoben; `sequence_order` wird nach jeder Änderung
|
hoch-/runtergeschoben; `sequence_order` wird nach jeder Änderung
|
||||||
|
|
@ -349,9 +355,10 @@ Aktueller Stand:
|
||||||
schwierige Variationen, Level-4-Voraussetzungen, Pflichtfeatures bei
|
schwierige Variationen, Level-4-Voraussetzungen, Pflichtfeatures bei
|
||||||
Schrittsequenzen, feste Level (`ChSq`), Feature-Validierung und die
|
Schrittsequenzen, feste Level (`ChSq`), Feature-Validierung und die
|
||||||
Speicherung am Segment.
|
Speicherung am Segment.
|
||||||
- **Validierung:** 28 Assertions für unbekannte Kürzel, Typ-Mismatches,
|
- **Validierung:** 54 Assertions für unbekannte Kürzel, Typ-Mismatches,
|
||||||
nicht verfügbare Level, Sprung-/ChSq-Sonderfälle, Feature-Fehler,
|
nicht verfügbare Level, Sprung-/ChSq-Sonderfälle, Feature-Fehler,
|
||||||
Pflichtfeatures, Level-Abweichungen und programmweite Einmal-Features.
|
Pflichtfeatures, Level-Abweichungen, programmweite Einmal-Features und die
|
||||||
|
Prüfstatistik je Kategorie.
|
||||||
- **Canvas:** 90 Assertions für Meter→Pixel-Mapping, Fit/Zoom/Pan,
|
- **Canvas:** 90 Assertions für Meter→Pixel-Mapping, Fit/Zoom/Pan,
|
||||||
Rink-Kontur und die reine Bogen-Geometrie.
|
Rink-Kontur und die reine Bogen-Geometrie.
|
||||||
- **Whiteboard:** 237 Assertions für Controller-Verdrahtung, Segmenterzeugung,
|
- **Whiteboard:** 237 Assertions für Controller-Verdrahtung, Segmenterzeugung,
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,13 @@ strukturierte Prüfung der Elementdaten gegen das geladene Regelwerk.
|
||||||
|
|
||||||
| Ziel | Ergebnis |
|
| Ziel | Ergebnis |
|
||||||
| :--- | :--- |
|
| :--- | :--- |
|
||||||
| Prüfmodell | `RoutineValidator` + `ValidationIssue` in `src/core/rules/` |
|
| Prüfmodell | `RoutineValidator`, `ValidationReport`, `ValidationCheck`, `ValidationIssue` |
|
||||||
| Prüfumfang | Kürzel, Typ, Level, Feature-Auswahl, Level-Abgleich, Einmal-Features |
|
| Prüfumfang | Kürzel, Typ, Level, Feature-Auswahl, Level-Abgleich, Einmal-Features |
|
||||||
| Befunde | Schweregrad, deutsche Meldung, Abschnitts- und Segmentbezug |
|
| Befunde | Schweregrad, deutsche Meldung, Abschnitts- und Segmentbezug |
|
||||||
| Oberfläche | Button „Prüfen“ in der Statusleiste, Dialog mit Fehlern/Warnungen |
|
| Oberfläche | Button „Prüfen“ in der Statusleiste, Dialog mit Prüfliste und Befunden |
|
||||||
|
| Prüfstatistik | Je Kategorie geprüft/bestanden plus Element- und Abschnittszahl |
|
||||||
| Verhalten | Prüfung ist nicht blockierend; Speichern und Export bleiben möglich |
|
| Verhalten | Prüfung ist nicht blockierend; Speichern und Export bleiben möglich |
|
||||||
| Tests | 866 Assertions gesamt, `./tools/test.sh` grün (neu: 28 Validierung) |
|
| Tests | 896 Assertions gesamt, `./tools/test.sh` grün (neu: 54 Validierung) |
|
||||||
|
|
||||||
## Entscheidungen
|
## Entscheidungen
|
||||||
|
|
||||||
|
|
@ -54,13 +55,18 @@ strukturierte Prüfung der Elementdaten gegen das geladene Regelwerk.
|
||||||
|
|
||||||
- Der Button **Prüfen** sitzt links neben „Segment löschen“ in der
|
- Der Button **Prüfen** sitzt links neben „Segment löschen“ in der
|
||||||
Statusleiste.
|
Statusleiste.
|
||||||
- Der Dialog `Kür prüfen` nennt zuerst Katalog und Level-Regeln mit Saison und
|
- Der Dialog `Kür prüfen` nennt im Kopf den Umfang: `Geprüft: 4 Elemente in
|
||||||
Quelle, damit klar ist, wogegen geprüft wurde.
|
1 Abschnitt (Saison 2025/26)`.
|
||||||
- Danach folgt eine Zusammenfassung (`n Fehler, m Warnungen · x Elemente
|
- Darunter steht eine Prüfliste mit einer Zeile pro Kategorie:
|
||||||
geprüft`) und darunter die Befunde mit farbigem Punkt, Schweregrad,
|
Kürzel im Katalog, Elementtyp passt, Level gültig, ChSq-Level,
|
||||||
Abschnitt, Element und Meldung.
|
Feature-Auswahl gültig, Pflichtfeatures, Level aus Features und
|
||||||
- Ein leeres Ergebnis wird positiv bestätigt: „Keine Befunde. Alle Elemente
|
Einmal pro Programm. Jede Zeile zeigt `bestanden/geprüft`, Befundzahlen
|
||||||
passen zu Katalog und Level-Regeln.“
|
und ein ✓/✗/–.
|
||||||
|
- Nicht anwendbare Kategorien erscheinen als „nicht geprüft“, z. B. wenn
|
||||||
|
keine Features gesetzt sind oder kein `ChSq` vorkommt.
|
||||||
|
- Danach folgen die Befunde mit farbigem Punkt, Schweregrad, Abschnitt,
|
||||||
|
Element und Meldung.
|
||||||
|
- Ein leeres Ergebnis wird positiv bestätigt: „Keine Befunde.“
|
||||||
- Die Dialoggröße wird auf die Viewport-Größe begrenzt, damit sie auch in
|
- Die Dialoggröße wird auf die Viewport-Größe begrenzt, damit sie auch in
|
||||||
kleinen Fenstern und im Headless-Test positionierbar bleibt.
|
kleinen Fenstern und im Headless-Test positionierbar bleibt.
|
||||||
|
|
||||||
|
|
@ -78,7 +84,7 @@ strukturierte Prüfung der Elementdaten gegen das geladene Regelwerk.
|
||||||
|
|
||||||
## Tests
|
## Tests
|
||||||
|
|
||||||
Neu: `tests/run_validation_tests.gd` (28 Assertions)
|
Neu: `tests/run_validation_tests.gd` (54 Assertions)
|
||||||
|
|
||||||
- saubere Kür ohne Befunde
|
- saubere Kür ohne Befunde
|
||||||
- unbekanntes Kürzel, Typ-Mismatch, nicht verfügbares Level
|
- unbekanntes Kürzel, Typ-Mismatch, nicht verfügbares Level
|
||||||
|
|
@ -88,10 +94,11 @@ Neu: `tests/run_validation_tests.gd` (28 Assertions)
|
||||||
- Level-Abweichung
|
- Level-Abweichung
|
||||||
- programmweites Einmal-Feature mit Verweis auf das erste Segment
|
- programmweites Einmal-Feature mit Verweis auf das erste Segment
|
||||||
- fehlendes Regelwerk
|
- fehlendes Regelwerk
|
||||||
|
- Prüfstatistik je Kategorie (geprüft/bestanden/Befunde, übersprungene Checks)
|
||||||
|
|
||||||
Erweitert: `tests/run_whiteboard_tests.gd` (228 → 237 Assertions) prüft
|
Erweitert: `tests/run_whiteboard_tests.gd` (228 → 237 Assertions) prüft
|
||||||
`validate_routine()`, den Prüfdialog mit Fehlertext, die genannten Quellen
|
`validate_routine()`, den Prüfdialog mit Prüfliste, Umfang und Befunden
|
||||||
und eine saubere Kür.
|
sowie eine saubere Kür.
|
||||||
|
|
||||||
Visuell geprüft über `tests/manual/capture_elements.gd ... validate` bei
|
Visuell geprüft über `tests/manual/capture_elements.gd ... validate` bei
|
||||||
1400 × 876.
|
1400 × 876.
|
||||||
|
|
|
||||||
|
|
@ -170,9 +170,21 @@ Abschnitt und Segment. Geprüft werden:
|
||||||
- Features, die laut Daten nur einmal pro Programm zählen
|
- Features, die laut Daten nur einmal pro Programm zählen
|
||||||
|
|
||||||
Der Button **Prüfen** in der Statusleiste öffnet die Befunde in einem Dialog.
|
Der Button **Prüfen** in der Statusleiste öffnet die Befunde in einem Dialog.
|
||||||
Der Dialog nennt zuerst Katalog und Level-Regeln mit Saison und Quelle sowie
|
Der Kopf nennt den Umfang (`Geprüft: 4 Elemente in 1 Abschnitt (Saison
|
||||||
die Anzahl der geprüften Elemente. Die Prüfung blockiert Speichern und Export
|
2025/26)`), darunter listet die Prüfliste jede Kategorie mit
|
||||||
nicht. Noch nicht geprüft werden
|
`bestanden/geprüft` und Befundzahl:
|
||||||
|
|
||||||
|
- Kürzel im Katalog
|
||||||
|
- Elementtyp passt
|
||||||
|
- Level gültig
|
||||||
|
- ChSq-Level
|
||||||
|
- Feature-Auswahl gültig
|
||||||
|
- Pflichtfeatures
|
||||||
|
- Level aus Features
|
||||||
|
- Einmal pro Programm
|
||||||
|
|
||||||
|
Nicht anwendbare Kategorien erscheinen als „nicht geprüft“. Erst danach folgen
|
||||||
|
die konkreten Befunde. Die Prüfung blockiert Speichern und Export nicht. Noch nicht geprüft werden
|
||||||
Programmtyp, erlaubte Elementanzahl, Wiederholungs- und Kombinationsregeln
|
Programmtyp, erlaubte Elementanzahl, Wiederholungs- und Kombinationsregeln
|
||||||
sowie die Begrenzung auf zwei Features pro Fuß.
|
sowie die Begrenzung auf zwei Features pro Fuß.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,71 +15,78 @@ func _init(catalog: ElementCatalog, rules: ElementLevelRules) -> void:
|
||||||
_rules = rules
|
_rules = rules
|
||||||
|
|
||||||
|
|
||||||
## Returns all findings in section order. An empty array means the element
|
## Returns the findings only. Use [method validate_report] when the UI also
|
||||||
## data is consistent with the loaded rule set.
|
## needs the counts of what was checked.
|
||||||
func validate(routine: Routine) -> Array[ValidationIssue]:
|
func validate(routine: Routine) -> Array[ValidationIssue]:
|
||||||
var issues: Array[ValidationIssue] = []
|
return validate_report(routine).issues
|
||||||
|
|
||||||
|
|
||||||
|
## Returns findings plus the element/section counts and per-check statistics.
|
||||||
|
func validate_report(routine: Routine) -> ValidationReport:
|
||||||
|
var report := ValidationReport.new()
|
||||||
if routine == null:
|
if routine == null:
|
||||||
issues.append(_issue(ValidationIssue.Severity.ERROR, "Keine Kür geladen."))
|
_append(
|
||||||
return issues
|
report,
|
||||||
if _catalog == null or _rules == null:
|
ValidationIssue.Severity.ERROR,
|
||||||
issues.append(
|
"Keine Kür geladen."
|
||||||
_issue(
|
|
||||||
ValidationIssue.Severity.ERROR,
|
|
||||||
"Regelwerk ist nicht geladen; Prüfung nicht möglich."
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
return issues
|
return report
|
||||||
|
if _catalog == null or _rules == null:
|
||||||
|
_append(
|
||||||
|
report,
|
||||||
|
ValidationIssue.Severity.ERROR,
|
||||||
|
"Regelwerk ist nicht geladen; Prüfung nicht möglich."
|
||||||
|
)
|
||||||
|
return report
|
||||||
|
|
||||||
var seen_once: Dictionary[String, String] = {}
|
var seen_once: Dictionary[String, String] = {}
|
||||||
for section: RoutineSection in routine.sections:
|
for section: RoutineSection in routine.sections:
|
||||||
if section == null:
|
if section == null:
|
||||||
continue
|
continue
|
||||||
|
report.section_count += 1
|
||||||
for segment: PathSegment in section.segments:
|
for segment: PathSegment in section.segments:
|
||||||
if segment == null or not segment.is_element():
|
if segment == null or not segment.is_element():
|
||||||
continue
|
continue
|
||||||
_validate_segment(segment, section.section_id, issues)
|
report.element_count += 1
|
||||||
_collect_program_features(
|
_validate_segment(segment, section.section_id, report)
|
||||||
segment,
|
_collect_program_features(segment, section.section_id, seen_once, report)
|
||||||
section.section_id,
|
|
||||||
seen_once,
|
|
||||||
issues
|
|
||||||
)
|
|
||||||
|
|
||||||
return issues
|
return report
|
||||||
|
|
||||||
|
|
||||||
func _validate_segment(
|
func _validate_segment(
|
||||||
segment: PathSegment,
|
segment: PathSegment,
|
||||||
section_id: String,
|
section_id: String,
|
||||||
issues: Array[ValidationIssue]
|
report: ValidationReport
|
||||||
) -> void:
|
) -> void:
|
||||||
var code := segment.element_code.strip_edges()
|
var code := segment.element_code.strip_edges()
|
||||||
if code.is_empty():
|
if code.is_empty():
|
||||||
issues.append(
|
_add(
|
||||||
_issue(
|
report,
|
||||||
ValidationIssue.Severity.WARNING,
|
"code",
|
||||||
"Element ohne Kürzel; Base Value und Level sind nicht prüfbar.",
|
ValidationIssue.Severity.WARNING,
|
||||||
section_id,
|
"Element ohne Kürzel; Base Value und Level sind nicht prüfbar.",
|
||||||
segment.segment_id
|
section_id,
|
||||||
)
|
segment.segment_id
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
var definition := _catalog.find(code)
|
var definition := _catalog.find(code)
|
||||||
if definition == null:
|
if definition == null:
|
||||||
issues.append(
|
_add(
|
||||||
_issue(
|
report,
|
||||||
ValidationIssue.Severity.ERROR,
|
"code",
|
||||||
"Kürzel „%s“ ist nicht im Katalog %s."
|
ValidationIssue.Severity.ERROR,
|
||||||
% [code, _catalog.season],
|
"Kürzel „%s“ ist nicht im Katalog %s." % [code, _catalog.season],
|
||||||
section_id,
|
section_id,
|
||||||
segment.segment_id
|
segment.segment_id
|
||||||
)
|
|
||||||
)
|
)
|
||||||
elif definition.element_type != segment.element_type:
|
else:
|
||||||
issues.append(
|
_pass(report, "code")
|
||||||
_issue(
|
if definition.element_type != segment.element_type:
|
||||||
|
_add(
|
||||||
|
report,
|
||||||
|
"type",
|
||||||
ValidationIssue.Severity.ERROR,
|
ValidationIssue.Severity.ERROR,
|
||||||
"Kürzel „%s“ gehört zu %s, nicht zu %s."
|
"Kürzel „%s“ gehört zu %s, nicht zu %s."
|
||||||
% [
|
% [
|
||||||
|
|
@ -90,23 +97,26 @@ func _validate_segment(
|
||||||
section_id,
|
section_id,
|
||||||
segment.segment_id
|
segment.segment_id
|
||||||
)
|
)
|
||||||
)
|
else:
|
||||||
|
_pass(report, "type")
|
||||||
|
|
||||||
var fixed_level := _rules.get_fixed_level(segment.element_type, code)
|
var fixed_level := _rules.get_fixed_level(segment.element_type, code)
|
||||||
if fixed_level >= 0:
|
if fixed_level >= 0:
|
||||||
if segment.element_level != fixed_level:
|
if segment.element_level == fixed_level:
|
||||||
issues.append(
|
_pass(report, "fixed_level")
|
||||||
_issue(
|
else:
|
||||||
ValidationIssue.Severity.ERROR,
|
_add(
|
||||||
"„%s“ ist fest %s (gewählt: %s)."
|
report,
|
||||||
% [
|
"fixed_level",
|
||||||
code,
|
ValidationIssue.Severity.ERROR,
|
||||||
ElementDefinition.level_label(fixed_level),
|
"„%s“ ist fest %s (gewählt: %s)."
|
||||||
ElementDefinition.level_label(segment.element_level),
|
% [
|
||||||
],
|
code,
|
||||||
section_id,
|
ElementDefinition.level_label(fixed_level),
|
||||||
segment.segment_id
|
ElementDefinition.level_label(segment.element_level),
|
||||||
)
|
],
|
||||||
|
section_id,
|
||||||
|
segment.segment_id
|
||||||
)
|
)
|
||||||
elif (
|
elif (
|
||||||
definition != null
|
definition != null
|
||||||
|
|
@ -114,111 +124,134 @@ func _validate_segment(
|
||||||
):
|
):
|
||||||
if definition.is_leveled():
|
if definition.is_leveled():
|
||||||
if not definition.has_level(segment.element_level):
|
if not definition.has_level(segment.element_level):
|
||||||
issues.append(
|
_add(
|
||||||
_issue(
|
report,
|
||||||
ValidationIssue.Severity.ERROR,
|
"level",
|
||||||
"%s ist für „%s“ nicht verfügbar."
|
ValidationIssue.Severity.ERROR,
|
||||||
% [
|
"%s ist für „%s“ nicht verfügbar."
|
||||||
ElementDefinition.level_label(segment.element_level),
|
% [
|
||||||
code,
|
ElementDefinition.level_label(segment.element_level),
|
||||||
],
|
code,
|
||||||
section_id,
|
],
|
||||||
segment.segment_id
|
|
||||||
)
|
|
||||||
)
|
|
||||||
elif segment.element_level != 0:
|
|
||||||
issues.append(
|
|
||||||
_issue(
|
|
||||||
ValidationIssue.Severity.WARNING,
|
|
||||||
"„%s“ hat Level %d; Sprünge sind nicht levelbar."
|
|
||||||
% [code, segment.element_level],
|
|
||||||
section_id,
|
section_id,
|
||||||
segment.segment_id
|
segment.segment_id
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
_pass(report, "level")
|
||||||
|
elif segment.element_level != 0:
|
||||||
|
_add(
|
||||||
|
report,
|
||||||
|
"level",
|
||||||
|
ValidationIssue.Severity.WARNING,
|
||||||
|
"„%s“ hat Level %d; Sprünge sind nicht levelbar."
|
||||||
|
% [code, segment.element_level],
|
||||||
|
section_id,
|
||||||
|
segment.segment_id
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
_pass(report, "level")
|
||||||
|
|
||||||
_validate_features(segment, code, section_id, issues)
|
_validate_features(segment, code, section_id, report)
|
||||||
|
|
||||||
|
|
||||||
func _validate_features(
|
func _validate_features(
|
||||||
segment: PathSegment,
|
segment: PathSegment,
|
||||||
code: String,
|
code: String,
|
||||||
section_id: String,
|
section_id: String,
|
||||||
issues: Array[ValidationIssue]
|
report: ValidationReport
|
||||||
) -> void:
|
) -> void:
|
||||||
if segment.element_type == PathSegment.ElementType.JUMP:
|
if segment.element_type == PathSegment.ElementType.JUMP:
|
||||||
if not segment.element_features.is_empty():
|
if not segment.element_features.is_empty():
|
||||||
issues.append(
|
_add(
|
||||||
_issue(
|
report,
|
||||||
ValidationIssue.Severity.WARNING,
|
"features",
|
||||||
"„%s“ hat %d Level-Features; Sprünge sind nicht levelbar."
|
ValidationIssue.Severity.WARNING,
|
||||||
% [code, segment.element_features.size()],
|
"„%s“ hat %d Level-Features; Sprünge sind nicht levelbar."
|
||||||
section_id,
|
% [code, segment.element_features.size()],
|
||||||
segment.segment_id
|
section_id,
|
||||||
)
|
segment.segment_id
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
var counts: Dictionary[String, int] = {}
|
|
||||||
for raw: String in segment.element_features:
|
|
||||||
var feature_code := raw.strip_edges()
|
|
||||||
if feature_code.is_empty():
|
|
||||||
issues.append(
|
|
||||||
_issue(
|
|
||||||
ValidationIssue.Severity.ERROR,
|
|
||||||
"Leerer Feature-Code bei „%s“." % code,
|
|
||||||
section_id,
|
|
||||||
segment.segment_id
|
|
||||||
)
|
|
||||||
)
|
|
||||||
continue
|
|
||||||
var feature := _rules.get_feature(segment.element_type, feature_code)
|
|
||||||
if feature == null:
|
|
||||||
issues.append(
|
|
||||||
_issue(
|
|
||||||
ValidationIssue.Severity.ERROR,
|
|
||||||
"Unbekanntes Feature „%s“ für „%s“." % [raw, code],
|
|
||||||
section_id,
|
|
||||||
segment.segment_id
|
|
||||||
)
|
|
||||||
)
|
|
||||||
continue
|
|
||||||
var used: int = counts.get(feature_code, 0)
|
|
||||||
if used >= feature.max_per_element:
|
|
||||||
issues.append(
|
|
||||||
_issue(
|
|
||||||
ValidationIssue.Severity.ERROR,
|
|
||||||
"Feature „%s“ ist bei „%s“ zu oft gewählt (max. %d)."
|
|
||||||
% [feature.display_name, code, feature.max_per_element],
|
|
||||||
section_id,
|
|
||||||
segment.segment_id
|
|
||||||
)
|
|
||||||
)
|
|
||||||
continue
|
|
||||||
counts[feature_code] = used + 1
|
|
||||||
|
|
||||||
if segment.element_features.is_empty():
|
if segment.element_features.is_empty():
|
||||||
return
|
return
|
||||||
|
|
||||||
for required: String in _rules.get_required_features(segment.element_type):
|
var counts: Dictionary[String, int] = {}
|
||||||
if counts.has(required):
|
var feature_failed := false
|
||||||
continue
|
for raw: String in segment.element_features:
|
||||||
var required_feature := _rules.get_feature(
|
var feature_code := raw.strip_edges()
|
||||||
segment.element_type,
|
if feature_code.is_empty():
|
||||||
required
|
_append(
|
||||||
)
|
report,
|
||||||
var required_name := (
|
ValidationIssue.Severity.ERROR,
|
||||||
required_feature.display_name if required_feature != null else required
|
"Leerer Feature-Code bei „%s“." % code,
|
||||||
)
|
|
||||||
issues.append(
|
|
||||||
_issue(
|
|
||||||
ValidationIssue.Severity.WARNING,
|
|
||||||
"Pflichtfeature fehlt bei „%s“: %s."
|
|
||||||
% [code, required_name],
|
|
||||||
section_id,
|
section_id,
|
||||||
segment.segment_id
|
segment.segment_id
|
||||||
)
|
)
|
||||||
)
|
feature_failed = true
|
||||||
|
continue
|
||||||
|
var feature := _rules.get_feature(segment.element_type, feature_code)
|
||||||
|
if feature == null:
|
||||||
|
_append(
|
||||||
|
report,
|
||||||
|
ValidationIssue.Severity.ERROR,
|
||||||
|
"Unbekanntes Feature „%s“ für „%s“." % [raw, code],
|
||||||
|
section_id,
|
||||||
|
segment.segment_id
|
||||||
|
)
|
||||||
|
feature_failed = true
|
||||||
|
continue
|
||||||
|
var used: int = counts.get(feature_code, 0)
|
||||||
|
if used >= feature.max_per_element:
|
||||||
|
_append(
|
||||||
|
report,
|
||||||
|
ValidationIssue.Severity.ERROR,
|
||||||
|
"Feature „%s“ ist bei „%s“ zu oft gewählt (max. %d)."
|
||||||
|
% [feature.display_name, code, feature.max_per_element],
|
||||||
|
section_id,
|
||||||
|
segment.segment_id
|
||||||
|
)
|
||||||
|
feature_failed = true
|
||||||
|
continue
|
||||||
|
counts[feature_code] = used + 1
|
||||||
|
|
||||||
|
if feature_failed:
|
||||||
|
_fail(report, "features", true)
|
||||||
|
else:
|
||||||
|
_pass(report, "features")
|
||||||
|
|
||||||
|
var required: PackedStringArray = _rules.get_required_features(
|
||||||
|
segment.element_type
|
||||||
|
)
|
||||||
|
if not required.is_empty():
|
||||||
|
var missing := PackedStringArray()
|
||||||
|
for required_code: String in required:
|
||||||
|
if counts.has(required_code):
|
||||||
|
continue
|
||||||
|
var required_feature := _rules.get_feature(
|
||||||
|
segment.element_type,
|
||||||
|
required_code
|
||||||
|
)
|
||||||
|
missing.append(
|
||||||
|
required_feature.display_name
|
||||||
|
if required_feature != null
|
||||||
|
else required_code
|
||||||
|
)
|
||||||
|
if missing.is_empty():
|
||||||
|
_pass(report, "required")
|
||||||
|
else:
|
||||||
|
for name: String in missing:
|
||||||
|
_append(
|
||||||
|
report,
|
||||||
|
ValidationIssue.Severity.WARNING,
|
||||||
|
"Pflichtfeature fehlt bei „%s“: %s." % [code, name],
|
||||||
|
section_id,
|
||||||
|
segment.segment_id
|
||||||
|
)
|
||||||
|
_fail(report, "required", false)
|
||||||
|
|
||||||
|
if feature_failed:
|
||||||
|
return
|
||||||
|
|
||||||
var result := _rules.calculate_level(
|
var result := _rules.calculate_level(
|
||||||
segment.element_type,
|
segment.element_type,
|
||||||
|
|
@ -229,20 +262,22 @@ func _validate_features(
|
||||||
return
|
return
|
||||||
if not result.ignored_features.is_empty():
|
if not result.ignored_features.is_empty():
|
||||||
return
|
return
|
||||||
if result.level != segment.element_level:
|
if result.level == segment.element_level:
|
||||||
issues.append(
|
_pass(report, "level_features")
|
||||||
_issue(
|
return
|
||||||
ValidationIssue.Severity.WARNING,
|
_append(
|
||||||
"Features ergeben bei „%s“ %s, gewählt ist %s."
|
report,
|
||||||
% [
|
ValidationIssue.Severity.WARNING,
|
||||||
code,
|
"Features ergeben bei „%s“ %s, gewählt ist %s."
|
||||||
ElementDefinition.level_label(result.level),
|
% [
|
||||||
ElementDefinition.level_label(segment.element_level),
|
code,
|
||||||
],
|
ElementDefinition.level_label(result.level),
|
||||||
section_id,
|
ElementDefinition.level_label(segment.element_level),
|
||||||
segment.segment_id
|
],
|
||||||
)
|
section_id,
|
||||||
)
|
segment.segment_id
|
||||||
|
)
|
||||||
|
_fail(report, "level_features", false)
|
||||||
|
|
||||||
|
|
||||||
## Features marked as once-per-program may only count in the first element
|
## Features marked as once-per-program may only count in the first element
|
||||||
|
|
@ -252,7 +287,7 @@ func _collect_program_features(
|
||||||
segment: PathSegment,
|
segment: PathSegment,
|
||||||
section_id: String,
|
section_id: String,
|
||||||
seen_once: Dictionary[String, String],
|
seen_once: Dictionary[String, String],
|
||||||
issues: Array[ValidationIssue]
|
report: ValidationReport
|
||||||
) -> void:
|
) -> void:
|
||||||
for raw: String in segment.element_features:
|
for raw: String in segment.element_features:
|
||||||
var feature := _rules.get_feature(
|
var feature := _rules.get_feature(
|
||||||
|
|
@ -262,18 +297,19 @@ func _collect_program_features(
|
||||||
if feature == null or not feature.once_per_program:
|
if feature == null or not feature.once_per_program:
|
||||||
continue
|
continue
|
||||||
var key := feature.code.to_lower()
|
var key := feature.code.to_lower()
|
||||||
if seen_once.has(key):
|
if not seen_once.has(key):
|
||||||
issues.append(
|
seen_once[key] = segment.segment_id
|
||||||
_issue(
|
_pass(report, "once")
|
||||||
ValidationIssue.Severity.WARNING,
|
|
||||||
"Feature „%s“ zählt nur einmal pro Programm (zuerst in Segment „%s“)."
|
|
||||||
% [feature.display_name, seen_once[key]],
|
|
||||||
section_id,
|
|
||||||
segment.segment_id
|
|
||||||
)
|
|
||||||
)
|
|
||||||
continue
|
continue
|
||||||
seen_once[key] = segment.segment_id
|
_append(
|
||||||
|
report,
|
||||||
|
ValidationIssue.Severity.WARNING,
|
||||||
|
"Feature „%s“ zählt nur einmal pro Programm (zuerst in Segment „%s“)."
|
||||||
|
% [feature.display_name, seen_once[key]],
|
||||||
|
section_id,
|
||||||
|
segment.segment_id
|
||||||
|
)
|
||||||
|
_fail(report, "once", false)
|
||||||
|
|
||||||
|
|
||||||
static func count_severity(
|
static func count_severity(
|
||||||
|
|
@ -287,10 +323,41 @@ static func count_severity(
|
||||||
return count
|
return count
|
||||||
|
|
||||||
|
|
||||||
func _issue(
|
func _add(
|
||||||
|
report: ValidationReport,
|
||||||
|
check_code: String,
|
||||||
severity: ValidationIssue.Severity,
|
severity: ValidationIssue.Severity,
|
||||||
message: String,
|
message: String,
|
||||||
section_id: String = "",
|
section_id: String = "",
|
||||||
segment_id: String = ""
|
segment_id: String = ""
|
||||||
) -> ValidationIssue:
|
) -> void:
|
||||||
return ValidationIssue.new(severity, message, section_id, segment_id)
|
_append(report, severity, message, section_id, segment_id)
|
||||||
|
_fail(report, check_code, severity == ValidationIssue.Severity.ERROR)
|
||||||
|
|
||||||
|
|
||||||
|
func _append(
|
||||||
|
report: ValidationReport,
|
||||||
|
severity: ValidationIssue.Severity,
|
||||||
|
message: String,
|
||||||
|
section_id: String = "",
|
||||||
|
segment_id: String = ""
|
||||||
|
) -> void:
|
||||||
|
report.issues.append(
|
||||||
|
ValidationIssue.new(severity, message, section_id, segment_id)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
func _pass(report: ValidationReport, check_code: String) -> void:
|
||||||
|
var check := report.get_check(check_code)
|
||||||
|
if check != null:
|
||||||
|
check.pass_check()
|
||||||
|
|
||||||
|
|
||||||
|
func _fail(
|
||||||
|
report: ValidationReport,
|
||||||
|
check_code: String,
|
||||||
|
is_error: bool
|
||||||
|
) -> void:
|
||||||
|
var check := report.get_check(check_code)
|
||||||
|
if check != null:
|
||||||
|
check.fail_check(is_error)
|
||||||
|
|
|
||||||
42
rinkplanner/src/core/rules/validation_check.gd
Normal file
42
rinkplanner/src/core/rules/validation_check.gd
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
class_name ValidationCheck
|
||||||
|
extends RefCounted
|
||||||
|
|
||||||
|
## One category of checks performed by [RoutineValidator]. Counts let the
|
||||||
|
## validation dialog show what was actually checked, not just the findings.
|
||||||
|
|
||||||
|
var code: String = ""
|
||||||
|
var label: String = ""
|
||||||
|
var checked: int = 0
|
||||||
|
var passed: int = 0
|
||||||
|
var findings: int = 0
|
||||||
|
var errors: int = 0
|
||||||
|
var warnings: int = 0
|
||||||
|
|
||||||
|
|
||||||
|
func _init(p_code: String = "", p_label: String = "") -> void:
|
||||||
|
code = p_code
|
||||||
|
label = p_label
|
||||||
|
|
||||||
|
|
||||||
|
func pass_check() -> void:
|
||||||
|
checked += 1
|
||||||
|
passed += 1
|
||||||
|
|
||||||
|
|
||||||
|
func fail_check(is_error: bool) -> void:
|
||||||
|
checked += 1
|
||||||
|
findings += 1
|
||||||
|
if is_error:
|
||||||
|
errors += 1
|
||||||
|
else:
|
||||||
|
warnings += 1
|
||||||
|
|
||||||
|
|
||||||
|
func is_skipped() -> bool:
|
||||||
|
return checked == 0
|
||||||
|
|
||||||
|
|
||||||
|
func summary() -> String:
|
||||||
|
if checked == 0:
|
||||||
|
return "nicht geprüft"
|
||||||
|
return "%d/%d" % [passed, checked]
|
||||||
1
rinkplanner/src/core/rules/validation_check.gd.uid
Normal file
1
rinkplanner/src/core/rules/validation_check.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://dy7kgyonxt8gq
|
||||||
44
rinkplanner/src/core/rules/validation_report.gd
Normal file
44
rinkplanner/src/core/rules/validation_report.gd
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
class_name ValidationReport
|
||||||
|
extends RefCounted
|
||||||
|
|
||||||
|
## Result of [RoutineValidator.validate_report]. Contains the findings, the
|
||||||
|
## element/section counts and one [ValidationCheck] per check category.
|
||||||
|
|
||||||
|
const CHECK_ORDER := [
|
||||||
|
"code",
|
||||||
|
"type",
|
||||||
|
"level",
|
||||||
|
"fixed_level",
|
||||||
|
"features",
|
||||||
|
"required",
|
||||||
|
"level_features",
|
||||||
|
"once",
|
||||||
|
]
|
||||||
|
|
||||||
|
const CHECK_LABELS := {
|
||||||
|
"code": "Kürzel im Katalog",
|
||||||
|
"type": "Elementtyp passt",
|
||||||
|
"level": "Level gültig",
|
||||||
|
"fixed_level": "ChSq-Level",
|
||||||
|
"features": "Feature-Auswahl gültig",
|
||||||
|
"required": "Pflichtfeatures",
|
||||||
|
"level_features": "Level aus Features",
|
||||||
|
"once": "Einmal pro Programm",
|
||||||
|
}
|
||||||
|
|
||||||
|
var issues: Array[ValidationIssue] = []
|
||||||
|
var element_count: int = 0
|
||||||
|
var section_count: int = 0
|
||||||
|
var checks: Array[ValidationCheck] = []
|
||||||
|
|
||||||
|
|
||||||
|
func _init() -> void:
|
||||||
|
for code: String in CHECK_ORDER:
|
||||||
|
checks.append(ValidationCheck.new(code, CHECK_LABELS[code]))
|
||||||
|
|
||||||
|
|
||||||
|
func get_check(code: String) -> ValidationCheck:
|
||||||
|
for check: ValidationCheck in checks:
|
||||||
|
if check.code == code:
|
||||||
|
return check
|
||||||
|
return null
|
||||||
1
rinkplanner/src/core/rules/validation_report.gd.uid
Normal file
1
rinkplanner/src/core/rules/validation_report.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://be37vd2vbcluq
|
||||||
|
|
@ -198,8 +198,8 @@ func _ready() -> void:
|
||||||
"Level rules: %s" % ", ".join(_level_rules.get_errors())
|
"Level rules: %s" % ", ".join(_level_rules.get_errors())
|
||||||
)
|
)
|
||||||
validation_button.tooltip_text = (
|
validation_button.tooltip_text = (
|
||||||
"Prüft gegen Katalog %s und Level-Regeln %s"
|
"Prüft Kürzel, Elementtyp, Level, Features und Einmal-Regeln (Saison %s)"
|
||||||
% [_element_catalog.season, _level_rules.season]
|
% _element_catalog.season
|
||||||
)
|
)
|
||||||
_setup_tool_options()
|
_setup_tool_options()
|
||||||
_setup_file_menu()
|
_setup_file_menu()
|
||||||
|
|
@ -442,59 +442,52 @@ func validate_routine() -> Array[ValidationIssue]:
|
||||||
return validator.validate(_routine)
|
return validator.validate(_routine)
|
||||||
|
|
||||||
|
|
||||||
## Opens the validation dialog with the current findings.
|
## Opens the validation dialog with the current findings and the checks that
|
||||||
|
## were performed.
|
||||||
func open_validation_dialog() -> void:
|
func open_validation_dialog() -> void:
|
||||||
var issues := validate_routine()
|
var validator: RoutineValidator = ROUTINE_VALIDATOR_SCRIPT.new(
|
||||||
|
_element_catalog,
|
||||||
|
_level_rules
|
||||||
|
)
|
||||||
|
var report := validator.validate_report(_routine)
|
||||||
var errors := RoutineValidator.count_severity(
|
var errors := RoutineValidator.count_severity(
|
||||||
issues,
|
report.issues,
|
||||||
ValidationIssue.Severity.ERROR
|
ValidationIssue.Severity.ERROR
|
||||||
)
|
)
|
||||||
var warnings := RoutineValidator.count_severity(
|
var warnings := RoutineValidator.count_severity(
|
||||||
issues,
|
report.issues,
|
||||||
ValidationIssue.Severity.WARNING
|
ValidationIssue.Severity.WARNING
|
||||||
)
|
)
|
||||||
|
var season := (
|
||||||
|
_element_catalog.season if _element_catalog != null else "unbekannt"
|
||||||
|
)
|
||||||
|
|
||||||
var lines := PackedStringArray()
|
var lines := PackedStringArray()
|
||||||
var element_count := _count_elements()
|
lines.append(
|
||||||
if _element_catalog != null:
|
"[b]Geprüft: %s in %s (Saison %s)[/b]"
|
||||||
lines.append(
|
% [
|
||||||
"[b]Katalog %s:[/b] %s"
|
_element_count_label(report.element_count),
|
||||||
% [
|
_section_count_label(report.section_count),
|
||||||
_element_catalog.season,
|
season,
|
||||||
_escape_bbcode(_element_catalog.source),
|
]
|
||||||
]
|
)
|
||||||
)
|
|
||||||
if _level_rules != null:
|
|
||||||
lines.append(
|
|
||||||
"[b]Level-Regeln %s:[/b] %s"
|
|
||||||
% [
|
|
||||||
_level_rules.season,
|
|
||||||
_escape_bbcode(_level_rules.source),
|
|
||||||
]
|
|
||||||
)
|
|
||||||
lines.append("")
|
lines.append("")
|
||||||
|
lines.append("[b]Prüfungen[/b]")
|
||||||
|
for check: ValidationCheck in report.checks:
|
||||||
|
lines.append(_validation_check_line(check))
|
||||||
|
lines.append("")
|
||||||
|
lines.append("[b]Befunde[/b]")
|
||||||
|
|
||||||
if issues.is_empty():
|
if report.issues.is_empty():
|
||||||
if element_count == 0:
|
if report.element_count == 0:
|
||||||
lines.append(
|
lines.append("Keine Elemente vorhanden.")
|
||||||
"[b]Keine Befunde.[/b] Es sind keine Elemente vorhanden."
|
|
||||||
)
|
|
||||||
elif element_count == 1:
|
|
||||||
lines.append(
|
|
||||||
"[b]Keine Befunde.[/b] Das Element passt zu Katalog und Level-Regeln."
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
lines.append(
|
lines.append("Keine Befunde.")
|
||||||
"[b]Keine Befunde.[/b] Alle %d Elemente passen zu Katalog und Level-Regeln."
|
|
||||||
% element_count
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
lines.append(
|
lines.append(
|
||||||
"[b]%d Fehler, %d Warnungen[/b] · %s geprüft"
|
"[b]%d Fehler, %d Warnungen[/b]" % [errors, warnings]
|
||||||
% [errors, warnings, _element_count_label(element_count)]
|
|
||||||
)
|
)
|
||||||
lines.append("")
|
for issue: ValidationIssue in report.issues:
|
||||||
for issue: ValidationIssue in issues:
|
|
||||||
var color := (
|
var color := (
|
||||||
"#ef4444"
|
"#ef4444"
|
||||||
if issue.severity == ValidationIssue.Severity.ERROR
|
if issue.severity == ValidationIssue.Severity.ERROR
|
||||||
|
|
@ -520,23 +513,44 @@ func open_validation_dialog() -> void:
|
||||||
validation_dialog.popup_centered(target)
|
validation_dialog.popup_centered(target)
|
||||||
|
|
||||||
|
|
||||||
func _count_elements() -> int:
|
func _validation_check_line(check: ValidationCheck) -> String:
|
||||||
if _routine == null:
|
var color := "#22c55e"
|
||||||
return 0
|
var icon := "✓"
|
||||||
var count := 0
|
if check.is_skipped():
|
||||||
for section: RoutineSection in _routine.sections:
|
color = "#64748b"
|
||||||
if section == null:
|
icon = "–"
|
||||||
continue
|
elif check.findings > 0:
|
||||||
for segment: PathSegment in section.segments:
|
color = "#ef4444" if check.errors > 0 else "#f59e0b"
|
||||||
if segment != null and segment.is_element():
|
icon = "✗"
|
||||||
count += 1
|
|
||||||
return count
|
var detail := check.summary()
|
||||||
|
var findings := PackedStringArray()
|
||||||
|
if check.errors > 0:
|
||||||
|
findings.append("%d Fehler" % check.errors)
|
||||||
|
if check.warnings > 0:
|
||||||
|
findings.append(
|
||||||
|
"%d Warnung%s"
|
||||||
|
% [check.warnings, "" if check.warnings == 1 else "en"]
|
||||||
|
)
|
||||||
|
if not findings.is_empty():
|
||||||
|
detail += " · " + " · ".join(findings)
|
||||||
|
|
||||||
|
return "[color=%s]%s[/color] %s — %s" % [
|
||||||
|
color,
|
||||||
|
icon,
|
||||||
|
_escape_bbcode(check.label),
|
||||||
|
detail,
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
func _element_count_label(count: int) -> String:
|
func _element_count_label(count: int) -> String:
|
||||||
return "1 Element" if count == 1 else "%d Elemente" % count
|
return "1 Element" if count == 1 else "%d Elemente" % count
|
||||||
|
|
||||||
|
|
||||||
|
func _section_count_label(count: int) -> String:
|
||||||
|
return "1 Abschnitt" if count == 1 else "%d Abschnitten" % count
|
||||||
|
|
||||||
|
|
||||||
func _validation_location(issue: ValidationIssue) -> String:
|
func _validation_location(issue: ValidationIssue) -> String:
|
||||||
var parts := PackedStringArray()
|
var parts := PackedStringArray()
|
||||||
if not issue.section_id.is_empty():
|
if not issue.section_id.is_empty():
|
||||||
|
|
|
||||||
|
|
@ -76,27 +76,58 @@ func _test_clean_routine() -> void:
|
||||||
var issues := _validator.validate(routine)
|
var issues := _validator.validate(routine)
|
||||||
_check(issues.is_empty(), "a consistent routine has no findings (%s)" % _messages(issues))
|
_check(issues.is_empty(), "a consistent routine has no findings (%s)" % _messages(issues))
|
||||||
|
|
||||||
|
var report := _validator.validate_report(routine)
|
||||||
|
_check(report.element_count == 2, "the report counts the elements")
|
||||||
|
_check(report.section_count == 1, "the report counts the sections")
|
||||||
|
_check(report.get_check("code").passed == 2, "both codes were checked")
|
||||||
|
_check(report.get_check("type").passed == 2, "both types were checked")
|
||||||
|
_check(report.get_check("level").passed == 2, "both levels were checked")
|
||||||
|
_check(
|
||||||
|
report.get_check("fixed_level").is_skipped(),
|
||||||
|
"fixed-level check is skipped without ChSq"
|
||||||
|
)
|
||||||
|
_check(report.get_check("features").passed == 2, "both feature sets were checked")
|
||||||
|
_check(
|
||||||
|
report.get_check("required").passed == 1,
|
||||||
|
"the compulsory sequence feature was checked"
|
||||||
|
)
|
||||||
|
_check(report.get_check("level_features").passed == 2, "both derived levels match")
|
||||||
|
_check(report.get_check("once").passed == 6, "once-per-program features were checked")
|
||||||
|
|
||||||
|
|
||||||
func _test_unknown_code() -> void:
|
func _test_unknown_code() -> void:
|
||||||
var issues := _validate_one(
|
var report := _report_one(
|
||||||
PathSegment.ElementType.SPIN,
|
PathSegment.ElementType.SPIN,
|
||||||
"3X",
|
"3X",
|
||||||
0,
|
0,
|
||||||
PackedStringArray()
|
PackedStringArray()
|
||||||
)
|
)
|
||||||
|
var issues := report.issues
|
||||||
_check(_count(issues, ValidationIssueScript.Severity.ERROR) == 1, "unknown code is an error")
|
_check(_count(issues, ValidationIssueScript.Severity.ERROR) == 1, "unknown code is an error")
|
||||||
_check(_has_message(issues, "nicht im Katalog"), "unknown code message")
|
_check(_has_message(issues, "nicht im Katalog"), "unknown code message")
|
||||||
|
_check(report.get_check("code").errors == 1, "the code check records the error")
|
||||||
|
_check(
|
||||||
|
report.get_check("type").is_skipped(),
|
||||||
|
"the type check is skipped without a definition"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
func _test_type_mismatch() -> void:
|
func _test_type_mismatch() -> void:
|
||||||
var issues := _validate_one(
|
var report := _report_one(
|
||||||
PathSegment.ElementType.SPIN,
|
PathSegment.ElementType.SPIN,
|
||||||
"3Lz",
|
"3Lz",
|
||||||
0,
|
0,
|
||||||
PackedStringArray()
|
PackedStringArray()
|
||||||
)
|
)
|
||||||
|
var issues := report.issues
|
||||||
_check(_count(issues, ValidationIssueScript.Severity.ERROR) == 1, "type mismatch is an error")
|
_check(_count(issues, ValidationIssueScript.Severity.ERROR) == 1, "type mismatch is an error")
|
||||||
_check(_has_message(issues, "gehört zu Sprung"), "type mismatch message")
|
_check(_has_message(issues, "gehört zu Sprung"), "type mismatch message")
|
||||||
|
_check(report.get_check("code").passed == 1, "the code itself exists")
|
||||||
|
_check(report.get_check("type").errors == 1, "the type check records the mismatch")
|
||||||
|
_check(
|
||||||
|
report.get_check("level").is_skipped(),
|
||||||
|
"the level check is skipped after a type mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
func _test_unavailable_level() -> void:
|
func _test_unavailable_level() -> void:
|
||||||
|
|
@ -128,7 +159,8 @@ func _test_jump_level_and_features() -> void:
|
||||||
2,
|
2,
|
||||||
PackedStringArray(["difficult_exit"])
|
PackedStringArray(["difficult_exit"])
|
||||||
)
|
)
|
||||||
var issues := _validator.validate(routine)
|
var report := _validator.validate_report(routine)
|
||||||
|
var issues := report.issues
|
||||||
_check(
|
_check(
|
||||||
_count(issues, ValidationIssueScript.Severity.WARNING) == 2,
|
_count(issues, ValidationIssueScript.Severity.WARNING) == 2,
|
||||||
"jump level and features are two warnings"
|
"jump level and features are two warnings"
|
||||||
|
|
@ -136,58 +168,83 @@ func _test_jump_level_and_features() -> void:
|
||||||
_check(_has_message(issues, "nicht levelbar"), "jump level warning")
|
_check(_has_message(issues, "nicht levelbar"), "jump level warning")
|
||||||
_check(_has_message(issues, "Level-Features"), "jump feature warning")
|
_check(_has_message(issues, "Level-Features"), "jump feature warning")
|
||||||
_check(segment.element_level == 2, "the validator does not mutate the segment")
|
_check(segment.element_level == 2, "the validator does not mutate the segment")
|
||||||
|
_check(
|
||||||
|
report.get_check("level").warnings == 1,
|
||||||
|
"the level check records the jump warning"
|
||||||
|
)
|
||||||
|
_check(
|
||||||
|
report.get_check("features").warnings == 1,
|
||||||
|
"the feature check records the jump warning"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
func _test_fixed_level() -> void:
|
func _test_fixed_level() -> void:
|
||||||
var issues := _validate_one(
|
var report := _report_one(
|
||||||
PathSegment.ElementType.SEQUENCE,
|
PathSegment.ElementType.SEQUENCE,
|
||||||
"ChSq",
|
"ChSq",
|
||||||
2,
|
2,
|
||||||
PackedStringArray()
|
PackedStringArray()
|
||||||
)
|
)
|
||||||
|
var issues := report.issues
|
||||||
_check(
|
_check(
|
||||||
_count(issues, ValidationIssueScript.Severity.ERROR) == 1,
|
_count(issues, ValidationIssueScript.Severity.ERROR) == 1,
|
||||||
"a wrong fixed level is an error"
|
"a wrong fixed level is an error"
|
||||||
)
|
)
|
||||||
_check(_has_message(issues, "fest"), "fixed level message")
|
_check(_has_message(issues, "fest"), "fixed level message")
|
||||||
|
_check(report.get_check("fixed_level").errors == 1, "the fixed-level check fails")
|
||||||
|
_check(
|
||||||
|
report.get_check("level").is_skipped(),
|
||||||
|
"the generic level check is skipped for fixed levels"
|
||||||
|
)
|
||||||
|
|
||||||
var valid := _validate_one(
|
var valid := _report_one(
|
||||||
PathSegment.ElementType.SEQUENCE,
|
PathSegment.ElementType.SEQUENCE,
|
||||||
"ChSq",
|
"ChSq",
|
||||||
1,
|
1,
|
||||||
PackedStringArray()
|
PackedStringArray()
|
||||||
)
|
)
|
||||||
_check(valid.is_empty(), "ChSq at Level 1 is valid")
|
_check(valid.issues.is_empty(), "ChSq at Level 1 is valid")
|
||||||
|
_check(valid.get_check("fixed_level").passed == 1, "the fixed-level check passes")
|
||||||
|
|
||||||
|
|
||||||
func _test_missing_code() -> void:
|
func _test_missing_code() -> void:
|
||||||
var issues := _validate_one(
|
var report := _report_one(
|
||||||
PathSegment.ElementType.SPIN,
|
PathSegment.ElementType.SPIN,
|
||||||
"",
|
"",
|
||||||
0,
|
0,
|
||||||
PackedStringArray()
|
PackedStringArray()
|
||||||
)
|
)
|
||||||
|
var issues := report.issues
|
||||||
_check(
|
_check(
|
||||||
_count(issues, ValidationIssueScript.Severity.WARNING) == 1,
|
_count(issues, ValidationIssueScript.Severity.WARNING) == 1,
|
||||||
"a missing code is a warning"
|
"a missing code is a warning"
|
||||||
)
|
)
|
||||||
_check(_has_message(issues, "ohne Kürzel"), "missing code message")
|
_check(_has_message(issues, "ohne Kürzel"), "missing code message")
|
||||||
|
_check(
|
||||||
|
report.get_check("code").warnings == 1,
|
||||||
|
"the code check records the missing code"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
func _test_feature_selection() -> void:
|
func _test_feature_selection() -> void:
|
||||||
var unknown := _validate_one(
|
var unknown_report := _report_one(
|
||||||
PathSegment.ElementType.SPIN,
|
PathSegment.ElementType.SPIN,
|
||||||
"CCoSp",
|
"CCoSp",
|
||||||
0,
|
0,
|
||||||
PackedStringArray(["nope"])
|
PackedStringArray(["nope"])
|
||||||
)
|
)
|
||||||
|
var unknown := unknown_report.issues
|
||||||
_check(
|
_check(
|
||||||
_count(unknown, ValidationIssueScript.Severity.ERROR) == 1,
|
_count(unknown, ValidationIssueScript.Severity.ERROR) == 1,
|
||||||
"an unknown feature is an error"
|
"an unknown feature is an error"
|
||||||
)
|
)
|
||||||
_check(_has_message(unknown, "Unbekanntes Feature"), "unknown feature message")
|
_check(_has_message(unknown, "Unbekanntes Feature"), "unknown feature message")
|
||||||
|
_check(
|
||||||
|
unknown_report.get_check("features").errors == 1,
|
||||||
|
"the feature check records the unknown code"
|
||||||
|
)
|
||||||
|
|
||||||
var too_many := _validate_one(
|
var too_many_report := _report_one(
|
||||||
PathSegment.ElementType.SPIN,
|
PathSegment.ElementType.SPIN,
|
||||||
"CCoSp",
|
"CCoSp",
|
||||||
0,
|
0,
|
||||||
|
|
@ -195,37 +252,52 @@ func _test_feature_selection() -> void:
|
||||||
["difficult_variation", "difficult_variation", "difficult_variation"]
|
["difficult_variation", "difficult_variation", "difficult_variation"]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
var too_many := too_many_report.issues
|
||||||
_check(
|
_check(
|
||||||
_count(too_many, ValidationIssueScript.Severity.ERROR) == 1,
|
_count(too_many, ValidationIssueScript.Severity.ERROR) == 1,
|
||||||
"too many difficult variations is an error"
|
"too many difficult variations is an error"
|
||||||
)
|
)
|
||||||
_check(_has_message(too_many, "zu oft"), "over-limit feature message")
|
_check(_has_message(too_many, "zu oft"), "over-limit feature message")
|
||||||
|
|
||||||
var missing := _validate_one(
|
var missing_report := _report_one(
|
||||||
PathSegment.ElementType.SEQUENCE,
|
PathSegment.ElementType.SEQUENCE,
|
||||||
"StSq",
|
"StSq",
|
||||||
1,
|
1,
|
||||||
PackedStringArray(["body_movements"])
|
PackedStringArray(["body_movements"])
|
||||||
)
|
)
|
||||||
|
var missing := missing_report.issues
|
||||||
_check(
|
_check(
|
||||||
_count(missing, ValidationIssueScript.Severity.WARNING) == 1,
|
_count(missing, ValidationIssueScript.Severity.WARNING) == 1,
|
||||||
"a missing compulsory sequence feature is a warning"
|
"a missing compulsory sequence feature is a warning"
|
||||||
)
|
)
|
||||||
_check(_has_message(missing, "Pflichtfeature fehlt"), "compulsory feature message")
|
_check(_has_message(missing, "Pflichtfeature fehlt"), "compulsory feature message")
|
||||||
|
_check(
|
||||||
|
missing_report.get_check("required").warnings == 1,
|
||||||
|
"the required-feature check records the warning"
|
||||||
|
)
|
||||||
|
_check(
|
||||||
|
missing_report.get_check("level_features").is_skipped(),
|
||||||
|
"the level check is skipped when a required feature is missing"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
func _test_level_mismatch() -> void:
|
func _test_level_mismatch() -> void:
|
||||||
var issues := _validate_one(
|
var report := _report_one(
|
||||||
PathSegment.ElementType.SPIN,
|
PathSegment.ElementType.SPIN,
|
||||||
"CCoSp",
|
"CCoSp",
|
||||||
4,
|
4,
|
||||||
PackedStringArray(["difficult_variation", "difficult_exit"])
|
PackedStringArray(["difficult_variation", "difficult_exit"])
|
||||||
)
|
)
|
||||||
|
var issues := report.issues
|
||||||
_check(
|
_check(
|
||||||
_count(issues, ValidationIssueScript.Severity.WARNING) == 1,
|
_count(issues, ValidationIssueScript.Severity.WARNING) == 1,
|
||||||
"a feature/level mismatch is a warning"
|
"a feature/level mismatch is a warning"
|
||||||
)
|
)
|
||||||
_check(_has_message(issues, "Features ergeben"), "level mismatch message")
|
_check(_has_message(issues, "Features ergeben"), "level mismatch message")
|
||||||
|
_check(
|
||||||
|
report.get_check("level_features").warnings == 1,
|
||||||
|
"the derived-level check records the mismatch"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
func _test_program_once_features() -> void:
|
func _test_program_once_features() -> void:
|
||||||
|
|
@ -247,7 +319,8 @@ func _test_program_once_features() -> void:
|
||||||
1,
|
1,
|
||||||
PackedStringArray(["difficult_exit"])
|
PackedStringArray(["difficult_exit"])
|
||||||
)
|
)
|
||||||
var issues := _validator.validate(routine)
|
var report := _validator.validate_report(routine)
|
||||||
|
var issues := report.issues
|
||||||
_check(
|
_check(
|
||||||
_count(issues, ValidationIssueScript.Severity.WARNING) == 1,
|
_count(issues, ValidationIssueScript.Severity.WARNING) == 1,
|
||||||
"repeated once-per-program features warn once per repeated occurrence"
|
"repeated once-per-program features warn once per repeated occurrence"
|
||||||
|
|
@ -257,6 +330,11 @@ func _test_program_once_features() -> void:
|
||||||
_has_message(issues, "zuerst in Segment „spin-a“"),
|
_has_message(issues, "zuerst in Segment „spin-a“"),
|
||||||
"once-per-program message names the first segment"
|
"once-per-program message names the first segment"
|
||||||
)
|
)
|
||||||
|
_check(
|
||||||
|
report.get_check("once").passed == 1
|
||||||
|
and report.get_check("once").warnings == 1,
|
||||||
|
"the once-per-program check counts both occurrences"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
func _test_missing_rules() -> void:
|
func _test_missing_rules() -> void:
|
||||||
|
|
@ -283,9 +361,18 @@ func _validate_one(
|
||||||
level: int,
|
level: int,
|
||||||
features: PackedStringArray
|
features: PackedStringArray
|
||||||
) -> Array[ValidationIssue]:
|
) -> Array[ValidationIssue]:
|
||||||
|
return _report_one(type, code, level, features).issues
|
||||||
|
|
||||||
|
|
||||||
|
func _report_one(
|
||||||
|
type: PathSegment.ElementType,
|
||||||
|
code: String,
|
||||||
|
level: int,
|
||||||
|
features: PackedStringArray
|
||||||
|
) -> ValidationReport:
|
||||||
var routine := _make_routine()
|
var routine := _make_routine()
|
||||||
_add_marker(routine.sections[0], "segment", type, code, level, features)
|
_add_marker(routine.sections[0], "segment", type, code, level, features)
|
||||||
return _validator.validate(routine)
|
return _validator.validate_report(routine)
|
||||||
|
|
||||||
|
|
||||||
func _make_routine() -> Routine:
|
func _make_routine() -> Routine:
|
||||||
|
|
|
||||||
|
|
@ -1126,18 +1126,18 @@ func _run() -> void:
|
||||||
"validation dialog shows the catalog finding"
|
"validation dialog shows the catalog finding"
|
||||||
)
|
)
|
||||||
_check(
|
_check(
|
||||||
controller.validation_text.text.contains("Katalog 2025/26")
|
controller.validation_text.text.contains("Geprüft: 1 Element in 1 Abschnitt")
|
||||||
and controller.validation_text.text.contains("2707"),
|
and controller.validation_text.text.contains("Saison 2025/26"),
|
||||||
"validation dialog names the catalog and its source"
|
"validation dialog states the scope of the check"
|
||||||
)
|
)
|
||||||
_check(
|
_check(
|
||||||
controller.validation_text.text.contains("Level-Regeln 2025/26")
|
controller.validation_text.text.contains("Kürzel im Katalog")
|
||||||
and controller.validation_text.text.contains("2701"),
|
and controller.validation_text.text.contains("0/1"),
|
||||||
"validation dialog names the level rules and their source"
|
"validation dialog lists the failed check with its count"
|
||||||
)
|
)
|
||||||
_check(
|
_check(
|
||||||
controller.validation_text.text.contains("1 Element geprüft"),
|
controller.validation_text.text.contains("Befunde"),
|
||||||
"validation dialog reports how many elements were checked"
|
"validation dialog separates checks from findings"
|
||||||
)
|
)
|
||||||
controller.validation_dialog.hide()
|
controller.validation_dialog.hide()
|
||||||
|
|
||||||
|
|
@ -1156,8 +1156,9 @@ func _run() -> void:
|
||||||
controller.open_validation_dialog()
|
controller.open_validation_dialog()
|
||||||
_check(
|
_check(
|
||||||
controller.validation_text.text.contains("Keine Befunde")
|
controller.validation_text.text.contains("Keine Befunde")
|
||||||
and controller.validation_text.text.contains("Das Element passt"),
|
and controller.validation_text.text.contains("Kürzel im Katalog")
|
||||||
"clean validation names the rule set and the checked element count"
|
and controller.validation_text.text.contains("1/1"),
|
||||||
|
"clean validation lists the passed checks"
|
||||||
)
|
)
|
||||||
controller.validation_dialog.hide()
|
controller.validation_dialog.hide()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue