diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fd4a05f..2f267ec 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -18,24 +18,9 @@ on: jobs: lint: - name: Lint - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - with: - ref: ${{ github.event.inputs.ref }} - - - uses: actions/setup-go@v5 - with: - go-version-file: 'cmd/go.mod' - cache-dependency-path: cmd/go.sum - - - name: golangci-lint - uses: golangci/golangci-lint-action@v4 - with: - version: latest - working-directory: cmd + uses: nspcc-dev/.github/.github/workflows/go-linter.yml@master + with: + workdir: cmd codeql: name: CodeQL diff --git a/.gitignore b/.gitignore index c960d92..bd8374a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .idea .vscode +.golangci.yml vendor .docker/ir/out/* !.docker/ir/out/.gitkeep diff --git a/.golangci.yml b/.golangci.yml deleted file mode 100644 index 3597c70..0000000 --- a/.golangci.yml +++ /dev/null @@ -1,73 +0,0 @@ -# This file contains all available configuration options -# with their default values. - -# options for analysis running -run: - # timeout for analysis, e.g. 30s, 5m, default is 1m - timeout: 5m - - # include test files or not, default is true - tests: true - -# output configuration options -output: - # colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number" - formats: - - format: tab - -# all available settings of specific linters -linters-settings: - exhaustive: - # indicates that switch statements are to be considered exhaustive if a - # 'default' case is present, even if all enum members aren't listed in the - # switch - default-signifies-exhaustive: true - -linters: - enable: - # mandatory linters - - govet - - revive - - # some default golangci-lint linters - - errcheck - - gosimple - - godot - - ineffassign - - staticcheck - - typecheck - - unused - - # extra linters - # - exhaustive - # - goconst - # - goerr113 - # - gomnd - # - nonamedreturns - # - unparam - - bidichk - - bodyclose - - contextcheck - - decorder - - durationcheck - - errorlint - - exportloopref - - gofmt - - misspell - - predeclared - - reassign - - whitespace - - goimports - disable-all: true - fast: false - -issues: - include: - - EXC0002 # should have a comment - - EXC0003 # test/Test ... consider calling this - - EXC0004 # govet - - EXC0005 # C-style breaks - exclude-rules: - - linters: - - revive - text: "unused-parameter" diff --git a/Makefile b/Makefile index d260b4e..6fd9a5e 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ NEOBENCH_FROM_COUNT ?= 1 NEOBENCH_TO_COUNT ?= 1 MS_PER_BLOCK ?= 0 -.PHONY: help +.PHONY: help lint # Show this help prompt help: @@ -36,6 +36,13 @@ help: start.SharpFourNodesGoRPC10wrk start.SharpFourNodesGoRPC30wrk start.SharpFourNodesGoRPC100wrk \ start.SharpFourNodesGoRPC25rate start.SharpFourNodesGoRPC50rate start.SharpFourNodesGoRPC60rate start.SharpFourNodesGoRPC300rate start.SharpFourNodesGoRPC1000rate +.golangci.yml: + wget -O $@ https://github.com/nspcc-dev/.github/raw/master/.golangci.yml + +# Lint Go code +lint: .golangci.yml + @cd cmd && golangci-lint run --config ../$< + # Build all images build: gen build.node.bench build.node.go build.node.sharp build.bench diff --git a/cmd/config/main.go b/cmd/config/main.go index 386767b..ce1eef9 100644 --- a/cmd/config/main.go +++ b/cmd/config/main.go @@ -190,7 +190,7 @@ func generateSharpConfig(templatePath, storageEngine, suffix string) error { return nil } -func writeJSON(path string, obj interface{}) error { +func writeJSON(path string, obj any) error { bytes, err := json.Marshal(obj) if err != nil { return err diff --git a/cmd/internal/client.go b/cmd/internal/client.go index 2b296c8..864f648 100644 --- a/cmd/internal/client.go +++ b/cmd/internal/client.go @@ -166,7 +166,7 @@ func (c *RPCClient) GetBlockCount(ctx context.Context) (int, error) { return num, c.doRPCCall(ctx, rpc, &num, c.blockRequester) } -func (c *RPCClient) doRPCCall(_ context.Context, call string, result interface{}, client *fasthttp.Client) error { +func (c *RPCClient) doRPCCall(_ context.Context, call string, result any, client *fasthttp.Client) error { idx := c.inc.Add(1) % c.len req, res := fasthttp.AcquireRequest(), fasthttp.AcquireResponse()