diff options
| author | Shulhan <ms@kilabit.info> | 2026-01-14 20:44:06 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2026-01-14 20:44:06 +0700 |
| commit | 8da1336917c763da16bc6466928c796f269548e8 (patch) | |
| tree | 49b45259bcfc63dd18d2236906a69acad8e37b1b | |
| parent | e5a023cc2aa1aec320574abd92eb9ea24846e0b5 (diff) | |
| download | spdxconv-8da1336917c763da16bc6466928c796f269548e8.tar.xz | |
all: handle binary file in post-scan
File that match with match-file-pattern but without prefix and suffix
will be marked as binary.
| -rw-r--r-- | file.go | 11 | ||||
| -rw-r--r-- | report.go | 6 | ||||
| -rw-r--r-- | spdxconv_test.go | 2 | ||||
| -rw-r--r-- | testdata/scan/test.json | 1 |
4 files changed, 19 insertions, 1 deletions
@@ -120,7 +120,16 @@ func (f *file) initLines(content []byte, maxLine int) (err error) { func (f *file) scan(conv *SPDXConv) { f.detectComment(&conv.cfg) - if f.isBinary || f.isUnknown { + if f.isBinary { + f.licenseID = valDefault + f.copyrightText = valDefault + f.getYearFromSCM(conv) + if f.copyrightYear == `` { + f.copyrightYear = conv.cfg.CopyrightYear + } + return + } + if f.isUnknown { return } f.scanLicenseID(conv) @@ -124,6 +124,12 @@ func (rep *report) scan(conv *SPDXConv, listFile []string) (err error) { continue } f.scan(conv) + if f.isBinary { + // json file should be detected as binary, since its + // does not have comment syntax. + rep.listBinary = append(rep.listBinary, f) + continue + } if f.isUnknown { rep.listUnknown = append(rep.listUnknown, f) continue diff --git a/spdxconv_test.go b/spdxconv_test.go index d73c69f..5186504 100644 --- a/spdxconv_test.go +++ b/spdxconv_test.go @@ -143,6 +143,7 @@ test.sql,match,1,2022,match,0,--, // //spdxconv:binary // +test.json,default,0,2025,default,0,, // //spdxconv:unknown // @@ -341,6 +342,7 @@ func TestSPDXConv_scanDir(t *testing.T) { `po/included.go`, `test.go`, `test.html`, + `test.json`, `test.sh`, `test.sql`, `with_spdx.go`, diff --git a/testdata/scan/test.json b/testdata/scan/test.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/testdata/scan/test.json @@ -0,0 +1 @@ +{} |
