Skip to content

Commit

Permalink
feat: mark authorsFile as deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
bfabio committed Jun 14, 2024
1 parent 95e5fa1 commit e1e58fb
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
10 changes: 7 additions & 3 deletions fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,14 @@ func validateFieldsV0(publiccode PublicCode, parser Parser, network bool) error
}
}

if publiccodev0.Legal.AuthorsFile != nil && !parser.fileExists(toCodeHostingURL(*publiccodev0.Legal.AuthorsFile, parser.baseURL), network) {
u := toCodeHostingURL(*publiccodev0.Legal.AuthorsFile, parser.baseURL)
if publiccodev0.Legal.AuthorsFile != nil {
vr = append(vr, ValidationWarning{"legal.authorsFile", "This key is DEPRECATED and will be removed in the future", 0, 0})

vr = append(vr, newValidationError("legal.authorsFile", "'%s' does not exist", urlutil.DisplayURL(&u)))
if !parser.fileExists(toCodeHostingURL(*publiccodev0.Legal.AuthorsFile, parser.baseURL), network) {
u := toCodeHostingURL(*publiccodev0.Legal.AuthorsFile, parser.baseURL)

vr = append(vr, newValidationError("legal.authorsFile", "'%s' does not exist", urlutil.DisplayURL(&u)))
}
}

if publiccodev0.Legal.License != "" {
Expand Down
27 changes: 27 additions & 0 deletions parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,26 @@ func TestValidTestcasesV0_NoNetwork(t *testing.T) {
checkValidFilesNoNetwork("testdata/v0/valid/no-network/*.yml", 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", 72, 3},
},
}

testFiles, _ := filepath.Glob("testdata/v0/valid_with_warnings/no-network/*yml")
for _, file := range testFiles {
baseName := path.Base(file)
if expected[baseName] == nil {
t.Errorf("No expected data for file %s", baseName)
}
t.Run(file, func(t *testing.T) {
err := parseNoNetwork(file)
checkParseErrors(t, err, testType{file, expected[baseName]})
})
}
}

func TestInvalidTestcasesV0_NoNetwork(t *testing.T) {
expected := map[string]error{
// logo
Expand Down Expand Up @@ -418,6 +438,12 @@ func TestInvalidTestcasesV0(t *testing.T) {
"legal.license", "invalid license 'Invalid License'", 42, 3,
}},
"legal_authorsFile_missing_file.yml": ValidationResults{
ValidationWarning{
"legal.authorsFile",
"This key is DEPRECATED and will be removed in the future",
42,
3,
},
ValidationError{
"legal.authorsFile",
"'https://raw.githubusercontent.com/italia/developers.italia.it/main/no_such_authors_file.txt' does not exist",
Expand Down Expand Up @@ -585,6 +611,7 @@ func TestDecodeValueErrorsRemote(t *testing.T) {
ValidationWarning{
"publiccodeYmlVersion", "v0.2 is not the latest version, use '0.4.0'. Parsing this file as v0.4.0.", 1, 1,
},
ValidationWarning{"legal.authorsFile", "This key is DEPRECATED and will be removed in the future", 48, 3},
ValidationWarning{"description.it.genericName", "This key is DEPRECATED and will be removed in the future", 12, 5},
}},
}
Expand Down
1 change: 0 additions & 1 deletion testdata/v0/valid/no-network/valid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ legal:
license: AGPL-3.0-or-later
mainCopyrightOwner: City of Chicago
repoOwner: City of Chicago
authorsFile: testdata/AUTHORS

maintenance:
type: "contract"
Expand Down
File renamed without changes.

0 comments on commit e1e58fb

Please sign in to comment.