Harden diagnostic handling and warning presentation
This commit is contained in:
@@ -45,19 +45,19 @@ func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationReq
|
||||
return contracts.ValidationResult{Approved: true}, nil
|
||||
}
|
||||
|
||||
warnings := make([]diagnostics.Finding, 0)
|
||||
findings := make([]diagnostics.Finding, 0)
|
||||
for index, occurrence := range req.Value.Occurrences {
|
||||
citedText, err := resolver.CitedText(occurrence.SourceRefs)
|
||||
if err != nil || shared.ContainsTokenSequence(citedText, occurrence.Name) {
|
||||
continue
|
||||
}
|
||||
warnings = append(warnings, diagnostics.Finding{
|
||||
findings = append(findings, diagnostics.Finding{
|
||||
Scope: fmt.Sprintf("occurrences[%d]", index),
|
||||
ReasonCode: ReasonCode,
|
||||
Message: fmt.Sprintf("item occurrence name %s was not found in cited source text", diagnostics.Quote(occurrence.Name)),
|
||||
})
|
||||
}
|
||||
return diagnostics.DataQualityResult(warnings)
|
||||
return diagnostics.DataQualityResult(findings)
|
||||
}
|
||||
|
||||
func Spec() pipeline.ValidatorSpec {
|
||||
|
||||
@@ -46,7 +46,7 @@ func TestValidatorDefersMalformedAndUnreadableEvidence(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidatorBoundsWarningsAndRegistersPolicy(t *testing.T) {
|
||||
func TestValidatorBoundsAdvisoriesAndRegistersPolicy(t *testing.T) {
|
||||
count := contracts.MaxDiagnosticSamples + 5
|
||||
occurrences := make([]dnd.ItemOccurrence, count)
|
||||
for index := range occurrences {
|
||||
|
||||
Reference in New Issue
Block a user