Skip to content

Commit 82ae47d

Browse files
committed
feat: add advice on what to do when finding deprecated fields
Fix italia#236.
1 parent a4590c3 commit 82ae47d

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

fields.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func validateFieldsV0(publiccode PublicCode, parser Parser, network bool) error
5656
}
5757

5858
if publiccodev0.MonochromeLogo != "" {
59-
vr = append(vr, ValidationWarning{"monochromeLogo", "This key is DEPRECATED and will be removed in the future", 0, 0})
59+
vr = append(vr, ValidationWarning{"monochromeLogo", "This key is DEPRECATED and will be removed in the future. Use 'logo' instead", 0, 0})
6060

6161
if _, err := isRelativePathOrURL(publiccodev0.MonochromeLogo, "monochromeLogo"); err != nil {
6262
vr = append(vr, err)
@@ -66,7 +66,7 @@ func validateFieldsV0(publiccode PublicCode, parser Parser, network bool) error
6666
}
6767

6868
if publiccodev0.Legal.AuthorsFile != nil {
69-
vr = append(vr, ValidationWarning{"legal.authorsFile", "This key is DEPRECATED and will be removed in the future", 0, 0})
69+
vr = append(vr, ValidationWarning{"legal.authorsFile", "This key is DEPRECATED and will be removed in the future. It's safe to drop it", 0, 0})
7070

7171
if _, err := isRelativePathOrURL(*publiccodev0.Legal.AuthorsFile, "legal.authorsFile"); err != nil {
7272
vr = append(vr, err)
@@ -78,11 +78,11 @@ func validateFieldsV0(publiccode PublicCode, parser Parser, network bool) error
7878
}
7979

8080
if len(publiccodev0.InputTypes) > 0 {
81-
vr = append(vr, ValidationWarning{"inputTypes", "This key is DEPRECATED and will be removed in the future", 0, 0})
81+
vr = append(vr, ValidationWarning{"inputTypes", "This key is DEPRECATED and will be removed in the future. It's safe to drop it", 0, 0})
8282
}
8383

8484
if len(publiccodev0.OutputTypes) > 0 {
85-
vr = append(vr, ValidationWarning{"outputTypes", "This key is DEPRECATED and will be removed in the future", 0, 0})
85+
vr = append(vr, ValidationWarning{"outputTypes", "This key is DEPRECATED and will be removed in the future. It's safe to drop it", 0, 0})
8686
}
8787

8888
for lang, desc := range publiccodev0.Description {
@@ -93,7 +93,7 @@ func validateFieldsV0(publiccode PublicCode, parser Parser, network bool) error
9393
if len(desc.GenericName) > 0 {
9494
vr = append(vr, ValidationWarning{
9595
fmt.Sprintf("description.%s.genericName", lang),
96-
"This key is DEPRECATED and will be removed in the future", 0, 0,
96+
"This key is DEPRECATED and will be removed in the future. It's safe to drop it", 0, 0,
9797
})
9898
}
9999

parser_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func TestValidTestcasesV0_NoNetwork(t *testing.T) {
105105
func TestValidWithWarningTestcasesV0_NoNetwork(t *testing.T) {
106106
expected := map[string]error{
107107
"authorsFile.yml": ValidationResults{
108-
ValidationWarning{"legal.authorsFile", "This key is DEPRECATED and will be removed in the future", 72, 3},
108+
ValidationWarning{"legal.authorsFile", "This key is DEPRECATED and will be removed in the future. It's safe to drop it", 72, 3},
109109
},
110110
}
111111

@@ -146,7 +146,7 @@ func TestInvalidTestcasesV0_NoNetwork(t *testing.T) {
146146

147147
// monochromeLogo
148148
"monochromeLogo_invalid_png.yml": ValidationResults{
149-
ValidationWarning{"monochromeLogo", "This key is DEPRECATED and will be removed in the future", 18, 1},
149+
ValidationWarning{"monochromeLogo", "This key is DEPRECATED and will be removed in the future. Use 'logo' instead", 18, 1},
150150
ValidationError{"monochromeLogo", "image: unknown format", 18, 1},
151151
},
152152
}
@@ -287,7 +287,7 @@ func TestInvalidTestcasesV0(t *testing.T) {
287287
ValidationError{"monochromeLogo", "wrong type for this field", 18, 1},
288288
},
289289
"monochromeLogo_unsupported_extension.yml": ValidationResults{
290-
ValidationWarning{"monochromeLogo", "This key is DEPRECATED and will be removed in the future", 18, 1},
290+
ValidationWarning{"monochromeLogo", "This key is DEPRECATED and will be removed in the future. Use 'logo' instead", 18, 1},
291291
ValidationError{
292292
"monochromeLogo",
293293
"invalid file extension for: " + cwd + "/testdata/v0/invalid/monochromeLogo.mpg",
@@ -296,14 +296,14 @@ func TestInvalidTestcasesV0(t *testing.T) {
296296
},
297297
},
298298
"monochromeLogo_missing_file.yml": ValidationResults{
299-
ValidationWarning{"monochromeLogo", "This key is DEPRECATED and will be removed in the future", 18, 1},
299+
ValidationWarning{"monochromeLogo", "This key is DEPRECATED and will be removed in the future. Use 'logo' instead", 18, 1},
300300
ValidationError{"monochromeLogo", "no such file: " + cwd + "/testdata/v0/invalid/no_such_file.png", 18, 1},
301301
},
302302

303303
// inputTypes
304304
"inputTypes_invalid.yml": ValidationResults{
305305
ValidationError{"inputTypes[1]", "inputTypes[1] is not a valid MIME type", 1, 1},
306-
ValidationWarning{"inputTypes", "This key is DEPRECATED and will be removed in the future", 14, 1},
306+
ValidationWarning{"inputTypes", "This key is DEPRECATED and will be removed in the future. It's safe to drop it", 14, 1},
307307
},
308308
"inputTypes_wrong_type.yml": ValidationResults{
309309
ValidationError{"inputTypes.foobar", "wrong type for this field", 15, 1},
@@ -312,7 +312,7 @@ func TestInvalidTestcasesV0(t *testing.T) {
312312
// outputTypes
313313
"outputTypes_invalid.yml": ValidationResults{
314314
ValidationError{"outputTypes[1]", "outputTypes[1] is not a valid MIME type", 1, 1},
315-
ValidationWarning{"outputTypes", "This key is DEPRECATED and will be removed in the future", 14, 1},
315+
ValidationWarning{"outputTypes", "This key is DEPRECATED and will be removed in the future. It's safe to drop it", 14, 1},
316316
},
317317
"outputTypes_wrong_type.yml": ValidationResults{
318318
ValidationError{"outputTypes.foobar", "wrong type for this field", 15, 1},
@@ -418,7 +418,7 @@ func TestInvalidTestcasesV0(t *testing.T) {
418418
},
419419
"description_en_genericName_too_long.yml": ValidationResults{
420420
ValidationError{"description.en.genericName", "genericName must be a maximum of 35 characters in length", 22, 5},
421-
ValidationWarning{"description.en.genericName", "This key is DEPRECATED and will be removed in the future", 22, 5},
421+
ValidationWarning{"description.en.genericName", "This key is DEPRECATED and will be removed in the future. It's safe to drop it", 22, 5},
422422
},
423423
"description_en_shortDescription_missing.yml": ValidationResults{
424424
ValidationError{"description.en.shortDescription", "shortDescription is a required field", 20, 5},
@@ -486,7 +486,7 @@ func TestInvalidTestcasesV0(t *testing.T) {
486486
"legal_authorsFile_missing_file.yml": ValidationResults{
487487
ValidationWarning{
488488
"legal.authorsFile",
489-
"This key is DEPRECATED and will be removed in the future",
489+
"This key is DEPRECATED and will be removed in the future. It's safe to drop it",
490490
42,
491491
3,
492492
},
@@ -644,7 +644,7 @@ func TestValidTestcasesV0(t *testing.T) {
644644
func TestValidWithWarningsTestcasesV0(t *testing.T) {
645645
expected := map[string]error{
646646
"unicode_grapheme_clusters.yml": ValidationResults{
647-
ValidationWarning{"description.en.genericName", "This key is DEPRECATED and will be removed in the future", 23, 5},
647+
ValidationWarning{"description.en.genericName", "This key is DEPRECATED and will be removed in the future. It's safe to drop it", 23, 5},
648648
},
649649
"valid.minimal.v0.2.yml": ValidationResults{
650650
ValidationWarning{"publiccodeYmlVersion", "v0.2 is not the latest version, use '0.4.0'. Parsing this file as v0.4.0.", 1, 1},
@@ -653,8 +653,8 @@ func TestValidWithWarningsTestcasesV0(t *testing.T) {
653653
ValidationWarning{"publiccodeYmlVersion", "v0.3 is not the latest version, use '0.4.0'. Parsing this file as v0.4.0.", 1, 1},
654654
},
655655
"valid.mime_types.yml": ValidationResults{
656-
ValidationWarning{"inputTypes", "This key is DEPRECATED and will be removed in the future", 48, 1},
657-
ValidationWarning{"outputTypes", "This key is DEPRECATED and will be removed in the future", 50, 1},
656+
ValidationWarning{"inputTypes", "This key is DEPRECATED and will be removed in the future. It's safe to drop it", 48, 1},
657+
ValidationWarning{"outputTypes", "This key is DEPRECATED and will be removed in the future. It's safe to drop it", 50, 1},
658658
},
659659
}
660660

@@ -684,8 +684,8 @@ func TestDecodeValueErrorsRemote(t *testing.T) {
684684
ValidationWarning{
685685
"publiccodeYmlVersion", "v0.2 is not the latest version, use '0.4.0'. Parsing this file as v0.4.0.", 1, 1,
686686
},
687-
ValidationWarning{"legal.authorsFile", "This key is DEPRECATED and will be removed in the future", 48, 3},
688-
ValidationWarning{"description.it.genericName", "This key is DEPRECATED and will be removed in the future", 12, 5},
687+
ValidationWarning{"legal.authorsFile", "This key is DEPRECATED and will be removed in the future. It's safe to drop it", 48, 3},
688+
ValidationWarning{"description.it.genericName", "This key is DEPRECATED and will be removed in the future. It's safe to drop it", 12, 5},
689689
}},
690690
}
691691

0 commit comments

Comments
 (0)