Skip to content

Commit

Permalink
ci(lint): new linter and new issues only (#1254)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaost authored Jan 3, 2025
1 parent 5729635 commit a8d0648
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 56 deletions.
28 changes: 2 additions & 26 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -53,4 +28,5 @@ jobs:
# https://golangci-lint.run/
uses: golangci/golangci-lint-action@v6
with:
version: latest
version: latest
only-new-issues: true
44 changes: 16 additions & 28 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -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
exclude-use-default: true
2 changes: 1 addition & 1 deletion internal/tagexpr/spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions pkg/app/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions pkg/app/server/hertz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/common/test/mock/writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit a8d0648

Please sign in to comment.