diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index 5e221a2..f744ae8 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -22,6 +22,6 @@ jobs: run: make generate-mock - name: Static Code Analysis - uses: golangci/golangci-lint-action@v6 + uses: golangci/golangci-lint-action@v9 with: - version: latest \ No newline at end of file + version: latest diff --git a/.golangci.yml b/.golangci.yml index 6a7fd3a..7f1936e 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,19 +1,16 @@ # Options for analysis running # More info could be found at https://golangci-lint.run/usage/configuration/ +version: "2" + run: - # timeout for analysis, e.g. 30s, 5m, default is 1m timeout: 5m modules-download-mode: readonly -# List of useful linters could be found at https://github.com/golangci/awesome-go-linters linters: - disable-all: true + default: none enable: - errcheck - copyloopvar - - gofumpt - - goimports - - gosimple - govet - ineffassign - makezero @@ -27,21 +24,20 @@ linters: - unused - wastedassign - gosec + settings: + staticcheck: + checks: [ "all", "-SA1019", "-SA1029", "-ST1000", "-ST1003" ] + gosec: + excludes: [ "G204", "G301", "G302", "G304", "G306", "G601", "G101" ] + config: + global: + nosec: true -linters-settings: - staticcheck: - # https://staticcheck.io/docs/options#checks - checks: [ "all","-SA1019","-SA1029" ] - gosec: - excludes: [ "G204", "G301", "G302", "G304", "G306", "G601", "G101" ] - exclude-generated: true - config: - global: - nosec: true +formatters: + enable: + - gofumpt + - goimports issues: - exclude-use-default: false - # Maximum issues count per one linter. Set to 0 to disable. Default is 50. max-issues-per-linter: 0 - # Maximum count of issues with the same text. Set to 0 to disable. Default is 3. max-same-issues: 0 diff --git a/Makefile b/Makefile index 6b91391..5428ff0 100644 --- a/Makefile +++ b/Makefile @@ -34,11 +34,11 @@ GOIMPORTS: ########## ANALYSE ########## GOLANGCI_LINT = ${TOOLS_DIR}/golangci-lint -GOLANGCI_LINT_VERSION = 1.63.4 +GOLANGCI_LINT_VERSION = 2.12.2 verify: GOLANGCI_LINT echo $(GO_SOURCES) - $(GOLANGCI_LINT) run --out-format tab --config "${WORKSPACE_ROOT}/.golangci.yml" + $(GOLANGCI_LINT) run --config "${WORKSPACE_ROOT}/.golangci.yml" GOLANGCI_LINT: ${GOLANGCI_LINT} --version 2>/dev/null | grep ${GOLANGCI_LINT_VERSION} || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ${TOOLS_DIR} v${GOLANGCI_LINT_VERSION} diff --git a/apptrust/common/output.go b/apptrust/common/output.go index 49f95f6..4f569ae 100644 --- a/apptrust/common/output.go +++ b/apptrust/common/output.go @@ -38,7 +38,9 @@ func PrintTable(data []byte, w io.Writer, orderedKeys []string) error { return fmt.Errorf("failed to parse response: %w", err) } tw := tabwriter.NewWriter(w, 0, 0, 2, ' ', 0) - fmt.Fprintln(tw, "FIELD\tVALUE") + if _, err := fmt.Fprintln(tw, "FIELD\tVALUE"); err != nil { + return err + } for _, key := range orderedKeys { val, ok := fields[key] if !ok || val == nil { @@ -60,7 +62,9 @@ func PrintTable(data []byte, w io.Writer, orderedKeys []string) error { if strVal == "" { continue } - fmt.Fprintf(tw, "%s\t%s\n", key, strVal) + if _, err := fmt.Fprintf(tw, "%s\t%s\n", key, strVal); err != nil { + return err + } } return tw.Flush() }