From ffc9a4eb9204f5a31b7fb1d6cd907e6cc3e93578 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Wed, 1 Nov 2023 12:14:31 +0100 Subject: [PATCH] ci: enable more linters Signed-off-by: Matthieu MOREL --- .github/workflows/ci.yml | 2 ++ .golangci.yml | 12 +++++++++++- cyclonedx_xml.go | 2 +- validate_json_test.go | 4 ++-- validate_xml_test.go | 6 +++--- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e7bf7da..3cb5dd7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,10 +35,12 @@ jobs: with: go-version: "1.20" check-latest: true + cache: false - name: Run golangci-lint uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # tag=v3.7.0 with: version: latest + args: --verbose test: name: Test diff --git a/.golangci.yml b/.golangci.yml index a9ac9d3..5292e43 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,6 +1,16 @@ linters: enable: - asciicheck - - gofmt + - errorlint + - gci + - gofumpt - gosec - wastedassign + +linters-settings: + gci: + sections: + - standard + - default + - prefix(github.com/CycloneDX) + custom-order: true diff --git a/cyclonedx_xml.go b/cyclonedx_xml.go index 4e038f2..8f3caa8 100644 --- a/cyclonedx_xml.go +++ b/cyclonedx_xml.go @@ -52,7 +52,7 @@ func (c *Copyright) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { if err := d.DecodeElement(&text, &start); err != nil { return err } - (*c).Text = text + c.Text = text return nil } diff --git a/validate_json_test.go b/validate_json_test.go index d1b5c9e..aa22982 100644 --- a/validate_json_test.go +++ b/validate_json_test.go @@ -19,6 +19,7 @@ package cyclonedx import ( "fmt" + "github.com/xeipuuv/gojsonschema" ) @@ -29,8 +30,7 @@ var jsonSchemaFiles = map[SpecVersion]string{ SpecVersion1_5: "file://./schema/bom-1.5.schema.json", } -type jsonValidator struct { -} +type jsonValidator struct{} func newJSONValidator() validator { return &jsonValidator{} diff --git a/validate_xml_test.go b/validate_xml_test.go index 5b31ec6..e678b49 100644 --- a/validate_xml_test.go +++ b/validate_xml_test.go @@ -19,8 +19,9 @@ package cyclonedx import ( "fmt" - "github.com/terminalstatic/go-xsd-validate" "sync" + + "github.com/terminalstatic/go-xsd-validate" ) var xmlSchemaFiles = map[SpecVersion]string{ @@ -34,8 +35,7 @@ var xmlSchemaFiles = map[SpecVersion]string{ var xsdValidateInitOnce sync.Once -type xmlValidator struct { -} +type xmlValidator struct{} func newXMLValidator() validator { var initErr error