diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index a9c318f53..37cb16a39 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -14,31 +14,6 @@ jobs: - name: Check Spell uses: crate-ci/typos@master - staticcheck: - runs-on: [ self-hosted, X64 ] - steps: - - uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: stable - # For self-hosted, the cache path is shared across projects - # and it works well without the cache of github actions - # Enable it if we're going to use Github only - cache: false - - - uses: reviewdog/action-staticcheck@v1 - with: - github_token: ${{ secrets.github_token }} - # Change reviewdog reporter if you need [github-pr-check,github-check,github-pr-review]. - reporter: github-pr-review - # Report all results. - filter_mode: nofilter - # Exit with 1 when it find at least one finding. - fail_on_error: true - # Set staticcheck flags - staticcheck_flags: -checks=inherit,-SA1029,-SA5008 - lint: runs-on: [ self-hosted, X64 ] steps: @@ -53,4 +28,5 @@ jobs: # https://golangci-lint.run/ uses: golangci/golangci-lint-action@v6 with: - version: latest \ No newline at end of file + version: latest + only-new-issues: true diff --git a/.golangci.yaml b/.golangci.yaml index 23c8d3629..eee75d771 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,35 +1,23 @@ # Options for analysis running. run: - # include `vendor` `third_party` `testdata` `examples` `Godeps` `builtin` - skip-dirs-use-default: true -# output configuration options + timeout: 3m - # Timeout for analysis, e.g. 30s, 5m. - # Default: 1m - timeout: 30m - -output: - # Format: colored-line-number|line-number|json|tab|checkstyle|code-climate|junit-xml|github-actions - format: colored-line-number -# All available settings of specific linters. -# Refer to https://golangci-lint.run/usage/linters -linters-settings: - govet: - # Disable analyzers by name. - # Run `go tool vet help` to see all analyzers. - disable: - - stdmethods -linters: +linters: # https://golangci-lint.run/usage/linters/ + disable-all: true enable: - - gofumpt - - goimports - - gofmt + - gosimple - govet - disable: - - errcheck - - typecheck - - deadcode - - varcheck + - ineffassign - staticcheck + - unused + - unconvert + - goimports + +linters-settings: + staticcheck: + checks: + - all + - "-SA5008" # unknown JSON option "required" + issues: - exclude-use-default: true \ No newline at end of file + exclude-use-default: true diff --git a/internal/tagexpr/spec_test.go b/internal/tagexpr/spec_test.go index 07f93d1ec..b73e9b00c 100644 --- a/internal/tagexpr/spec_test.go +++ b/internal/tagexpr/spec_test.go @@ -54,7 +54,7 @@ func TestReadBoolExprNode(t *testing.T) { {expr: "true ", val: true, lastExprNode: " "}, {expr: "!true&", val: false, lastExprNode: "&"}, {expr: "!false|", val: true, lastExprNode: "|"}, - {expr: "!!!!false =", val: !!!!false, lastExprNode: " ="}, + {expr: "!!!!false =", val: !!!!false, lastExprNode: " ="}, //nolint:staticcheck // SA4013: negating a boolean twice has no effect } for _, c := range cases { t.Log(c.expr) diff --git a/pkg/app/client/client_test.go b/pkg/app/client/client_test.go index c9332a2ec..9aa99f9dc 100644 --- a/pkg/app/client/client_test.go +++ b/pkg/app/client/client_test.go @@ -1884,24 +1884,28 @@ func TestClientLastMiddleware(t *testing.T) { } mw1 := func(next Endpoint) Endpoint { return func(ctx context.Context, req *protocol.Request, resp *protocol.Response) (err error) { + //nolint:staticcheck // SA1029 no built-in type string as key ctx = context.WithValue(ctx, "final0", "final0") return next(ctx, req, resp) } } mw2 := func(next Endpoint) Endpoint { return func(ctx context.Context, req *protocol.Request, resp *protocol.Response) (err error) { + //nolint:staticcheck // SA1029 no built-in type string as key ctx = context.WithValue(ctx, "final1", "final1") return next(ctx, req, resp) } } mw3 := func(next Endpoint) Endpoint { return func(ctx context.Context, req *protocol.Request, resp *protocol.Response) (err error) { + //nolint:staticcheck // SA1029 no built-in type string as key ctx = context.WithValue(ctx, "final2", "final2") return next(ctx, req, resp) } } mw4 := func(next Endpoint) Endpoint { return func(ctx context.Context, req *protocol.Request, resp *protocol.Response) (err error) { + //nolint:staticcheck // SA1029 no built-in type string as key ctx = context.WithValue(ctx, "final0", "final3") return next(ctx, req, resp) } diff --git a/pkg/app/server/hertz_test.go b/pkg/app/server/hertz_test.go index b66043d29..83b40eba5 100644 --- a/pkg/app/server/hertz_test.go +++ b/pkg/app/server/hertz_test.go @@ -814,6 +814,7 @@ func (t testTracer) Start(ctx context.Context, c *app.RequestContext) context.Co value = v.(int) value++ } + //nolint:staticcheck // SA1029 no built-in type string as key return context.WithValue(ctx, "testKey", value) } diff --git a/pkg/common/test/mock/writer_test.go b/pkg/common/test/mock/writer_test.go index f03d69b07..1727c7a0d 100644 --- a/pkg/common/test/mock/writer_test.go +++ b/pkg/common/test/mock/writer_test.go @@ -44,7 +44,7 @@ func TestExtWriter(t *testing.T) { // setbody b2 := []byte("abc") - w.SetBody([]byte(b2)) + w.SetBody(b2) err = w.Flush() assert.DeepEqual(t, nil, err) assert.DeepEqual(t, b2, w.Buf.Bytes())