diff --git a/.golangci.yaml b/.golangci.yaml index 4325033..70a76c4 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -121,6 +121,7 @@ linters: # Test tables and helpers follow the existing test layout. - path: _test\.go$ linters: + - dupl - paralleltest - lll - wsl_v5 diff --git a/errors.go b/errors.go index 12a1b5c..2717602 100644 --- a/errors.go +++ b/errors.go @@ -2,12 +2,29 @@ package publiccode import ( "cmp" + "context" "encoding/json" "errors" "fmt" "net/url" "slices" "strings" + + "github.com/publiccodeyml/libpubliccode/v5/internal/httpclient" +) + +// Causes of a failed network check. A [ValidationError] that reports an +// unreachable URL, logo or screenshot unwraps to one of them when the check +// failed for a reason that says nothing about the value, so callers can +// tell it apart with errors.Is and try the file again later. +// [ValidationResults] does not unwrap, so check each of its elements. +var ( + // ErrRateLimited means the server kept rate limiting the request, with + // a 429 or a rate limit 403, after the parser's retries. + ErrRateLimited = errors.New("rate limited") + // ErrTimeout means the request did not complete within the parser's + // timeout or the caller's deadline. + ErrTimeout = errors.New("timed out") ) // ParseError is generic parse error. @@ -32,6 +49,9 @@ type ValidationError struct { Description string `json:"description"` Line int `json:"line"` Column int `json:"column"` + + // cause is ErrRateLimited, ErrTimeout or nil. + cause error } func (e ValidationError) Error() string { @@ -43,6 +63,12 @@ func (e ValidationError) Error() string { return fmt.Sprintf("%s:%d:%d: error: %s%s", e.fileName(), e.Line, e.Column, key, e.Description) } +// Unwrap returns [ErrRateLimited] or [ErrTimeout] when e reports a network +// check that failed for that reason, and nil otherwise. +func (e ValidationError) Unwrap() error { + return e.cause +} + func (e ValidationError) MarshalJSON() ([]byte, error) { type Ve ValidationError @@ -72,6 +98,33 @@ func newValidationErrorf(key string, description string, args ...any) Validation return newValidationError(key, fmt.Sprintf(description, args...)) } +// withCause records why the network check behind e failed, when err says +// it was rate limited or timed out. +func (e ValidationError) withCause(err error) ValidationError { + e.cause = networkCause(err) + + return e +} + +func networkCause(err error) error { + if errors.Is(err, httpclient.ErrRateLimited) { + return ErrRateLimited + } + + if errors.Is(err, context.DeadlineExceeded) { + return ErrTimeout + } + + if timeout, ok := errors.AsType[interface { + error + Timeout() bool + }](err); ok && timeout.Timeout() { + return ErrTimeout + } + + return nil +} + // ValidationWarning reports a condition that does not make a publiccode.yml file // invalid, such as use of a deprecated field. It implements error so it can be // returned alongside [ValidationError] values in [ValidationResults]. @@ -162,7 +215,7 @@ func position(err error) (int, int) { // newUnreachableError reports that the URL in key did not answer. err // gives the cause and does not name the URL, so the URL appears once. func newUnreachableError(key string, u *URL, err error) ValidationError { - return newValidationErrorf(key, "'%s' not reachable: %s", (*url.URL)(u).String(), err.Error()) + return newValidationErrorf(key, "'%s' not reachable: %s", (*url.URL)(u).String(), err.Error()).withCause(err) } // newNotImageError reports that the file value in key is not an image. @@ -173,5 +226,5 @@ func newNotImageError(key string, value string, err error) ValidationError { err = dlErr.Err } - return newValidationErrorf(key, "'%s' is not an image: %s", value, err.Error()) + return newValidationErrorf(key, "'%s' is not an image: %s", value, err.Error()).withCause(err) } diff --git a/errors_test.go b/errors_test.go index 1a0ba82..d81c207 100644 --- a/errors_test.go +++ b/errors_test.go @@ -1,11 +1,15 @@ package publiccode import ( + "context" "encoding/json" "errors" "fmt" + "net" "net/url" "testing" + + "github.com/publiccodeyml/libpubliccode/v5/internal/httpclient" ) func TestParseErrorError(t *testing.T) { @@ -181,3 +185,24 @@ func TestValidationResultsHasErrors(t *testing.T) { }) } } + +func TestNetworkCause(t *testing.T) { + for _, tc := range []struct { + name string + err error + want error + }{ + {"rate limited", fmt.Errorf("downloading: %w", httpclient.ErrRateLimited), ErrRateLimited}, + {"deadline", fmt.Errorf("requesting: %w", context.DeadlineExceeded), ErrTimeout}, + {"net timeout", &net.DNSError{Err: "i/o timeout", IsTimeout: true}, ErrTimeout}, + {"not found", fmt.Errorf("downloading: %w", httpclient.ErrNotFound), nil}, + {"refused", &net.OpError{Op: "dial", Err: errors.New("connection refused")}, nil}, + {"nil", nil, nil}, + } { + t.Run(tc.name, func(t *testing.T) { + if got := newValidationError("url", "not reachable").withCause(tc.err).Unwrap(); !errors.Is(got, tc.want) { + t.Errorf("Unwrap() = %v, want %v", got, tc.want) + } + }) + } +} diff --git a/fields.go b/fields.go index 8642538..2cc6473 100644 --- a/fields.go +++ b/fields.go @@ -58,7 +58,7 @@ func validateFieldsV0(publiccode PublicCode, parser *Parser, network bool, baseU if u != nil { validLogo, err := parser.validLogo(*u, network) if !validLogo { - vr = append(vr, newValidationError("logo", err.Error())) + vr = append(vr, newValidationError("logo", err.Error()).withCause(err)) } } } @@ -77,7 +77,7 @@ func validateFieldsV0(publiccode PublicCode, parser *Parser, network bool, baseU if u != nil { validLogo, err := parser.validLogo(*u, network) if !validLogo { - vr = append(vr, newValidationError("monochromeLogo", err.Error())) + vr = append(vr, newValidationError("monochromeLogo", err.Error()).withCause(err)) } } } @@ -384,7 +384,7 @@ func validateFieldsV1(publiccode PublicCode, parser *Parser, network bool, baseU if u != nil { validLogo, err := parser.validLogo(*u, network) if !validLogo { - vr = append(vr, newValidationError("logo", err.Error())) + vr = append(vr, newValidationError("logo", err.Error()).withCause(err)) } } } diff --git a/network_errors_test.go b/network_errors_test.go new file mode 100644 index 0000000..80f8b43 --- /dev/null +++ b/network_errors_test.go @@ -0,0 +1,161 @@ +package publiccode + +import ( + "bytes" + "errors" + "net/http" + "net/http/httptest" + "strings" + "testing" + "time" +) + +func TestFailedNetworkChecksUnwrapToTheirCause(t *testing.T) { + release := make(chan struct{}) + + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case "/rate-limited": + w.Header().Set("Retry-After", "0") + w.WriteHeader(http.StatusTooManyRequests) + case "/stalled": + select { + case <-r.Context().Done(): + case <-release: + } + default: + w.WriteHeader(http.StatusNotFound) + } + })) + t.Cleanup(srv.Close) + t.Cleanup(func() { close(release) }) + + content := validPubliccode(t) + for old, path := range map[string]string{ + `url: "https://github.com/italia/developers.italia.it.git"`: `url: "` + srv.URL + `/repository"`, + `landingURL: "https://developers.italia.it"`: `landingURL: "` + srv.URL + `/rate-limited"`, + `roadmap: "https://designers.italia.it/roadmap/"`: `roadmap: "` + srv.URL + `/stalled"`, + } { + if !bytes.Contains(content, []byte(old)) { + t.Fatalf("fixture has no %s", old) + } + + content = bytes.Replace(content, []byte(old), []byte(path), 1) + } + + content = bytes.Replace(content, + []byte(`documentation: "https://raw.githubusercontent.com/`), + []byte(`documentation: "`+srv.URL+`/missing/`), 1) + + p, err := NewParser(ParserConfig{ + BaseURL: "testdata/v0/valid/", + Timeout: 500 * time.Millisecond, + AllowNetworkToPrivateHosts: true, + }) + if err != nil { + t.Fatal(err) + } + + _, err = p.ParseStream(bytes.NewReader(content)) + + vr, ok := errors.AsType[ValidationResults](err) + if !ok { + t.Fatalf("got %v, want ValidationResults", err) + } + + want := map[string]error{ + "landingURL": ErrRateLimited, + "roadmap": ErrTimeout, + "description.en.documentation": nil, + } + + for key, cause := range want { + found := false + + for _, result := range vr { + valErr, ok := errors.AsType[ValidationError](result) + if !ok || valErr.Key != key || !strings.Contains(valErr.Description, "not reachable") { + continue + } + + found = true + + if got := valErr.Unwrap(); !errors.Is(got, cause) { + t.Errorf("%s: Unwrap() = %v, want %v", key, got, cause) + } + + if cause != nil && !errors.Is(result, cause) { + t.Errorf("%s: errors.Is(%v, %v) = false", key, result, cause) + } + + if errors.Is(result, ErrRateLimited) && !errors.Is(cause, ErrRateLimited) { + t.Errorf("%s: %v matches ErrRateLimited", key, result) + } + } + + if !found { + t.Errorf("no unreachable error for %s in:\n%v", key, vr) + } + } +} + +func TestLogoNetworkChecksUnwrapToTheirCause(t *testing.T) { + release := make(chan struct{}) + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.URL.Path == "/rate-limited.png" { + w.Header().Set("Retry-After", "0") + w.WriteHeader(http.StatusTooManyRequests) + + return + } + select { + case <-r.Context().Done(): + case <-release: + } + })) + t.Cleanup(srv.Close) + t.Cleanup(func() { close(release) }) + + for _, tc := range []struct { + name string + path string + cause error + }{ + {"rate limited", "/rate-limited.png", ErrRateLimited}, + {"timeout", "/stalled.png", ErrTimeout}, + } { + t.Run(tc.name, func(t *testing.T) { + p, err := NewParser(ParserConfig{ + BaseURL: srv.URL + "/", + Timeout: 50 * time.Millisecond, + AllowNetworkToPrivateHosts: true, + }) + if err != nil { + t.Fatal(err) + } + content := "publiccodeYmlVersion: '0.8'\nlogo: " + srv.URL + tc.path + + "\nmonochromeLogo: " + srv.URL + tc.path + "\n" + _, err = p.ParseStream(strings.NewReader(content)) + vr, ok := errors.AsType[ValidationResults](err) + if !ok { + t.Fatalf("got %v, want ValidationResults", err) + } + for _, key := range []string{"logo", "monochromeLogo"} { + found := false + for _, result := range vr { + valErr, ok := errors.AsType[ValidationError](result) + if !ok || valErr.Key != key { + continue + } + found = true + if !errors.Is(result, tc.cause) { + t.Errorf("%s: errors.Is(%v, %v) = false", key, result, tc.cause) + } + } + if !found { + t.Errorf("no validation error for %s in %v", key, vr) + } + } + }) + } +} diff --git a/parser.go b/parser.go index d2afda8..85f4f5d 100644 --- a/parser.go +++ b/parser.go @@ -492,7 +492,7 @@ func (p *Parser) parseAndValidate(in io.Reader, fileURL *url.URL) (PublicCode, e Description: fmt.Sprintf("failed to get raw URL for code repository at %s: %s", publiccode.Url(), err), Line: line, Column: column, - }) + }.withCause(err)) // Return early because proceeding with no base URL would result in a lot // of duplicate errors stemming from its absence. diff --git a/parser_extra_test.go b/parser_extra_test.go index 951e3af..c384869 100644 --- a/parser_extra_test.go +++ b/parser_extra_test.go @@ -283,7 +283,7 @@ func TestParseStreamVersion06(t *testing.T) { t.Fatal("expected a parsed document") } expected := ValidationResults{ - ValidationWarning{"", "publiccodeYmlVersion", "v" + version + " is not the latest version, use '0'. Parsing this file as v0.8.", 1, 1}, + ValidationWarning{Key: "publiccodeYmlVersion", Description: "v" + version + " is not the latest version, use '0'. Parsing this file as v0.8.", Line: 1, Column: 1}, } if !reflect.DeepEqual(err, expected) { t.Fatalf("unexpected diagnostics: got %#v, want %#v", err, expected) diff --git a/parser_internal_test.go b/parser_internal_test.go index d5199c7..7d34bf1 100644 --- a/parser_internal_test.go +++ b/parser_internal_test.go @@ -83,8 +83,8 @@ func TestDecodeReportsEveryUnknownKey(t *testing.T) { legal: {license: MIT, b: 1, a: 2} `, want: ValidationResults{ - ValidationError{"", "legal.b", `unknown field "b"`, 2, 1}, - ValidationError{"", "legal.a", `unknown field "a"`, 2, 1}, + ValidationError{File: "", Key: "legal.b", Description: `unknown field "b"`, Line: 2, Column: 1}, + ValidationError{File: "", Key: "legal.a", Description: `unknown field "a"`, Line: 2, Column: 1}, }, }, "key of an anchor used twice": { @@ -94,7 +94,7 @@ fundedBy: - *org `, want: ValidationResults{ - ValidationError{"", "fundedBy[0].foo", `unknown field "foo"`, 3, 1}, + ValidationError{File: "", Key: "fundedBy[0].foo", Description: `unknown field "foo"`, Line: 3, Column: 1}, }, }, "key brought in by a merge key": { @@ -105,9 +105,9 @@ maintenance: baz: 2 `, want: ValidationResults{ - ValidationError{"", "x", `unknown field "x"`, 2, 1}, - ValidationError{"", "maintenance.bar", `unknown field "bar"`, 2, 1}, - ValidationError{"", "maintenance.baz", `unknown field "baz"`, 5, 1}, + ValidationError{File: "", Key: "x", Description: `unknown field "x"`, Line: 2, Column: 1}, + ValidationError{File: "", Key: "maintenance.bar", Description: `unknown field "bar"`, Line: 2, Column: 1}, + ValidationError{File: "", Key: "maintenance.baz", Description: `unknown field "baz"`, Line: 5, Column: 1}, }, }, "anchor holding an alias of itself": { @@ -116,8 +116,8 @@ fundedBy: &x [*x] foo: 1 `, want: ValidationResults{ - ValidationError{"", "foo", `unknown field "foo"`, 3, 1}, - ValidationError{"", "fundedBy", "wrong type for this field", 2, 1}, + ValidationError{File: "", Key: "foo", Description: `unknown field "foo"`, Line: 3, Column: 1}, + ValidationError{File: "", Key: "fundedBy", Description: "wrong type for this field", Line: 2, Column: 1}, }, }, "mapping merging an alias of itself": { @@ -125,7 +125,7 @@ foo: 1 maintenance: &x {type: internal, foo: 1, <<: *x} `, want: ValidationResults{ - ValidationError{"", "maintenance.foo", `unknown field "foo"`, 2, 1}, + ValidationError{File: "", Key: "maintenance.foo", Description: `unknown field "foo"`, Line: 2, Column: 1}, newValidationError("", "cannot find anchor by alias name x"), }, }, @@ -137,10 +137,10 @@ maintenance: &x {type: internal, foo: 1, <<: *x} !!str 4: 4 `, want: ValidationResults{ - ValidationError{"", "zzTagged", `unknown field "zzTagged"`, 2, 1}, - ValidationError{"", "zzQuoted", `unknown field "zzQuoted"`, 3, 1}, - ValidationError{"", "zzAnchored", `unknown field "zzAnchored"`, 4, 1}, - ValidationError{"", "4", `unknown field "4"`, 5, 1}, + ValidationError{File: "", Key: "zzTagged", Description: `unknown field "zzTagged"`, Line: 2, Column: 1}, + ValidationError{File: "", Key: "zzQuoted", Description: `unknown field "zzQuoted"`, Line: 3, Column: 1}, + ValidationError{File: "", Key: "zzAnchored", Description: `unknown field "zzAnchored"`, Line: 4, Column: 1}, + ValidationError{File: "", Key: "4", Description: `unknown field "4"`, Line: 5, Column: 1}, }, }, "key next to a wrong type": { @@ -149,8 +149,8 @@ name: [a] foo: 1 `, want: ValidationResults{ - ValidationError{"", "foo", `unknown field "foo"`, 3, 1}, - ValidationError{"", "name", "wrong type for this field", 2, 1}, + ValidationError{File: "", Key: "foo", Description: `unknown field "foo"`, Line: 3, Column: 1}, + ValidationError{File: "", Key: "name", Description: "wrong type for this field", Line: 2, Column: 1}, }, }, } diff --git a/v0_test.go b/v0_test.go index 68eb950..a8679e4 100644 --- a/v0_test.go +++ b/v0_test.go @@ -15,8 +15,8 @@ func TestValidTestcasesV0_NoNetwork(t *testing.T) { func TestValidWithWarningTestcasesV0_NoNetwork(t *testing.T) { expected := map[string]error{ "authorsFile.yml": ValidationResults{ - ValidationWarning{"", "legal.authorsFile", "This key is DEPRECATED and will be removed in the future. It's safe to drop it", 63, 3}, - ValidationWarning{"", "IT", "This key is DEPRECATED and will be removed in the future. Migrate its keys as their warnings say, then drop it", 95, 1}, + ValidationWarning{File: "", Key: "legal.authorsFile", Description: "This key is DEPRECATED and will be removed in the future. It's safe to drop it", Line: 63, Column: 3}, + ValidationWarning{File: "", Key: "IT", Description: "This key is DEPRECATED and will be removed in the future. Migrate its keys as their warnings say, then drop it", Line: 95, Column: 1}, }, } @@ -43,53 +43,53 @@ func TestInvalidTestcasesV0_NoNetwork(t *testing.T) { expected := map[string]error{ // logo "logo_missing_file.yml": ValidationResults{ - ValidationError{"", "logo", "no such file: " + cwd + "/testdata/v0/invalid/no-network/no_such_file.png", 18, 1}, + ValidationError{File: "", Key: "logo", Description: "no such file: " + cwd + "/testdata/v0/invalid/no-network/no_such_file.png", Line: 18, Column: 1}, }, "logo_invalid_png.yml": ValidationResults{ - ValidationError{"", "logo", "image: unknown format", 18, 1}, + ValidationError{File: "", Key: "logo", Description: "image: unknown format", Line: 18, Column: 1}, }, // landingURL "landingURL_invalid.yml": ValidationResults{ // Just a syntax check here, no check for reachability as network is disabled - ValidationError{"", "landingURL", "landingURL must be an HTTP URL", 8, 1}, - ValidationWarning{"", "usedBy", "This key is DEPRECATED and will be removed in the future. It's safe to drop it", 21, 1}, - ValidationWarning{"", "description.en.videos", "This key is DEPRECATED and will be removed in the future. Link videos from the documentation or the website instead", 62, 5}, - ValidationWarning{"", "dependsOn.open", "This key is DEPRECATED and will be removed in the future. It's safe to drop it", 102, 3}, - ValidationWarning{"", "IT", "This key is DEPRECATED and will be removed in the future. Migrate its keys as their warnings say, then drop it", 118, 1}, + ValidationError{File: "", Key: "landingURL", Description: "landingURL must be an HTTP URL", Line: 8, Column: 1}, + ValidationWarning{File: "", Key: "usedBy", Description: "This key is DEPRECATED and will be removed in the future. It's safe to drop it", Line: 21, Column: 1}, + ValidationWarning{File: "", Key: "description.en.videos", Description: "This key is DEPRECATED and will be removed in the future. Link videos from the documentation or the website instead", Line: 62, Column: 5}, + ValidationWarning{File: "", Key: "dependsOn.open", Description: "This key is DEPRECATED and will be removed in the future. It's safe to drop it", Line: 102, Column: 3}, + ValidationWarning{File: "", Key: "IT", Description: "This key is DEPRECATED and will be removed in the future. Migrate its keys as their warnings say, then drop it", Line: 118, Column: 1}, }, // monochromeLogo "monochromeLogo_invalid_png.yml": ValidationResults{ - ValidationWarning{"", "monochromeLogo", "This key is DEPRECATED and will be removed in the future. Use 'logo' instead", 18, 1}, - ValidationError{"", "monochromeLogo", "image: unknown format", 18, 1}, + ValidationWarning{File: "", Key: "monochromeLogo", Description: "This key is DEPRECATED and will be removed in the future. Use 'logo' instead", Line: 18, Column: 1}, + ValidationError{File: "", Key: "monochromeLogo", Description: "image: unknown format", Line: 18, Column: 1}, }, // YAML 1.1 boolean aliases must be rejected "localisation_localisationReady_yaml11_yes.yml": ValidationResults{ - ValidationError{"", "localisation.localisationReady", "wrong type for this field", 51, 1}, - ValidationError{"", "localisation.localisationReady", "localisationReady is a required field", 51, 3}, - ValidationError{"", "localisation.availableLanguages", "availableLanguages is a required field", 52, 3}, + ValidationError{File: "", Key: "localisation.localisationReady", Description: "wrong type for this field", Line: 51, Column: 1}, + ValidationError{File: "", Key: "localisation.localisationReady", Description: "localisationReady is a required field", Line: 51, Column: 3}, + ValidationError{File: "", Key: "localisation.availableLanguages", Description: "availableLanguages is a required field", Line: 52, Column: 3}, }, "localisation_localisationReady_yaml11_no.yml": ValidationResults{ - ValidationError{"", "localisation.localisationReady", "wrong type for this field", 51, 1}, - ValidationError{"", "localisation.localisationReady", "localisationReady is a required field", 51, 3}, - ValidationError{"", "localisation.availableLanguages", "availableLanguages is a required field", 52, 3}, + ValidationError{File: "", Key: "localisation.localisationReady", Description: "wrong type for this field", Line: 51, Column: 1}, + ValidationError{File: "", Key: "localisation.localisationReady", Description: "localisationReady is a required field", Line: 51, Column: 3}, + ValidationError{File: "", Key: "localisation.availableLanguages", Description: "availableLanguages is a required field", Line: 52, Column: 3}, }, "localisation_localisationReady_yaml11_on.yml": ValidationResults{ - ValidationError{"", "localisation.localisationReady", "wrong type for this field", 51, 1}, - ValidationError{"", "localisation.localisationReady", "localisationReady is a required field", 51, 3}, - ValidationError{"", "localisation.availableLanguages", "availableLanguages is a required field", 52, 3}, + ValidationError{File: "", Key: "localisation.localisationReady", Description: "wrong type for this field", Line: 51, Column: 1}, + ValidationError{File: "", Key: "localisation.localisationReady", Description: "localisationReady is a required field", Line: 51, Column: 3}, + ValidationError{File: "", Key: "localisation.availableLanguages", Description: "availableLanguages is a required field", Line: 52, Column: 3}, }, "localisation_localisationReady_yaml11_off.yml": ValidationResults{ - ValidationError{"", "localisation.localisationReady", "wrong type for this field", 51, 1}, - ValidationError{"", "localisation.localisationReady", "localisationReady is a required field", 51, 3}, - ValidationError{"", "localisation.availableLanguages", "availableLanguages is a required field", 52, 3}, + ValidationError{File: "", Key: "localisation.localisationReady", Description: "wrong type for this field", Line: 51, Column: 1}, + ValidationError{File: "", Key: "localisation.localisationReady", Description: "localisationReady is a required field", Line: 51, Column: 3}, + ValidationError{File: "", Key: "localisation.availableLanguages", Description: "availableLanguages is a required field", Line: 52, Column: 3}, }, // supports "supports_unknown_alias.yml": ValidationResults{ - ValidationError{"", "supports[0].id", "id contains an unknown alias (see https://github.com/publiccodeyml/publiccode.yml/blob/main/docs/standard/aliases-list.rst)", 17, 5}, + ValidationError{File: "", Key: "supports[0].id", Description: "id contains an unknown alias (see https://github.com/publiccodeyml/publiccode.yml/blob/main/docs/standard/aliases-list.rst)", Line: 17, Column: 5}, }, } @@ -116,544 +116,499 @@ func TestInvalidTestcasesV0_NoNetwork(t *testing.T) { func TestInvalidTestcasesV0(t *testing.T) { expected := map[string]error{ // publiccodeYmlVersion - "publiccodeYmlVersion_missing.yml": ValidationResults{ValidationError{"", "publiccodeYmlVersion", "publiccodeYmlVersion is a required field", 0, 0}}, + "publiccodeYmlVersion_missing.yml": ValidationResults{ValidationError{File: "", Key: "publiccodeYmlVersion", Description: "publiccodeYmlVersion is a required field", Line: 0, Column: 0}}, "publiccodeYmlVersion_invalid.yml": ValidationResults{ - ValidationError{ - "", - "publiccodeYmlVersion", - "unsupported version: '1'. Supported versions: 0, 0.2, 0.2.0, 0.2.1, 0.2.2, 0.3, 0.3.0, 0.4, 0.4.0, 0.5.0, 0.5, 0.6.0, 0.6, 0.7.0, 0.7, 0.8.0, 0.8", - 0, - 0, - }, + ValidationError{File: "", Key: "publiccodeYmlVersion", Description: "unsupported version: '1'. Supported versions: 0, 0.2, 0.2.0, 0.2.1, 0.2.2, 0.3, 0.3.0, 0.4, 0.4.0, 0.5.0, 0.5, 0.6.0, 0.6, 0.7.0, 0.7, 0.8.0, 0.8", Line: 0, Column: 0}, }, "publiccodeYmlVersion_wrong_type.yml": ValidationResults{ - ValidationError{"", "publiccodeYmlVersion", "wrong type for this field", 2, 1}, + ValidationError{File: "", Key: "publiccodeYmlVersion", Description: "wrong type for this field", Line: 2, Column: 1}, }, // name - "name_missing.yml": ValidationResults{ValidationError{"", "name", "name is a required field", 1, 1}}, - "name_nil.yml": ValidationResults{ValidationError{"", "name", "name is a required field", 4, 1}}, + "name_missing.yml": ValidationResults{ValidationError{File: "", Key: "name", Description: "name is a required field", Line: 1, Column: 1}}, + "name_nil.yml": ValidationResults{ValidationError{File: "", Key: "name", Description: "name is a required field", Line: 4, Column: 1}}, "name_wrong_type.yml": ValidationResults{ - ValidationError{"", "name", "wrong type for this field", 4, 1}, - ValidationError{"", "name", "name is a required field", 4, 1}, + ValidationError{File: "", Key: "name", Description: "wrong type for this field", Line: 4, Column: 1}, + ValidationError{File: "", Key: "name", Description: "name is a required field", Line: 4, Column: 1}, }, // applicationSuite - "applicationSuite_wrong_type.yml": ValidationResults{ValidationError{"", "applicationSuite", "wrong type for this field", 4, 1}}, + "applicationSuite_wrong_type.yml": ValidationResults{ValidationError{File: "", Key: "applicationSuite", Description: "wrong type for this field", Line: 4, Column: 1}}, // url - "url_missing.yml": ValidationResults{ValidationError{"", "url", "url is a required field", 1, 1}}, + "url_missing.yml": ValidationResults{ValidationError{File: "", Key: "url", Description: "url is a required field", Line: 1, Column: 1}}, "url_wrong_type.yml": ValidationResults{ - ValidationError{"", "url", "wrong type for this field", 6, 1}, - ValidationError{"", "url", "url is a required field", 6, 1}, + ValidationError{File: "", Key: "url", Description: "wrong type for this field", Line: 6, Column: 1}, + ValidationError{File: "", Key: "url", Description: "url is a required field", Line: 6, Column: 1}, }, "url_invalid.yml": ValidationResults{ - ValidationError{"", "url", "url must be a valid URL", 6, 1}, - ValidationError{"", "url", "'foobar' not reachable: missing URL scheme", 6, 1}, - ValidationError{"", "url", "is not a valid code repository", 6, 1}, + ValidationError{File: "", Key: "url", Description: "url must be a valid URL", Line: 6, Column: 1}, + ValidationError{File: "", Key: "url", Description: "'foobar' not reachable: missing URL scheme", Line: 6, Column: 1}, + ValidationError{File: "", Key: "url", Description: "is not a valid code repository", Line: 6, Column: 1}, }, // landingURL "landingURL_wrong_type.yml": ValidationResults{ - ValidationError{"", "landingURL", "wrong type for this field", 8, 1}, - ValidationWarning{"", "usedBy", "This key is DEPRECATED and will be removed in the future. It's safe to drop it", 21, 1}, - ValidationWarning{"", "dependsOn.open", "This key is DEPRECATED and will be removed in the future. It's safe to drop it", 98, 3}, - ValidationWarning{"", "IT", "This key is DEPRECATED and will be removed in the future. Migrate its keys as their warnings say, then drop it", 114, 1}, + ValidationError{File: "", Key: "landingURL", Description: "wrong type for this field", Line: 8, Column: 1}, + ValidationWarning{File: "", Key: "usedBy", Description: "This key is DEPRECATED and will be removed in the future. It's safe to drop it", Line: 21, Column: 1}, + ValidationWarning{File: "", Key: "dependsOn.open", Description: "This key is DEPRECATED and will be removed in the future. It's safe to drop it", Line: 98, Column: 3}, + ValidationWarning{File: "", Key: "IT", Description: "This key is DEPRECATED and will be removed in the future. Migrate its keys as their warnings say, then drop it", Line: 114, Column: 1}, }, "landingURL_invalid.yml": ValidationResults{ - ValidationError{"", "landingURL", "landingURL must be an HTTP URL", 8, 1}, - ValidationError{"", "landingURL", "'???' not reachable: missing URL scheme", 8, 1}, - ValidationWarning{"", "usedBy", "This key is DEPRECATED and will be removed in the future. It's safe to drop it", 21, 1}, - ValidationWarning{"", "description.en.videos", "This key is DEPRECATED and will be removed in the future. Link videos from the documentation or the website instead", 62, 5}, - ValidationWarning{"", "dependsOn.open", "This key is DEPRECATED and will be removed in the future. It's safe to drop it", 102, 3}, - ValidationWarning{"", "IT", "This key is DEPRECATED and will be removed in the future. Migrate its keys as their warnings say, then drop it", 118, 1}, + ValidationError{File: "", Key: "landingURL", Description: "landingURL must be an HTTP URL", Line: 8, Column: 1}, + ValidationError{File: "", Key: "landingURL", Description: "'???' not reachable: missing URL scheme", Line: 8, Column: 1}, + ValidationWarning{File: "", Key: "usedBy", Description: "This key is DEPRECATED and will be removed in the future. It's safe to drop it", Line: 21, Column: 1}, + ValidationWarning{File: "", Key: "description.en.videos", Description: "This key is DEPRECATED and will be removed in the future. Link videos from the documentation or the website instead", Line: 62, Column: 5}, + ValidationWarning{File: "", Key: "dependsOn.open", Description: "This key is DEPRECATED and will be removed in the future. It's safe to drop it", Line: 102, Column: 3}, + ValidationWarning{File: "", Key: "IT", Description: "This key is DEPRECATED and will be removed in the future. Migrate its keys as their warnings say, then drop it", Line: 118, Column: 1}, }, // isBasedOn "isBasedOn_wrong_type.yml": ValidationResults{ - ValidationError{"", "isBasedOn.foobar", "wrong type for this field", 10, 1}, + ValidationError{File: "", Key: "isBasedOn.foobar", Description: "wrong type for this field", Line: 10, Column: 1}, }, "isBasedOn_bad_url_array.yml": ValidationResults{ - ValidationError{"", "isBasedOn[1]", "isBasedOn[1] must be a valid URL", 11, 5}, + ValidationError{File: "", Key: "isBasedOn[1]", Description: "isBasedOn[1] must be a valid URL", Line: 11, Column: 5}, }, "isBasedOn_bad_url_string.yml": ValidationResults{ - ValidationWarning{"", "isBasedOn", "The single string form is DEPRECATED and will be removed in the future. Use a one element array instead", 9, 1}, - ValidationError{"", "isBasedOn[0]", "isBasedOn[0] must be a valid URL", 9, 1}, + ValidationWarning{File: "", Key: "isBasedOn", Description: "The single string form is DEPRECATED and will be removed in the future. Use a one element array instead", Line: 9, Column: 1}, + ValidationError{File: "", Key: "isBasedOn[0]", Description: "isBasedOn[0] must be a valid URL", Line: 9, Column: 1}, }, // softwareVersion "softwareVersion_wrong_type.yml": ValidationResults{ - ValidationError{"", "softwareVersion", "wrong type for this field", 8, 1}, + ValidationError{File: "", Key: "softwareVersion", Description: "wrong type for this field", Line: 8, Column: 1}, }, // releaseDate - "releaseDate_empty.yml": ValidationResults{ValidationError{"", "releaseDate", "releaseDate must be a date with format 'YYYY-MM-DD'", 8, 1}}, + "releaseDate_empty.yml": ValidationResults{ValidationError{File: "", Key: "releaseDate", Description: "releaseDate must be a date with format 'YYYY-MM-DD'", Line: 8, Column: 1}}, "releaseDate_wrong_type.yml": ValidationResults{ - ValidationError{"", "releaseDate", "wrong type for this field", 8, 1}, + ValidationError{File: "", Key: "releaseDate", Description: "wrong type for this field", Line: 8, Column: 1}, }, "releaseDate_invalid.yml": ValidationResults{ - ValidationError{"", "releaseDate", "releaseDate must be a date with format 'YYYY-MM-DD'", 8, 1}, + ValidationError{File: "", Key: "releaseDate", Description: "releaseDate must be a date with format 'YYYY-MM-DD'", Line: 8, Column: 1}, }, "releaseDate_datetime.yml": ValidationResults{ - ValidationError{"", "releaseDate", "releaseDate must be a date with format 'YYYY-MM-DD'", 8, 1}, + ValidationError{File: "", Key: "releaseDate", Description: "releaseDate must be a date with format 'YYYY-MM-DD'", Line: 8, Column: 1}, }, // logo "logo_wrong_type.yml": ValidationResults{ - ValidationError{"", "logo", "wrong type for this field", 18, 1}, + ValidationError{File: "", Key: "logo", Description: "wrong type for this field", Line: 18, Column: 1}, }, "logo_unsupported_extension.yml": ValidationResults{ - ValidationError{"", "logo", "invalid file extension for: " + cwd + "/testdata/v0/invalid/logo.mpg", 18, 1}, + ValidationError{File: "", Key: "logo", Description: "invalid file extension for: " + cwd + "/testdata/v0/invalid/logo.mpg", Line: 18, Column: 1}, }, "logo_missing_file.yml": ValidationResults{ - ValidationError{"", "logo", "no such file: " + cwd + "/testdata/v0/invalid/no_such_file.png", 18, 1}, + ValidationError{File: "", Key: "logo", Description: "no such file: " + cwd + "/testdata/v0/invalid/no_such_file.png", Line: 18, Column: 1}, }, "logo_absolute_path.yml": ValidationResults{ - ValidationError{"", "logo", "is an absolute path. Only relative paths or HTTP(s) URLs allowed", 18, 1}, + ValidationError{File: "", Key: "logo", Description: "is an absolute path. Only relative paths or HTTP(s) URLs allowed", Line: 18, Column: 1}, }, "logo_outside_repository.yml": ValidationResults{ - ValidationError{"", "logo", "refers to a file outside the repository", 18, 1}, + ValidationError{File: "", Key: "logo", Description: "refers to a file outside the repository", Line: 18, Column: 1}, }, "logo_file_scheme.yml": ValidationResults{ - ValidationError{"", "logo", "is a file:// URL. Only relative paths or HTTP(s) URLs allowed", 18, 1}, + ValidationError{File: "", Key: "logo", Description: "is a file:// URL. Only relative paths or HTTP(s) URLs allowed", Line: 18, Column: 1}, }, "logo_file_scheme2.yml": ValidationResults{ - ValidationError{"", "logo", "is a file:// URL. Only relative paths or HTTP(s) URLs allowed", 18, 1}, + ValidationError{File: "", Key: "logo", Description: "is a file:// URL. Only relative paths or HTTP(s) URLs allowed", Line: 18, Column: 1}, }, "logo_file_scheme3.yml": ValidationResults{ - ValidationError{"", "logo", "is a file:// URL. Only relative paths or HTTP(s) URLs allowed", 18, 1}, + ValidationError{File: "", Key: "logo", Description: "is a file:// URL. Only relative paths or HTTP(s) URLs allowed", Line: 18, Column: 1}, }, "logo_file_scheme_uppercase.yml": ValidationResults{ - ValidationError{"", "logo", "is a file:// URL. Only relative paths or HTTP(s) URLs allowed", 18, 1}, + ValidationError{File: "", Key: "logo", Description: "is a file:// URL. Only relative paths or HTTP(s) URLs allowed", Line: 18, Column: 1}, }, "logo_file_scheme_mixed_case.yml": ValidationResults{ - ValidationError{"", "logo", "is a file:// URL. Only relative paths or HTTP(s) URLs allowed", 18, 1}, + ValidationError{File: "", Key: "logo", Description: "is a file:// URL. Only relative paths or HTTP(s) URLs allowed", Line: 18, Column: 1}, }, "logo_ftp_scheme.yml": ValidationResults{ - ValidationError{"", "logo", "has an unsupported URL scheme 'ftp'. Only relative paths or HTTP(s) URLs allowed", 18, 1}, + ValidationError{File: "", Key: "logo", Description: "has an unsupported URL scheme 'ftp'. Only relative paths or HTTP(s) URLs allowed", Line: 18, Column: 1}, }, "logo_data_scheme.yml": ValidationResults{ - ValidationError{"", "logo", "has an unsupported URL scheme 'data'. Only relative paths or HTTP(s) URLs allowed", 18, 1}, + ValidationError{File: "", Key: "logo", Description: "has an unsupported URL scheme 'data'. Only relative paths or HTTP(s) URLs allowed", Line: 18, Column: 1}, }, // Local publiccode.yml and URL in logo: should look for the logo remotely "logo_missing_url.yml": ValidationResults{ - ValidationError{"", "logo", "downloading https://google.com/no_such_file.png: not found", 18, 1}, + ValidationError{File: "", Key: "logo", Description: "downloading https://google.com/no_such_file.png: not found", Line: 18, Column: 1}, }, // monochromeLogo "monochromeLogo_wrong_type.yml": ValidationResults{ - ValidationError{"", "monochromeLogo", "wrong type for this field", 18, 1}, + ValidationError{File: "", Key: "monochromeLogo", Description: "wrong type for this field", Line: 18, Column: 1}, }, "monochromeLogo_unsupported_extension.yml": ValidationResults{ - ValidationWarning{"", "monochromeLogo", "This key is DEPRECATED and will be removed in the future. Use 'logo' instead", 18, 1}, - ValidationError{ - "", - "monochromeLogo", - "invalid file extension for: " + cwd + "/testdata/v0/invalid/monochromeLogo.mpg", - 18, - 1, - }, + ValidationWarning{File: "", Key: "monochromeLogo", Description: "This key is DEPRECATED and will be removed in the future. Use 'logo' instead", Line: 18, Column: 1}, + ValidationError{File: "", Key: "monochromeLogo", Description: "invalid file extension for: " + cwd + "/testdata/v0/invalid/monochromeLogo.mpg", Line: 18, Column: 1}, }, "monochromeLogo_missing_file.yml": ValidationResults{ - ValidationWarning{"", "monochromeLogo", "This key is DEPRECATED and will be removed in the future. Use 'logo' instead", 18, 1}, - ValidationError{"", "monochromeLogo", "no such file: " + cwd + "/testdata/v0/invalid/no_such_file.png", 18, 1}, + ValidationWarning{File: "", Key: "monochromeLogo", Description: "This key is DEPRECATED and will be removed in the future. Use 'logo' instead", Line: 18, Column: 1}, + ValidationError{File: "", Key: "monochromeLogo", Description: "no such file: " + cwd + "/testdata/v0/invalid/no_such_file.png", Line: 18, Column: 1}, }, "monochromeLogo_outside_repository.yml": ValidationResults{ - ValidationWarning{"", "monochromeLogo", "This key is DEPRECATED and will be removed in the future. Use 'logo' instead", 18, 1}, - ValidationError{"", "monochromeLogo", "refers to a file outside the repository", 18, 1}, + ValidationWarning{File: "", Key: "monochromeLogo", Description: "This key is DEPRECATED and will be removed in the future. Use 'logo' instead", Line: 18, Column: 1}, + ValidationError{File: "", Key: "monochromeLogo", Description: "refers to a file outside the repository", Line: 18, Column: 1}, }, // organisation "organisation_wrong_uri.yml": ValidationResults{ - ValidationError{"", "organisation.uri", "uri is not a valid URI", 19, 3}, + ValidationError{File: "", Key: "organisation.uri", Description: "uri is not a valid URI", Line: 19, Column: 3}, }, "organisation_wrong_type.yml": ValidationResults{ - ValidationError{"", "organisation[0]", "wrong type for this field", 18, 1}, + ValidationError{File: "", Key: "organisation[0]", Description: "wrong type for this field", Line: 18, Column: 1}, }, "organisation_uri_missing.yml": ValidationResults{ - ValidationError{"", "organisation.uri", "uri is a required field", 18, 3}, + ValidationError{File: "", Key: "organisation.uri", Description: "uri is a required field", Line: 18, Column: 3}, }, "organisation_uri_wrong_italian_pa.yml": ValidationResults{ - ValidationError{"", "organisation.uri", "uri is not a valid URI", 20, 3}, + ValidationError{File: "", Key: "organisation.uri", Description: "uri is not a valid URI", Line: 20, Column: 3}, }, "organisation_uri_wrong_italian_pa2.yml": ValidationResults{ - ValidationError{"", "organisation.uri", "uri must be a valid Italian Public Administration Code (iPA) with format 'urn:x-italian-pa:[codiceIPA]' (see https://github.com/publiccodeyml/italian-organizations-ipa-vocabulary)", 19, 3}, + ValidationError{File: "", Key: "organisation.uri", Description: "uri must be a valid Italian Public Administration Code (iPA) with format 'urn:x-italian-pa:[codiceIPA]' (see https://github.com/publiccodeyml/italian-organizations-ipa-vocabulary)", Line: 19, Column: 3}, }, // inputTypes "inputTypes_invalid.yml": ValidationResults{ - ValidationError{"", "inputTypes[1]", "inputTypes[1] is not a valid MIME type", 16, 7}, - ValidationWarning{"", "inputTypes", "This key is DEPRECATED and will be removed in the future. It's safe to drop it", 14, 1}, + ValidationError{File: "", Key: "inputTypes[1]", Description: "inputTypes[1] is not a valid MIME type", Line: 16, Column: 7}, + ValidationWarning{File: "", Key: "inputTypes", Description: "This key is DEPRECATED and will be removed in the future. It's safe to drop it", Line: 14, Column: 1}, }, "inputTypes_wrong_type.yml": ValidationResults{ - ValidationError{"", "inputTypes.foobar", "wrong type for this field", 15, 1}, + ValidationError{File: "", Key: "inputTypes.foobar", Description: "wrong type for this field", Line: 15, Column: 1}, }, // outputTypes "outputTypes_invalid.yml": ValidationResults{ - ValidationError{"", "outputTypes[1]", "outputTypes[1] is not a valid MIME type", 16, 7}, - ValidationWarning{"", "outputTypes", "This key is DEPRECATED and will be removed in the future. It's safe to drop it", 14, 1}, + ValidationError{File: "", Key: "outputTypes[1]", Description: "outputTypes[1] is not a valid MIME type", Line: 16, Column: 7}, + ValidationWarning{File: "", Key: "outputTypes", Description: "This key is DEPRECATED and will be removed in the future. It's safe to drop it", Line: 14, Column: 1}, }, "outputTypes_wrong_type.yml": ValidationResults{ - ValidationError{"", "outputTypes.foobar", "wrong type for this field", 15, 1}, + ValidationError{File: "", Key: "outputTypes.foobar", Description: "wrong type for this field", Line: 15, Column: 1}, }, // platforms - "platforms_missing.yml": ValidationResults{ValidationError{"", "platforms", "platforms must contain more than 0 items", 1, 1}}, + "platforms_missing.yml": ValidationResults{ValidationError{File: "", Key: "platforms", Description: "platforms must contain more than 0 items", Line: 1, Column: 1}}, "platforms_wrong_type.yml": ValidationResults{ - ValidationError{"", "platforms", "wrong type for this field", 9, 1}, - ValidationError{"", "platforms", "platforms must contain more than 0 items", 9, 1}, + ValidationError{File: "", Key: "platforms", Description: "wrong type for this field", Line: 9, Column: 1}, + ValidationError{File: "", Key: "platforms", Description: "platforms must contain more than 0 items", Line: 9, Column: 1}, }, // categories - "categories_invalid.yml": ValidationResults{ValidationError{"", "categories[0]", "categories[0] must be a valid category (see https://github.com/publiccodeyml/publiccode.yml/blob/main/docs/standard/categories-list.rst)", 13, 5}}, + "categories_invalid.yml": ValidationResults{ValidationError{File: "", Key: "categories[0]", Description: "categories[0] must be a valid category (see https://github.com/publiccodeyml/publiccode.yml/blob/main/docs/standard/categories-list.rst)", Line: 13, Column: 5}}, // usedBy "usedBy_wrong_type.yml": ValidationResults{ - ValidationError{"", "usedBy", "wrong type for this field", 14, 1}, + ValidationError{File: "", Key: "usedBy", Description: "wrong type for this field", Line: 14, Column: 1}, }, // fundedBy "fundedBy_wrong_uri.yml": ValidationResults{ - ValidationError{"", "fundedBy[0].uri", "uri is not a valid URI", 19, 5}, + ValidationError{File: "", Key: "fundedBy[0].uri", Description: "uri is not a valid URI", Line: 19, Column: 5}, }, "fundedBy_wrong_type.yml": ValidationResults{ - ValidationError{"", "fundedBy.name", "wrong type for this field", 18, 1}, + ValidationError{File: "", Key: "fundedBy.name", Description: "wrong type for this field", Line: 18, Column: 1}, }, "fundedBy_uri_missing.yml": ValidationResults{ - ValidationError{"", "fundedBy[0].uri", "uri is a required field", 18, 5}, + ValidationError{File: "", Key: "fundedBy[0].uri", Description: "uri is a required field", Line: 18, Column: 5}, }, "fundedBy_uri_wrong_italian_pa.yml": ValidationResults{ - ValidationError{"", "fundedBy[0].uri", "uri is not a valid URI", 20, 5}, + ValidationError{File: "", Key: "fundedBy[0].uri", Description: "uri is not a valid URI", Line: 20, Column: 5}, }, "fundedBy_uri_wrong_italian_pa2.yml": ValidationResults{ - ValidationError{"", "fundedBy[0].uri", "uri must be a valid Italian Public Administration Code (iPA) with format 'urn:x-italian-pa:[codiceIPA]' (see https://github.com/publiccodeyml/italian-organizations-ipa-vocabulary)", 19, 5}, + ValidationError{File: "", Key: "fundedBy[0].uri", Description: "uri must be a valid Italian Public Administration Code (iPA) with format 'urn:x-italian-pa:[codiceIPA]' (see https://github.com/publiccodeyml/italian-organizations-ipa-vocabulary)", Line: 19, Column: 5}, }, // roadmap "roadmap_invalid.yml": ValidationResults{ - ValidationError{"", "roadmap", "roadmap must be an HTTP URL", 4, 1}, - ValidationError{"", "roadmap", "'foobar' not reachable: missing URL scheme", 4, 1}, + ValidationError{File: "", Key: "roadmap", Description: "roadmap must be an HTTP URL", Line: 4, Column: 1}, + ValidationError{File: "", Key: "roadmap", Description: "'foobar' not reachable: missing URL scheme", Line: 4, Column: 1}, }, "roadmap_wrong_type.yml": ValidationResults{ - ValidationError{"", "roadmap", "wrong type for this field", 4, 1}, + ValidationError{File: "", Key: "roadmap", Description: "wrong type for this field", Line: 4, Column: 1}, }, // developmentStatus "developmentStatus_missing.yml": ValidationResults{ - ValidationError{"", "developmentStatus", "developmentStatus is a required field", 1, 1}, + ValidationError{File: "", Key: "developmentStatus", Description: "developmentStatus is a required field", Line: 1, Column: 1}, }, "developmentStatus_invalid.yml": ValidationResults{ - ValidationError{"", "developmentStatus", "developmentStatus must be one of the following: \"concept\", \"development\", \"beta\", \"stable\" or \"obsolete\"", 16, 1}, + ValidationError{File: "", Key: "developmentStatus", Description: "developmentStatus must be one of the following: \"concept\", \"development\", \"beta\", \"stable\" or \"obsolete\"", Line: 16, Column: 1}, }, "developmentStatus_wrong_type.yml": ValidationResults{ - ValidationError{"", "developmentStatus", "wrong type for this field", 16, 1}, - ValidationError{"", "developmentStatus", "developmentStatus is a required field", 16, 1}, + ValidationError{File: "", Key: "developmentStatus", Description: "wrong type for this field", Line: 16, Column: 1}, + ValidationError{File: "", Key: "developmentStatus", Description: "developmentStatus is a required field", Line: 16, Column: 1}, }, // softwareType "softwareType_missing.yml": ValidationResults{ - ValidationError{"", "softwareType", "softwareType is a required field", 1, 1}, + ValidationError{File: "", Key: "softwareType", Description: "softwareType is a required field", Line: 1, Column: 1}, }, "softwareType_invalid.yml": ValidationResults{ - ValidationError{"", "softwareType", "softwareType must be one of the following: \"standalone/mobile\", \"standalone/iot\", \"standalone/desktop\", \"standalone/web\", \"standalone/backend\", \"standalone/other\", \"addon\", \"library\" or \"configurationFiles\"", 17, 1}, + ValidationError{File: "", Key: "softwareType", Description: "softwareType must be one of the following: \"standalone/mobile\", \"standalone/iot\", \"standalone/desktop\", \"standalone/web\", \"standalone/backend\", \"standalone/other\", \"addon\", \"library\" or \"configurationFiles\"", Line: 17, Column: 1}, }, "softwareType_wrong_type.yml": ValidationResults{ - ValidationError{"", "softwareType", "wrong type for this field", 17, 1}, - ValidationError{"", "softwareType", "softwareType is a required field", 17, 1}, + ValidationError{File: "", Key: "softwareType", Description: "wrong type for this field", Line: 17, Column: 1}, + ValidationError{File: "", Key: "softwareType", Description: "softwareType is a required field", Line: 17, Column: 1}, }, // intendedAudience // intendedAudience.* "intendedAudience_wrong_type.yml": ValidationResults{ - ValidationError{"", "intendedAudience", "wrong type for this field", 18, 1}, + ValidationError{File: "", Key: "intendedAudience", Description: "wrong type for this field", Line: 18, Column: 1}, }, "intendedAudience_countries_invalid_country.yml": ValidationResults{ - ValidationError{"", "intendedAudience.countries[2]", "countries[2] must be a valid ISO 3166-1 alpha-2 two-letter country code", 22, 7}, + ValidationError{File: "", Key: "intendedAudience.countries[2]", Description: "countries[2] must be a valid ISO 3166-1 alpha-2 two-letter country code", Line: 22, Column: 7}, }, "intendedAudience_countries_invalid_iso_3166_1_alpha_2.yml": ValidationResults{ - ValidationError{"", "intendedAudience.countries[2]", "countries[2] must be a valid ISO 3166-1 alpha-2 two-letter country code", 22, 7}, + ValidationError{File: "", Key: "intendedAudience.countries[2]", Description: "countries[2] must be a valid ISO 3166-1 alpha-2 two-letter country code", Line: 22, Column: 7}, }, "intendedAudience_countries_wrong_type.yml": ValidationResults{ - ValidationError{"", "intendedAudience.countries", "wrong type for this field", 19, 1}, + ValidationError{File: "", Key: "intendedAudience.countries", Description: "wrong type for this field", Line: 19, Column: 1}, }, "intendedAudience_unsupportedCountries_invalid_country.yml": ValidationResults{ - ValidationError{"", "intendedAudience.unsupportedCountries[0]", "unsupportedCountries[0] must be a valid ISO 3166-1 alpha-2 two-letter country code", 20, 7}, - ValidationWarning{"", "intendedAudience.unsupportedCountries", "This key is DEPRECATED and will be removed in the future. Use 'intendedAudience.countries' to list the targeted countries instead", 18, 3}, + ValidationError{File: "", Key: "intendedAudience.unsupportedCountries[0]", Description: "unsupportedCountries[0] must be a valid ISO 3166-1 alpha-2 two-letter country code", Line: 20, Column: 7}, + ValidationWarning{File: "", Key: "intendedAudience.unsupportedCountries", Description: "This key is DEPRECATED and will be removed in the future. Use 'intendedAudience.countries' to list the targeted countries instead", Line: 18, Column: 3}, }, "intendedAudience_unsupportedCountries_wrong_type.yml": ValidationResults{ - ValidationError{"", "intendedAudience.unsupportedCountries", "wrong type for this field", 19, 1}, + ValidationError{File: "", Key: "intendedAudience.unsupportedCountries", Description: "wrong type for this field", Line: 19, Column: 1}, }, "intendedAudience_scope_invalid_scope.yml": ValidationResults{ - ValidationError{"", "intendedAudience.scope[0]", "scope[0] must be a valid scope (see https://github.com/publiccodeyml/publiccode.yml/blob/main/docs/standard/scope-list.rst)", 20, 9}, + ValidationError{File: "", Key: "intendedAudience.scope[0]", Description: "scope[0] must be a valid scope (see https://github.com/publiccodeyml/publiccode.yml/blob/main/docs/standard/scope-list.rst)", Line: 20, Column: 9}, }, "intendedAudience_scope_wrong_type.yml": ValidationResults{ - ValidationError{"", "intendedAudience.scope", "wrong type for this field", 19, 1}, + ValidationError{File: "", Key: "intendedAudience.scope", Description: "wrong type for this field", Line: 19, Column: 1}, }, // description // description.* "description_invalid_language.yml": ValidationResults{ - ValidationError{"", "description", "description must be a valid BCP 47 language", 18, 1}, + ValidationError{File: "", Key: "description", Description: "description must be a valid BCP 47 language", Line: 18, Column: 1}, }, "description_en_features_empty.yml": ValidationResults{ - ValidationError{"", "description.en.features", "features must contain more than 0 items", 39, 5}, + ValidationError{File: "", Key: "description.en.features", Description: "features must contain more than 0 items", Line: 39, Column: 5}, }, "description_en_localisedName_wrong_type.yml": ValidationResults{ - ValidationError{"", "description.en.localisedName", "wrong type for this field", 21, 1}, - ValidationError{"", "description", "description must contain more than 0 items", 18, 1}, + ValidationError{File: "", Key: "description.en.localisedName", Description: "wrong type for this field", Line: 21, Column: 1}, + ValidationError{File: "", Key: "description", Description: "description must contain more than 0 items", Line: 18, Column: 1}, }, "description_en_genericName_too_long.yml": ValidationResults{ - ValidationError{"", "description.en.genericName", "genericName must be a maximum of 35 characters in length", 22, 5}, - ValidationWarning{"", "description.en.genericName", "This key is DEPRECATED and will be removed in the future. It's safe to drop it", 22, 5}, + ValidationError{File: "", Key: "description.en.genericName", Description: "genericName must be a maximum of 35 characters in length", Line: 22, Column: 5}, + ValidationWarning{File: "", Key: "description.en.genericName", Description: "This key is DEPRECATED and will be removed in the future. It's safe to drop it", Line: 22, Column: 5}, }, "description_en_shortDescription_missing.yml": ValidationResults{ - ValidationError{"", "description.en.shortDescription", "shortDescription is a required field", 20, 5}, + ValidationError{File: "", Key: "description.en.shortDescription", Description: "shortDescription is a required field", Line: 20, Column: 5}, }, "description_en_longDescription_missing.yml": ValidationResults{ - ValidationError{"", "description.en.longDescription", "longDescription is a required field", 20, 5}, + ValidationError{File: "", Key: "description.en.longDescription", Description: "longDescription is a required field", Line: 20, Column: 5}, }, "description_en_longDescription_too_long.yml": ValidationResults{ - ValidationError{"", "description.en.longDescription", "longDescription must be a maximum of 10000 characters in length", 27, 5}, + ValidationError{File: "", Key: "description.en.longDescription", Description: "longDescription must be a maximum of 10000 characters in length", Line: 27, Column: 5}, }, "description_en_longDescription_too_short.yml": ValidationResults{ - ValidationError{"", "description.en.longDescription", "longDescription must be at least 150 characters in length", 27, 5}, + ValidationError{File: "", Key: "description.en.longDescription", Description: "longDescription must be at least 150 characters in length", Line: 27, Column: 5}, }, "description_en_longDescription_too_short_grapheme_clusters.yml": ValidationResults{ - ValidationError{"", "description.en.longDescription", "longDescription must be at least 150 characters in length", 28, 5}, + ValidationError{File: "", Key: "description.en.longDescription", Description: "longDescription must be at least 150 characters in length", Line: 28, Column: 5}, }, "description_en_documentation_invalid.yml": ValidationResults{ - ValidationError{"", "description.en.documentation", "documentation must be an HTTP URL", 25, 5}, - ValidationError{"", "description.en.documentation", "'not_a_url' not reachable: missing URL scheme", 25, 5}, + ValidationError{File: "", Key: "description.en.documentation", Description: "documentation must be an HTTP URL", Line: 25, Column: 5}, + ValidationError{File: "", Key: "description.en.documentation", Description: "'not_a_url' not reachable: missing URL scheme", Line: 25, Column: 5}, }, "description_en_documentation_wrong_type.yml": ValidationResults{ - ValidationError{"", "description.en.documentation", "wrong type for this field", 25, 1}, - ValidationError{"", "description", "description must contain more than 0 items", 20, 1}, + ValidationError{File: "", Key: "description.en.documentation", Description: "wrong type for this field", Line: 25, Column: 1}, + ValidationError{File: "", Key: "description", Description: "description must contain more than 0 items", Line: 20, Column: 1}, }, "description_en_apiDocumentation_invalid.yml": ValidationResults{ - ValidationError{"", "description.en.apiDocumentation", "apiDocumentation must be an HTTP URL", 41, 5}, - ValidationError{"", "description.en.apiDocumentation", "'abc' not reachable: missing URL scheme", 41, 5}, + ValidationError{File: "", Key: "description.en.apiDocumentation", Description: "apiDocumentation must be an HTTP URL", Line: 41, Column: 5}, + ValidationError{File: "", Key: "description.en.apiDocumentation", Description: "'abc' not reachable: missing URL scheme", Line: 41, Column: 5}, }, "description_en_apiDocumentation_wrong_type.yml": ValidationResults{ - ValidationError{"", "description.en.apiDocumentation", "wrong type for this field", 43, 1}, - ValidationError{"", "description", "description must contain more than 0 items", 20, 1}, + ValidationError{File: "", Key: "description.en.apiDocumentation", Description: "wrong type for this field", Line: 43, Column: 1}, + ValidationError{File: "", Key: "description", Description: "description must contain more than 0 items", Line: 20, Column: 1}, }, "description_en_screenshots_missing_file.yml": ValidationResults{ - ValidationError{ - "", - "description.en.screenshots[0]", - "'no_such_file.png' is not an image: no such file: " + cwd + "/testdata/v0/invalid/no_such_file.png", - 42, - 9, - }, + ValidationError{File: "", Key: "description.en.screenshots[0]", Description: "'no_such_file.png' is not an image: no such file: " + cwd + "/testdata/v0/invalid/no_such_file.png", Line: 42, Column: 9}, }, "description_en_screenshots_outside_repository.yml": ValidationResults{ - ValidationError{"", "description.en.screenshots[0]", "refers to a file outside the repository", 42, 9}, + ValidationError{File: "", Key: "description.en.screenshots[0]", Description: "refers to a file outside the repository", Line: 42, Column: 9}, }, "description_en_awards_wrong_type.yml": ValidationResults{ - ValidationError{"", "description.en.awards", "wrong type for this field", 40, 1}, - ValidationError{"", "description", "description must contain more than 0 items", 18, 1}, + ValidationError{File: "", Key: "description.en.awards", Description: "wrong type for this field", Line: 40, Column: 1}, + ValidationError{File: "", Key: "description", Description: "description must contain more than 0 items", Line: 18, Column: 1}, }, "description_en_videos_invalid.yml": ValidationResults{ - ValidationError{"", "description.en.videos[0]", "videos[0] must be an HTTP URL", 41, 9}, - ValidationError{"", "description.en.videos[1]", "videos[1] is a required field", 43, 8}, - ValidationError{"", "description.en.videos[2]", "videos[2] must be an HTTP URL", 45, 9}, - ValidationWarning{"", "description.en.videos", "This key is DEPRECATED and will be removed in the future. Link videos from the documentation or the website instead", 39, 5}, - ValidationError{"", "description.en.videos[0]", "'ABC' is not a valid video URL supporting oEmbed: invalid oEmbed link: ABC", 41, 9}, - ValidationError{"", "description.en.videos[2]", "'' is not a valid video URL supporting oEmbed: invalid oEmbed link: ", 45, 9}, + ValidationError{File: "", Key: "description.en.videos[0]", Description: "videos[0] must be an HTTP URL", Line: 41, Column: 9}, + ValidationError{File: "", Key: "description.en.videos[1]", Description: "videos[1] is a required field", Line: 43, Column: 8}, + ValidationError{File: "", Key: "description.en.videos[2]", Description: "videos[2] must be an HTTP URL", Line: 45, Column: 9}, + ValidationWarning{File: "", Key: "description.en.videos", Description: "This key is DEPRECATED and will be removed in the future. Link videos from the documentation or the website instead", Line: 39, Column: 5}, + ValidationError{File: "", Key: "description.en.videos[0]", Description: "'ABC' is not a valid video URL supporting oEmbed: invalid oEmbed link: ABC", Line: 41, Column: 9}, + ValidationError{File: "", Key: "description.en.videos[2]", Description: "'' is not a valid video URL supporting oEmbed: invalid oEmbed link: ", Line: 45, Column: 9}, }, "description_en_videos_invalid_oembed.yml": ValidationResults{ - ValidationWarning{"", "description.en.videos", "This key is DEPRECATED and will be removed in the future. Link videos from the documentation or the website instead", 39, 5}, - ValidationError{"", "description.en.videos[0]", "'https://google.com' is not a valid video URL supporting oEmbed: invalid oEmbed link: https://google.com", 41, 9}, + ValidationWarning{File: "", Key: "description.en.videos", Description: "This key is DEPRECATED and will be removed in the future. Link videos from the documentation or the website instead", Line: 39, Column: 5}, + ValidationError{File: "", Key: "description.en.videos[0]", Description: "'https://google.com' is not a valid video URL supporting oEmbed: invalid oEmbed link: https://google.com", Line: 41, Column: 9}, }, // legal // legal.* - "legal_missing.yml": ValidationResults{ValidationError{"", "legal.license", "license is a required field", 0, 0}}, + "legal_missing.yml": ValidationResults{ValidationError{File: "", Key: "legal.license", Description: "license is a required field", Line: 0, Column: 0}}, "legal_wrong_type.yml": ValidationResults{ - ValidationError{"", "legal", "wrong type for this field", 46, 1}, - ValidationError{"", "legal.license", "license is a required field", 46, 8}, + ValidationError{File: "", Key: "legal", Description: "wrong type for this field", Line: 46, Column: 1}, + ValidationError{File: "", Key: "legal.license", Description: "license is a required field", Line: 46, Column: 8}, }, - "legal_license_missing.yml": ValidationResults{ValidationError{"", "legal.license", "license is a required field", 41, 3}}, - "legal_license_invalid.yml": ValidationResults{ValidationError{ - "", - "legal.license", "license must be a valid license (see https://spdx.org/licenses)", 42, 3, - }}, + "legal_license_missing.yml": ValidationResults{ValidationError{File: "", Key: "legal.license", Description: "license is a required field", Line: 41, Column: 3}}, + "legal_license_invalid.yml": ValidationResults{ValidationError{File: "", Key: "legal.license", Description: "license must be a valid license (see https://spdx.org/licenses)", Line: 42, Column: 3}}, "legal_authorsFile_missing_file.yml": ValidationResults{ - ValidationWarning{ - "", - "legal.authorsFile", - "This key is DEPRECATED and will be removed in the future. It's safe to drop it", - 42, - 3, - }, - ValidationError{ - "", - "legal.authorsFile", - "'" + cwd + "/testdata/v0/invalid/no_such_authors_file.txt' does not exist: no such file: " + cwd + "/testdata/v0/invalid/no_such_authors_file.txt", - 42, - 3, - }, + ValidationWarning{File: "", Key: "legal.authorsFile", Description: "This key is DEPRECATED and will be removed in the future. It's safe to drop it", Line: 42, Column: 3}, + ValidationError{File: "", Key: "legal.authorsFile", Description: "'" + cwd + "/testdata/v0/invalid/no_such_authors_file.txt' does not exist: no such file: " + cwd + "/testdata/v0/invalid/no_such_authors_file.txt", Line: 42, Column: 3}, }, "legal_authorsFile_file_scheme_uppercase.yml": ValidationResults{ - ValidationWarning{ - "", - "legal.authorsFile", - "This key is DEPRECATED and will be removed in the future. It's safe to drop it", - 42, - 3, - }, - ValidationError{ - "", - "legal.authorsFile", - "is a file:// URL. Only relative paths or HTTP(s) URLs allowed", - 42, - 3, - }, + ValidationWarning{File: "", Key: "legal.authorsFile", Description: "This key is DEPRECATED and will be removed in the future. It's safe to drop it", Line: 42, Column: 3}, + ValidationError{File: "", Key: "legal.authorsFile", Description: "is a file:// URL. Only relative paths or HTTP(s) URLs allowed", Line: 42, Column: 3}, }, // maintenance // maintenance.* "maintenance_type_missing.yml": ValidationResults{ - ValidationError{"", "maintenance.type", "type is a required field", 47, 3}, + ValidationError{File: "", Key: "maintenance.type", Description: "type is a required field", Line: 47, Column: 3}, }, "maintenance_type_invalid.yml": ValidationResults{ - ValidationError{"", "maintenance.type", "type must be one of the following: \"internal\", \"contract\", \"community\" or \"none\"", 45, 3}, + ValidationError{File: "", Key: "maintenance.type", Description: "type must be one of the following: \"internal\", \"contract\", \"community\" or \"none\"", Line: 45, Column: 3}, }, "maintenance_contacts_missing_with_type_community.yml": ValidationResults{ - ValidationError{"", "maintenance.contacts", "contacts is a required field when \"type\" is \"community\"", 44, 3}, + ValidationError{File: "", Key: "maintenance.contacts", Description: "contacts is a required field when \"type\" is \"community\"", Line: 44, Column: 3}, }, "maintenance_contacts_missing_with_type_internal.yml": ValidationResults{ - ValidationError{"", "maintenance.contacts", "contacts is a required field when \"type\" is \"internal\"", 44, 3}, + ValidationError{File: "", Key: "maintenance.contacts", Description: "contacts is a required field when \"type\" is \"internal\"", Line: 44, Column: 3}, }, "maintenance_contacts_name_missing.yml": ValidationResults{ - ValidationError{"", "maintenance.contacts[0].name", "name is a required field", 47, 7}, + ValidationError{File: "", Key: "maintenance.contacts[0].name", Description: "name is a required field", Line: 47, Column: 7}, }, "maintenance_contacts_email_invalid.yml": ValidationResults{ - ValidationError{"", "maintenance.contacts[0].email", "email must be a valid email address", 49, 9}, + ValidationError{File: "", Key: "maintenance.contacts[0].email", Description: "email must be a valid email address", Line: 49, Column: 9}, }, "maintenance_contractors_missing_with_type_contract.yml": ValidationResults{ - ValidationError{"", "maintenance.contractors", "contractors is a required field when \"type\" is \"contract\"", 44, 3}, + ValidationError{File: "", Key: "maintenance.contractors", Description: "contractors is a required field when \"type\" is \"contract\"", Line: 44, Column: 3}, }, "maintenance_contractors_invalid_type.yml": ValidationResults{ - ValidationError{"", "maintenance.contractors", "wrong type for this field", 47, 1}, - ValidationError{"", "maintenance.type", "type is a required field", 44, 3}, + ValidationError{File: "", Key: "maintenance.contractors", Description: "wrong type for this field", Line: 47, Column: 1}, + ValidationError{File: "", Key: "maintenance.type", Description: "type is a required field", Line: 44, Column: 3}, }, "maintenance_contractors_name_missing.yml": ValidationResults{ - ValidationError{"", "maintenance.contractors[0].name", "name is a required field", 47, 7}, + ValidationError{File: "", Key: "maintenance.contractors[0].name", Description: "name is a required field", Line: 47, Column: 7}, }, "maintenance_contractors_until_missing.yml": ValidationResults{ - ValidationError{"", "maintenance.contractors[0].until", "until is a required field", 47, 7}, + ValidationError{File: "", Key: "maintenance.contractors[0].until", Description: "until is a required field", Line: 47, Column: 7}, }, "maintenance_contractors_until_invalid.yml": ValidationResults{ - ValidationError{"", "maintenance.contractors[0].until", "until must be a date with format 'YYYY-MM-DD'", 49, 7}, + ValidationError{File: "", Key: "maintenance.contractors[0].until", Description: "until must be a date with format 'YYYY-MM-DD'", Line: 49, Column: 7}, }, "maintenance_contractors_email_invalid.yml": ValidationResults{ - ValidationError{"", "maintenance.contractors[0].email", "email must be a valid email address", 50, 8}, + ValidationError{File: "", Key: "maintenance.contractors[0].email", Description: "email must be a valid email address", Line: 50, Column: 8}, }, "maintenance_contractors_website_invalid.yml": ValidationResults{ - ValidationError{"", "maintenance.contractors[0].website", "website must be an HTTP URL", 52, 7}, + ValidationError{File: "", Key: "maintenance.contractors[0].website", Description: "website must be an HTTP URL", Line: 52, Column: 7}, }, "maintenance_contractors_when_type_is_community.yml": ValidationResults{ - ValidationError{"", "maintenance.contractors", "contractors must not be present unless \"type\" is \"contract\"", 46, 3}, + ValidationError{File: "", Key: "maintenance.contractors", Description: "contractors must not be present unless \"type\" is \"contract\"", Line: 46, Column: 3}, }, "maintenance_contractors_when_type_is_internal.yml": ValidationResults{ - ValidationError{"", "maintenance.contractors", "contractors must not be present unless \"type\" is \"contract\"", 46, 3}, + ValidationError{File: "", Key: "maintenance.contractors", Description: "contractors must not be present unless \"type\" is \"contract\"", Line: 46, Column: 3}, }, "maintenance_contractors_when_type_is_none.yml": ValidationResults{ - ValidationError{"", "maintenance.contractors", "contractors must not be present unless \"type\" is \"contract\"", 46, 3}, + ValidationError{File: "", Key: "maintenance.contractors", Description: "contractors must not be present unless \"type\" is \"contract\"", Line: 46, Column: 3}, }, // localisation "localisation_availableLanguages_missing.yml": ValidationResults{ - ValidationError{"", "localisation.availableLanguages", "availableLanguages is a required field", 50, 3}, + ValidationError{File: "", Key: "localisation.availableLanguages", Description: "availableLanguages is a required field", Line: 50, Column: 3}, }, "localisation_availableLanguages_empty.yml": ValidationResults{ - ValidationError{"", "localisation.availableLanguages", "availableLanguages must contain more than 0 items", 52, 3}, + ValidationError{File: "", Key: "localisation.availableLanguages", Description: "availableLanguages must contain more than 0 items", Line: 52, Column: 3}, }, "localisation_availableLanguages_invalid.yml": ValidationResults{ - ValidationError{"", "localisation.availableLanguages[0]", "availableLanguages[0] must be a valid BCP 47 language", 53, 8}, + ValidationError{File: "", Key: "localisation.availableLanguages[0]", Description: "availableLanguages[0] must be a valid BCP 47 language", Line: 53, Column: 8}, }, "localisation_localisationReady_missing.yml": ValidationResults{ - ValidationError{"", "localisation.localisationReady", "localisationReady is a required field", 52, 3}, + ValidationError{File: "", Key: "localisation.localisationReady", Description: "localisationReady is a required field", Line: 52, Column: 3}, }, // dependsOn "dependsOn_open_name_wrong_type.yml": ValidationResults{ - ValidationError{"", "dependsOn.open[0]", "wrong type for this field", 56, 1}, + ValidationError{File: "", Key: "dependsOn.open[0]", Description: "wrong type for this field", Line: 56, Column: 1}, }, "dependsOn_open_versionMin_wrong_type.yml": ValidationResults{ - ValidationError{"", "dependsOn.open[0].versionMin", "wrong type for this field", 57, 1}, + ValidationError{File: "", Key: "dependsOn.open[0].versionMin", Description: "wrong type for this field", Line: 57, Column: 1}, }, "dependsOn_open_versionMax_wrong_type.yml": ValidationResults{ - ValidationError{"", "dependsOn.open[0].versionMax", "wrong type for this field", 57, 1}, + ValidationError{File: "", Key: "dependsOn.open[0].versionMax", Description: "wrong type for this field", Line: 57, Column: 1}, }, "dependsOn_open_version_wrong_type.yml": ValidationResults{ - ValidationError{"", "dependsOn.open[0].version", "wrong type for this field", 57, 1}, + ValidationError{File: "", Key: "dependsOn.open[0].version", Description: "wrong type for this field", Line: 57, Column: 1}, }, "dependsOn_open_optional_wrong_type.yml": ValidationResults{ - ValidationError{"", "dependsOn.open[0].optional", "wrong type for this field", 57, 1}, + ValidationError{File: "", Key: "dependsOn.open[0].optional", Description: "wrong type for this field", Line: 57, Column: 1}, }, // it.* "it_countryExtensionVersion_invalid.yml": ValidationResults{ - ValidationError{"", "IT.countryExtensionVersion", "countryExtensionVersion must be one of the following: \"0.2\" or \"1.0\"", 12, 3}, - ValidationWarning{"", "IT", "This key is DEPRECATED and will be removed in the future. Migrate its keys as their warnings say, then drop it", 11, 1}, + ValidationError{File: "", Key: "IT.countryExtensionVersion", Description: "countryExtensionVersion must be one of the following: \"0.2\" or \"1.0\"", Line: 12, Column: 3}, + ValidationWarning{File: "", Key: "IT", Description: "This key is DEPRECATED and will be removed in the future. Migrate its keys as their warnings say, then drop it", Line: 11, Column: 1}, }, "it_riuso_codiceIPA_invalid.yml": ValidationResults{ - ValidationError{"", "IT.riuso.codiceIPA", "codiceIPA must be a valid Italian Public Administration Code (iPA) (see https://github.com/publiccodeyml/italian-organizations-ipa-vocabulary)", 55, 5}, - ValidationWarning{"", "IT", "This key is DEPRECATED and will be removed in the future. Migrate its keys as their warnings say, then drop it", 53, 1}, + ValidationError{File: "", Key: "IT.riuso.codiceIPA", Description: "codiceIPA must be a valid Italian Public Administration Code (iPA) (see https://github.com/publiccodeyml/italian-organizations-ipa-vocabulary)", Line: 55, Column: 5}, + ValidationWarning{File: "", Key: "IT", Description: "This key is DEPRECATED and will be removed in the future. Migrate its keys as their warnings say, then drop it", Line: 53, Column: 1}, }, "it_IT_duplicated.yml": ValidationResults{ - ValidationWarning{"", "usedBy", "This key is DEPRECATED and will be removed in the future. It's safe to drop it", 19, 1}, - ValidationWarning{"", "description.en.videos", "This key is DEPRECATED and will be removed in the future. Link videos from the documentation or the website instead", 60, 5}, - ValidationWarning{"", "dependsOn.open", "This key is DEPRECATED and will be removed in the future. It's safe to drop it", 85, 3}, - ValidationWarning{"", "IT", "This key is DEPRECATED and will be removed in the future. Migrate its keys as their warnings say, then drop it", 105, 1}, - ValidationWarning{"", "it", "This key is DEPRECATED and will be removed in the future. Migrate its keys as their warnings say, then drop it", 114, 1}, - ValidationError{"", "it", "'IT' key already present. Remove this key", 114, 1}, + ValidationWarning{File: "", Key: "usedBy", Description: "This key is DEPRECATED and will be removed in the future. It's safe to drop it", Line: 19, Column: 1}, + ValidationWarning{File: "", Key: "description.en.videos", Description: "This key is DEPRECATED and will be removed in the future. Link videos from the documentation or the website instead", Line: 60, Column: 5}, + ValidationWarning{File: "", Key: "dependsOn.open", Description: "This key is DEPRECATED and will be removed in the future. It's safe to drop it", Line: 85, Column: 3}, + ValidationWarning{File: "", Key: "IT", Description: "This key is DEPRECATED and will be removed in the future. Migrate its keys as their warnings say, then drop it", Line: 105, Column: 1}, + ValidationWarning{File: "", Key: "it", Description: "This key is DEPRECATED and will be removed in the future. Migrate its keys as their warnings say, then drop it", Line: 114, Column: 1}, + ValidationError{File: "", Key: "it", Description: "'IT' key already present. Remove this key", Line: 114, Column: 1}, }, "it_wrong_case.yml": ValidationResults{ - ValidationError{"", "It", "unknown field \"It\"", 105, 1}, - ValidationWarning{"", "usedBy", "This key is DEPRECATED and will be removed in the future. It's safe to drop it", 19, 1}, - ValidationWarning{"", "description.en.videos", "This key is DEPRECATED and will be removed in the future. Link videos from the documentation or the website instead", 60, 5}, - ValidationWarning{"", "dependsOn.open", "This key is DEPRECATED and will be removed in the future. It's safe to drop it", 85, 3}, + ValidationError{File: "", Key: "It", Description: "unknown field \"It\"", Line: 105, Column: 1}, + ValidationWarning{File: "", Key: "usedBy", Description: "This key is DEPRECATED and will be removed in the future. It's safe to drop it", Line: 19, Column: 1}, + ValidationWarning{File: "", Key: "description.en.videos", Description: "This key is DEPRECATED and will be removed in the future. Link videos from the documentation or the website instead", Line: 60, Column: 5}, + ValidationWarning{File: "", Key: "dependsOn.open", Description: "This key is DEPRECATED and will be removed in the future. It's safe to drop it", Line: 85, Column: 3}, }, "description_en_gb_invalid_bcp47.yml": ValidationResults{ - ValidationError{"", "description", "description must be a valid BCP 47 language", 18, 1}, + ValidationError{File: "", Key: "description", Description: "description must be a valid BCP 47 language", Line: 18, Column: 1}, }, "localisation_availableLanguages_invalid_bcp47.yml": ValidationResults{ - ValidationError{"", "localisation.availableLanguages[0]", "availableLanguages[0] must be a valid BCP 47 language", 54, 8}, + ValidationError{File: "", Key: "localisation.availableLanguages[0]", Description: "availableLanguages[0] must be a valid BCP 47 language", Line: 54, Column: 8}, }, // misc "aliases_nested.yml": ValidationResults{ - ValidationError{"", "zl7", "YAML aliases expand to more than 10000 nodes", 61, 16}, + ValidationError{File: "", Key: "zl7", Description: "YAML aliases expand to more than 10000 nodes", Line: 61, Column: 16}, }, - "file_encoding.yml": ValidationResults{ValidationError{"", "", "Invalid UTF-8", 0, 0}}, - "invalid_yaml.yml": ValidationResults{ValidationError{"", "", "value is not allowed in this context. map key-value is pre-defined", 38, 1}}, + "file_encoding.yml": ValidationResults{ValidationError{File: "", Key: "", Description: "Invalid UTF-8", Line: 0, Column: 0}}, + "invalid_yaml.yml": ValidationResults{ValidationError{File: "", Key: "", Description: "value is not allowed in this context. map key-value is pre-defined", Line: 38, Column: 1}}, "mostly_empty.yml": ValidationResults{ - ValidationError{"", "name", "name is a required field", 1, 1}, - ValidationError{"", "url", "url is a required field", 1, 1}, - ValidationError{"", "platforms", "platforms must contain more than 0 items", 1, 1}, - ValidationError{"", "developmentStatus", "developmentStatus is a required field", 1, 1}, - ValidationError{"", "softwareType", "softwareType is a required field", 1, 1}, - ValidationError{"", "description[en-US].shortDescription", "shortDescription is a required field", 3, 10}, - ValidationError{"", "description[en-US].longDescription", "longDescription is a required field", 3, 10}, - ValidationError{"", "localisation.localisationReady", "localisationReady is a required field", 4, 15}, - ValidationError{"", "localisation.availableLanguages", "availableLanguages is a required field", 4, 15}, - ValidationError{"", "legal.license", "license is a required field", 5, 8}, - ValidationError{"", "maintenance.type", "type is a required field", 6, 14}, + ValidationError{File: "", Key: "name", Description: "name is a required field", Line: 1, Column: 1}, + ValidationError{File: "", Key: "url", Description: "url is a required field", Line: 1, Column: 1}, + ValidationError{File: "", Key: "platforms", Description: "platforms must contain more than 0 items", Line: 1, Column: 1}, + ValidationError{File: "", Key: "developmentStatus", Description: "developmentStatus is a required field", Line: 1, Column: 1}, + ValidationError{File: "", Key: "softwareType", Description: "softwareType is a required field", Line: 1, Column: 1}, + ValidationError{File: "", Key: "description[en-US].shortDescription", Description: "shortDescription is a required field", Line: 3, Column: 10}, + ValidationError{File: "", Key: "description[en-US].longDescription", Description: "longDescription is a required field", Line: 3, Column: 10}, + ValidationError{File: "", Key: "localisation.localisationReady", Description: "localisationReady is a required field", Line: 4, Column: 15}, + ValidationError{File: "", Key: "localisation.availableLanguages", Description: "availableLanguages is a required field", Line: 4, Column: 15}, + ValidationError{File: "", Key: "legal.license", Description: "license is a required field", Line: 5, Column: 8}, + ValidationError{File: "", Key: "maintenance.type", Description: "type is a required field", Line: 6, Column: 14}, }, "unknown_field.yml": ValidationResults{ - ValidationError{"", "foobar", "unknown field \"foobar\"", 10, 1}, + ValidationError{File: "", Key: "foobar", Description: "unknown field \"foobar\"", Line: 10, Column: 1}, }, "unknown_fields.yml": ValidationResults{ - ValidationError{"", "zzzTop", "unknown field \"zzzTop\"", 8, 1}, - ValidationError{"", "description.en-GB.zzzDescription", "unknown field \"zzzDescription\"", 23, 1}, - ValidationError{"", "maintenance.contacts[0].zzzContact", "unknown field \"zzzContact\"", 51, 1}, - ValidationError{"", "zzzLast", "unknown field \"zzzLast\"", 58, 1}, - ValidationError{"", "description", "description must contain more than 0 items", 20, 1}, - ValidationError{"", "maintenance.type", "type is a required field", 47, 3}, + ValidationError{File: "", Key: "zzzTop", Description: "unknown field \"zzzTop\"", Line: 8, Column: 1}, + ValidationError{File: "", Key: "description.en-GB.zzzDescription", Description: "unknown field \"zzzDescription\"", Line: 23, Column: 1}, + ValidationError{File: "", Key: "maintenance.contacts[0].zzzContact", Description: "unknown field \"zzzContact\"", Line: 51, Column: 1}, + ValidationError{File: "", Key: "zzzLast", Description: "unknown field \"zzzLast\"", Line: 58, Column: 1}, + ValidationError{File: "", Key: "description", Description: "description must contain more than 0 items", Line: 20, Column: 1}, + ValidationError{File: "", Key: "maintenance.type", Description: "type is a required field", Line: 47, Column: 3}, }, } @@ -685,85 +640,85 @@ func TestValidTestcasesV0(t *testing.T) { func TestValidWithWarningsTestcasesV0(t *testing.T) { expected := map[string]error{ "unicode_grapheme_clusters.yml": ValidationResults{ - ValidationWarning{"", "description.en.genericName", "This key is DEPRECATED and will be removed in the future. It's safe to drop it", 23, 5}, + ValidationWarning{File: "", Key: "description.en.genericName", Description: "This key is DEPRECATED and will be removed in the future. It's safe to drop it", Line: 23, Column: 5}, }, "maintenance_contacts_phone_not_e164.yml": ValidationResults{ - ValidationWarning{"", "maintenance.contacts[0].phone", "Phone numbers SHOULD use the E.164 format, e.g. '+3923113215112'", 46, 7}, + ValidationWarning{File: "", Key: "maintenance.contacts[0].phone", Description: "Phone numbers SHOULD use the E.164 format, e.g. '+3923113215112'", Line: 46, Column: 7}, }, "valid.minimal.v0.2.yml": ValidationResults{ - ValidationWarning{"", "publiccodeYmlVersion", "v0.2 is not the latest version, use '0'. Parsing this file as v0.8.", 1, 1}, + ValidationWarning{File: "", Key: "publiccodeYmlVersion", Description: "v0.2 is not the latest version, use '0'. Parsing this file as v0.8.", Line: 1, Column: 1}, }, "valid.minimal.v0.3.yml": ValidationResults{ - ValidationWarning{"", "publiccodeYmlVersion", "v0.3 is not the latest version, use '0'. Parsing this file as v0.8.", 1, 1}, + ValidationWarning{File: "", Key: "publiccodeYmlVersion", Description: "v0.3 is not the latest version, use '0'. Parsing this file as v0.8.", Line: 1, Column: 1}, }, "valid.minimal.v0.4.yml": ValidationResults{ - ValidationWarning{"", "publiccodeYmlVersion", "v0.4 is not the latest version, use '0'. Parsing this file as v0.8.", 1, 1}, + ValidationWarning{File: "", Key: "publiccodeYmlVersion", Description: "v0.4 is not the latest version, use '0'. Parsing this file as v0.8.", Line: 1, Column: 1}, }, "valid.minimal.v0.7.yml": ValidationResults{ - ValidationWarning{"", "publiccodeYmlVersion", "v0.7 is not the latest version, use '0'. Parsing this file as v0.8.", 1, 1}, + ValidationWarning{File: "", Key: "publiccodeYmlVersion", Description: "v0.7 is not the latest version, use '0'. Parsing this file as v0.8.", Line: 1, Column: 1}, }, "valid.mime_types.yml": ValidationResults{ - ValidationWarning{"", "inputTypes", "This key is DEPRECATED and will be removed in the future. It's safe to drop it", 48, 1}, - ValidationWarning{"", "outputTypes", "This key is DEPRECATED and will be removed in the future. It's safe to drop it", 50, 1}, + ValidationWarning{File: "", Key: "inputTypes", Description: "This key is DEPRECATED and will be removed in the future. It's safe to drop it", Line: 48, Column: 1}, + ValidationWarning{File: "", Key: "outputTypes", Description: "This key is DEPRECATED and will be removed in the future. It's safe to drop it", Line: 50, Column: 1}, }, "valid_with_it_conforme_gdpr.yml": ValidationResults{ - ValidationWarning{"", "IT", "This key is DEPRECATED and will be removed in the future. Migrate its keys as their warnings say, then drop it", 101, 1}, - ValidationWarning{"", "IT.conforme.gdpr", "This key is DEPRECATED and will be removed in the future. Add a 'supports' entry with id 'alias:gdpr' instead", 108, 5}, + ValidationWarning{File: "", Key: "IT", Description: "This key is DEPRECATED and will be removed in the future. Migrate its keys as their warnings say, then drop it", Line: 101, Column: 1}, + ValidationWarning{File: "", Key: "IT.conforme.gdpr", Description: "This key is DEPRECATED and will be removed in the future. Add a 'supports' entry with id 'alias:gdpr' instead", Line: 108, Column: 5}, }, "valid_with_it_conforme.yml": ValidationResults{ - ValidationWarning{"", "IT", "This key is DEPRECATED and will be removed in the future. Migrate its keys as their warnings say, then drop it", 101, 1}, - ValidationWarning{"", "IT.conforme", "This key is DEPRECATED and will be removed in the future. It's safe to drop it", 103, 3}, + ValidationWarning{File: "", Key: "IT", Description: "This key is DEPRECATED and will be removed in the future. Migrate its keys as their warnings say, then drop it", Line: 101, Column: 1}, + ValidationWarning{File: "", Key: "IT.conforme", Description: "This key is DEPRECATED and will be removed in the future. It's safe to drop it", Line: 103, Column: 3}, }, "valid_with_country_specific_section_downcase.yml": ValidationResults{ - ValidationWarning{"", "it", "This key is DEPRECATED and will be removed in the future. Migrate its keys as their warnings say, then drop it", 91, 1}, + ValidationWarning{File: "", Key: "it", Description: "This key is DEPRECATED and will be removed in the future. Migrate its keys as their warnings say, then drop it", Line: 91, Column: 1}, }, "valid_with_lowercase_countries.yml": ValidationResults{ - ValidationWarning{"", "intendedAudience.countries[0]", "Lowercase country codes are DEPRECATED. Use uppercase instead ('IT')", 27, 7}, - ValidationWarning{"", "intendedAudience.countries[1]", "Lowercase country codes are DEPRECATED. Use uppercase instead ('DE')", 28, 7}, - ValidationWarning{"", "intendedAudience.unsupportedCountries", "This key is DEPRECATED and will be removed in the future. Use 'intendedAudience.countries' to list the targeted countries instead", 29, 3}, - ValidationWarning{"", "intendedAudience.unsupportedCountries[0]", "Lowercase country codes are DEPRECATED. Use uppercase instead ('US')", 30, 7}, + ValidationWarning{File: "", Key: "intendedAudience.countries[0]", Description: "Lowercase country codes are DEPRECATED. Use uppercase instead ('IT')", Line: 27, Column: 7}, + ValidationWarning{File: "", Key: "intendedAudience.countries[1]", Description: "Lowercase country codes are DEPRECATED. Use uppercase instead ('DE')", Line: 28, Column: 7}, + ValidationWarning{File: "", Key: "intendedAudience.unsupportedCountries", Description: "This key is DEPRECATED and will be removed in the future. Use 'intendedAudience.countries' to list the targeted countries instead", Line: 29, Column: 3}, + ValidationWarning{File: "", Key: "intendedAudience.unsupportedCountries[0]", Description: "Lowercase country codes are DEPRECATED. Use uppercase instead ('US')", Line: 30, Column: 7}, }, "valid_with_government_scope.yml": ValidationResults{ - ValidationWarning{"", "intendedAudience.scope[1]", "The 'government' scope is DEPRECATED and will be removed in the future. It's safe to drop it", 19, 7}, + ValidationWarning{File: "", Key: "intendedAudience.scope[1]", Description: "The 'government' scope is DEPRECATED and will be removed in the future. It's safe to drop it", Line: 19, Column: 7}, }, "valid_with_unsupportedCountries.yml": ValidationResults{ - ValidationWarning{"", "intendedAudience.unsupportedCountries", "This key is DEPRECATED and will be removed in the future. Use 'intendedAudience.countries' to list the targeted countries instead", 19, 3}, + ValidationWarning{File: "", Key: "intendedAudience.unsupportedCountries", Description: "This key is DEPRECATED and will be removed in the future. Use 'intendedAudience.countries' to list the targeted countries instead", Line: 19, Column: 3}, }, "valid_with_isBasedOn_string.yml": ValidationResults{ - ValidationWarning{"", "isBasedOn", "The single string form is DEPRECATED and will be removed in the future. Use a one element array instead", 6, 1}, + ValidationWarning{File: "", Key: "isBasedOn", Description: "The single string form is DEPRECATED and will be removed in the future. Use a one element array instead", Line: 6, Column: 1}, }, "valid_with_legal_repoOwner.yml": ValidationResults{ - ValidationWarning{"", "legal.repoOwner", "This key is DEPRECATED and will be removed in the future. Use 'organisation.name' instead", 62, 3}, + ValidationWarning{File: "", Key: "legal.repoOwner", Description: "This key is DEPRECATED and will be removed in the future. Use 'organisation.name' instead", Line: 62, Column: 3}, }, "valid_with_usedBy.yml": ValidationResults{ - ValidationWarning{"", "usedBy", "This key is DEPRECATED and will be removed in the future. It's safe to drop it", 12, 1}, + ValidationWarning{File: "", Key: "usedBy", Description: "This key is DEPRECATED and will be removed in the future. It's safe to drop it", Line: 12, Column: 1}, }, "valid_with_dependsOn_open.yml": ValidationResults{ - ValidationWarning{"", "dependsOn.open", "This key is DEPRECATED and will be removed in the future. It's safe to drop it", 53, 3}, + ValidationWarning{File: "", Key: "dependsOn.open", Description: "This key is DEPRECATED and will be removed in the future. It's safe to drop it", Line: 53, Column: 3}, }, "valid_with_videos.yml": ValidationResults{ - ValidationWarning{"", "description.en-GB.videos", "This key is DEPRECATED and will be removed in the future. Link videos from the documentation or the website instead", 37, 5}, + ValidationWarning{File: "", Key: "description.en-GB.videos", Description: "This key is DEPRECATED and will be removed in the future. Link videos from the documentation or the website instead", Line: 37, Column: 5}, }, "valid_with_IT_piattaforme.yml": ValidationResults{ - ValidationWarning{"", "IT", "This key is DEPRECATED and will be removed in the future. Migrate its keys as their warnings say, then drop it", 215, 1}, - ValidationWarning{"", "IT.piattaforme.spid", "This key is DEPRECATED and will be removed in the future. Add a 'supports' entry with id 'alias:spid' instead", 217, 5}, - ValidationWarning{"", "IT.piattaforme.pagopa", "This key is DEPRECATED and will be removed in the future. Add a 'supports' entry with id 'alias:pagopa' instead", 218, 5}, - ValidationWarning{"", "IT.piattaforme.cie", "This key is DEPRECATED and will be removed in the future. Add a 'supports' entry with id 'alias:cie' instead", 219, 5}, - ValidationWarning{"", "IT.piattaforme.anpr", "This key is DEPRECATED and will be removed in the future. Add a 'supports' entry with id 'alias:anpr' instead", 220, 5}, - ValidationWarning{"", "IT.piattaforme.io", "This key is DEPRECATED and will be removed in the future. Add a 'supports' entry with id 'alias:io' instead", 221, 5}, + ValidationWarning{File: "", Key: "IT", Description: "This key is DEPRECATED and will be removed in the future. Migrate its keys as their warnings say, then drop it", Line: 215, Column: 1}, + ValidationWarning{File: "", Key: "IT.piattaforme.spid", Description: "This key is DEPRECATED and will be removed in the future. Add a 'supports' entry with id 'alias:spid' instead", Line: 217, Column: 5}, + ValidationWarning{File: "", Key: "IT.piattaforme.pagopa", Description: "This key is DEPRECATED and will be removed in the future. Add a 'supports' entry with id 'alias:pagopa' instead", Line: 218, Column: 5}, + ValidationWarning{File: "", Key: "IT.piattaforme.cie", Description: "This key is DEPRECATED and will be removed in the future. Add a 'supports' entry with id 'alias:cie' instead", Line: 219, Column: 5}, + ValidationWarning{File: "", Key: "IT.piattaforme.anpr", Description: "This key is DEPRECATED and will be removed in the future. Add a 'supports' entry with id 'alias:anpr' instead", Line: 220, Column: 5}, + ValidationWarning{File: "", Key: "IT.piattaforme.io", Description: "This key is DEPRECATED and will be removed in the future. Add a 'supports' entry with id 'alias:io' instead", Line: 221, Column: 5}, }, "valid_with_IT_riuso_codiceIPA.yml": ValidationResults{ - ValidationWarning{"", "IT", "This key is DEPRECATED and will be removed in the future. Migrate its keys as their warnings say, then drop it", 101, 1}, - ValidationWarning{"", "IT.riuso.codiceIPA", "This key is DEPRECATED and will be removed in the future. Use 'organisation.uri' and set it to 'urn:x-italian-pa:pcm' instead", 103, 5}, + ValidationWarning{File: "", Key: "IT", Description: "This key is DEPRECATED and will be removed in the future. Migrate its keys as their warnings say, then drop it", Line: 101, Column: 1}, + ValidationWarning{File: "", Key: "IT.riuso.codiceIPA", Description: "This key is DEPRECATED and will be removed in the future. Use 'organisation.uri' and set it to 'urn:x-italian-pa:pcm' instead", Line: 103, Column: 5}, }, "valid_with_country_specific_section_uppercase.yml": ValidationResults{ - ValidationWarning{"", "IT", "This key is DEPRECATED and will be removed in the future. Migrate its keys as their warnings say, then drop it", 90, 1}, + ValidationWarning{File: "", Key: "IT", Description: "This key is DEPRECATED and will be removed in the future. Migrate its keys as their warnings say, then drop it", Line: 90, Column: 1}, }, "countryExtensionVersion_1.0.yml": ValidationResults{ - ValidationWarning{"", "IT", "This key is DEPRECATED and will be removed in the future. Migrate its keys as their warnings say, then drop it", 90, 1}, + ValidationWarning{File: "", Key: "IT", Description: "This key is DEPRECATED and will be removed in the future. Migrate its keys as their warnings say, then drop it", Line: 90, Column: 1}, }, "valid_no_it_conforme.yml": ValidationResults{ - ValidationWarning{"", "IT", "This key is DEPRECATED and will be removed in the future. Migrate its keys as their warnings say, then drop it", 90, 1}, + ValidationWarning{File: "", Key: "IT", Description: "This key is DEPRECATED and will be removed in the future. Migrate its keys as their warnings say, then drop it", Line: 90, Column: 1}, }, } @@ -792,17 +747,17 @@ func TestDecodeValueErrorsRemote(t *testing.T) { // Pinned to a commit: fetching from main means a testdata change // breaks this test in every PR until the change itself lands. {"https://raw.githubusercontent.com/italia/publiccode-parser-go/389af926bcb5bcb723b56d8e390585f2d0f2c7e8/testdata/v0/valid_with_warnings/valid_with_lowercase_countries.yml", ValidationResults{ - ValidationWarning{"", "isBasedOn", "The single string form is DEPRECATED and will be removed in the future. Use a one element array instead", 7, 1}, - ValidationWarning{"", "usedBy", "This key is DEPRECATED and will be removed in the future. It's safe to drop it", 18, 1}, - ValidationWarning{"", "intendedAudience.countries[0]", "Lowercase country codes are DEPRECATED. Use uppercase instead ('IT')", 31, 7}, - ValidationWarning{"", "intendedAudience.countries[1]", "Lowercase country codes are DEPRECATED. Use uppercase instead ('DE')", 32, 7}, - ValidationWarning{"", "intendedAudience.unsupportedCountries", "This key is DEPRECATED and will be removed in the future. Use 'intendedAudience.countries' to list the targeted countries instead", 33, 3}, - ValidationWarning{"", "intendedAudience.unsupportedCountries[0]", "Lowercase country codes are DEPRECATED. Use uppercase instead ('US')", 34, 7}, - ValidationWarning{"", "description.en.videos", "This key is DEPRECATED and will be removed in the future. Link videos from the documentation or the website instead", 62, 5}, - ValidationWarning{"", "maintenance.contacts[0].phone", "Phone numbers SHOULD use the E.164 format, e.g. '+3923113215112'", 83, 7}, - ValidationWarning{"", "maintenance.contacts[1].phone", "Phone numbers SHOULD use the E.164 format, e.g. '+3923113215112'", 87, 7}, - ValidationWarning{"", "maintenance.contacts[2].phone", "Phone numbers SHOULD use the E.164 format, e.g. '+3923113215112'", 91, 7}, - ValidationWarning{"", "dependsOn.open", "This key is DEPRECATED and will be removed in the future. It's safe to drop it", 102, 3}, + ValidationWarning{File: "", Key: "isBasedOn", Description: "The single string form is DEPRECATED and will be removed in the future. Use a one element array instead", Line: 7, Column: 1}, + ValidationWarning{File: "", Key: "usedBy", Description: "This key is DEPRECATED and will be removed in the future. It's safe to drop it", Line: 18, Column: 1}, + ValidationWarning{File: "", Key: "intendedAudience.countries[0]", Description: "Lowercase country codes are DEPRECATED. Use uppercase instead ('IT')", Line: 31, Column: 7}, + ValidationWarning{File: "", Key: "intendedAudience.countries[1]", Description: "Lowercase country codes are DEPRECATED. Use uppercase instead ('DE')", Line: 32, Column: 7}, + ValidationWarning{File: "", Key: "intendedAudience.unsupportedCountries", Description: "This key is DEPRECATED and will be removed in the future. Use 'intendedAudience.countries' to list the targeted countries instead", Line: 33, Column: 3}, + ValidationWarning{File: "", Key: "intendedAudience.unsupportedCountries[0]", Description: "Lowercase country codes are DEPRECATED. Use uppercase instead ('US')", Line: 34, Column: 7}, + ValidationWarning{File: "", Key: "description.en.videos", Description: "This key is DEPRECATED and will be removed in the future. Link videos from the documentation or the website instead", Line: 62, Column: 5}, + ValidationWarning{File: "", Key: "maintenance.contacts[0].phone", Description: "Phone numbers SHOULD use the E.164 format, e.g. '+3923113215112'", Line: 83, Column: 7}, + ValidationWarning{File: "", Key: "maintenance.contacts[1].phone", Description: "Phone numbers SHOULD use the E.164 format, e.g. '+3923113215112'", Line: 87, Column: 7}, + ValidationWarning{File: "", Key: "maintenance.contacts[2].phone", Description: "Phone numbers SHOULD use the E.164 format, e.g. '+3923113215112'", Line: 91, Column: 7}, + ValidationWarning{File: "", Key: "dependsOn.open", Description: "This key is DEPRECATED and will be removed in the future. It's safe to drop it", Line: 102, Column: 3}, }}, } @@ -829,19 +784,19 @@ func TestRelativePathsOrURLs(t *testing.T) { // Remote publiccode.yml and relative path in screenshots: // should look for the screenshot remotely relative to this URL {"https://raw.githubusercontent.com/italia/publiccode-parser-go/2a1f25a36e0f2ab2d71efb67db8b66ff00573fbe/testdata/v0/invalid/description_en_screenshots_missing_file.yml", ValidationResults{ - ValidationError{"", "description.en.screenshots[0]", "'no_such_file.png' is not an image: downloading https://raw.githubusercontent.com/italia/publiccode-parser-go/2a1f25a36e0f2ab2d71efb67db8b66ff00573fbe/testdata/v0/invalid/no_such_file.png: not found", 42, 9}, + ValidationError{File: "", Key: "description.en.screenshots[0]", Description: "'no_such_file.png' is not an image: downloading https://raw.githubusercontent.com/italia/publiccode-parser-go/2a1f25a36e0f2ab2d71efb67db8b66ff00573fbe/testdata/v0/invalid/no_such_file.png: not found", Line: 42, Column: 9}, }}, // Local publiccode.yml and relative path in screenshot: // should look for the logo relative to this path in the filesystem {"testdata/v0/invalid/description_en_screenshots_missing_file.yml", ValidationResults{ - ValidationError{"", "description.en.screenshots[0]", "'no_such_file.png' is not an image: no such file: " + cwd + "/testdata/v0/invalid/no_such_file.png", 42, 9}, + ValidationError{File: "", Key: "description.en.screenshots[0]", Description: "'no_such_file.png' is not an image: no such file: " + cwd + "/testdata/v0/invalid/no_such_file.png", Line: 42, Column: 9}, }}, // Remote publiccode.yml and URL in logo: // should look for the logo remotely {"https://raw.githubusercontent.com/italia/publiccode-parser-go/2a1f25a36e0f2ab2d71efb67db8b66ff00573fbe/testdata/v0/invalid/logo_missing_url.yml", ValidationResults{ - ValidationError{"", "logo", "downloading https://google.com/no_such_file.png: not found", 18, 1}, + ValidationError{File: "", Key: "logo", Description: "downloading https://google.com/no_such_file.png: not found", Line: 18, Column: 1}, }}, // Local publiccode.yml and URL in logo: @@ -904,7 +859,7 @@ func TestRelativePathsOrURLsNoNetwork(t *testing.T) { // should look for the logo relative to this path in the filesystem. // DisableNetwork doesn't affect this so the check *IS* performed. {"testdata/v0/invalid/description_en_screenshots_missing_file.yml", ValidationResults{ - ValidationError{"", "description.en.screenshots[0]", "'no_such_file.png' is not an image: no such file: " + cwd + "/testdata/v0/invalid/no_such_file.png", 42, 9}, + ValidationError{File: "", Key: "description.en.screenshots[0]", Description: "'no_such_file.png' is not an image: no such file: " + cwd + "/testdata/v0/invalid/no_such_file.png", Line: 42, Column: 9}, }}, } @@ -927,7 +882,7 @@ func TestRelativePathsOrURLsNoNetwork(t *testing.T) { func TestUrlMissingWithoutPath(t *testing.T) { expected := map[string]error{ "url_missing.yml": ValidationResults{ - ValidationError{"", "url", "url is a required field", 1, 1}, + ValidationError{File: "", Key: "url", Description: "url is a required field", Line: 1, Column: 1}, }, } diff --git a/v1_test.go b/v1_test.go index 8a762da..05c6643 100644 --- a/v1_test.go +++ b/v1_test.go @@ -13,13 +13,7 @@ func TestInvalidTestcasesV1(t *testing.T) { } expected := ValidationResults{ - ValidationError{ - "", - "publiccodeYmlVersion", - "unsupported version: '1'. Supported versions: 0, 0.2, 0.2.0, 0.2.1, 0.2.2, 0.3, 0.3.0, 0.4, 0.4.0, 0.5.0, 0.5, 0.6.0, 0.6, 0.7.0, 0.7, 0.8.0, 0.8", - 0, - 0, - }, + ValidationError{File: "", Key: "publiccodeYmlVersion", Description: "unsupported version: '1'. Supported versions: 0, 0.2, 0.2.0, 0.2.1, 0.2.2, 0.3, 0.3.0, 0.4, 0.4.0, 0.5.0, 0.5, 0.6.0, 0.6, 0.7.0, 0.7, 0.8.0, 0.8", Line: 0, Column: 0}, } for _, dir := range dirs {