From 9801b1cf64dbf8340fe532542bae186a6bb507dd Mon Sep 17 00:00:00 2001 From: Shulhan Date: Wed, 14 Jan 2026 04:09:32 +0700 Subject: report: group the file with missing copyright year as unknown --- report.go | 10 ++++++++++ spdxconv_test.go | 9 ++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/report.go b/report.go index f229e81..5296bef 100644 --- a/report.go +++ b/report.go @@ -131,6 +131,10 @@ func (rep *report) scan(conv *SPDXConv, listFile []string) (err error) { if f.licenseID == valExist && f.copyrightText == valExist { continue } + if f.copyrightYear == `` { + rep.listUnknown = append(rep.listUnknown, f) + continue + } rep.listRegular = append(rep.listRegular, f) } return nil @@ -151,7 +155,9 @@ func (rep *report) write() (err error) { var csvw = csv.NewWriter(&buf) var record = make([]string, v1FieldsPerRecord) + buf.WriteString("//\n") buf.WriteString(reportMetaPrefix + reportGroupRegular + "\n") + buf.WriteString("//\n") for _, file := range rep.listRegular { record[0] = file.path record[1] = file.licenseID @@ -168,7 +174,9 @@ func (rep *report) write() (err error) { } csvw.Flush() + buf.WriteString("//\n") buf.WriteString(reportMetaPrefix + reportGroupBinary + "\n") + buf.WriteString("//\n") for _, file := range rep.listBinary { record[0] = file.path record[1] = file.licenseID @@ -185,7 +193,9 @@ func (rep *report) write() (err error) { } csvw.Flush() + buf.WriteString("//\n") buf.WriteString(reportMetaPrefix + reportGroupUnknown + "\n") + buf.WriteString("//\n") for _, file := range rep.listUnknown { record[0] = file.path record[1] = file.licenseID diff --git a/spdxconv_test.go b/spdxconv_test.go index 842102c..aa37cba 100644 --- a/spdxconv_test.go +++ b/spdxconv_test.go @@ -131,14 +131,21 @@ func TestScan(t *testing.T) { //spdxconv:version:v1 //spdxconv:header:path,license_id,idx_license_id,year,copyright_id,idx_copyright_id +// //spdxconv:regular +// no_copyright_year.md,match,2,2026,default,0," test.go,match,1,2022,match,0,// , test.html,match,4,2022,match,1," test.sh,default,0,2026,default,0,# , test.sql,match,1,2022,match,0,-- , +// //spdxconv:binary -//spdxconv:unknown` +// +// +//spdxconv:unknown +// +` test.Assert(t, `Scan: `+scanDir, exp, string(got)) } -- cgit v1.3