From 1d75e3ec1499c4767add22a81e5356c6283e63c8 Mon Sep 17 00:00:00 2001 From: Jordan Krage Date: Tue, 18 Jun 2024 08:34:50 -0500 Subject: [PATCH] bump golangci-lint to v1.59.1 (#13598) --- .github/actions/golangci-lint/action.yml | 2 +- .github/workflows/integration-tests.yml | 2 +- .golangci.yml | 6 ++++-- .tool-versions | 2 +- GNUmakefile | 2 +- core/utils/deferable_write_closer_test.go | 7 ++++--- core/web/bridge_types_controller_test.go | 2 +- core/web/evm_transfer_controller_test.go | 2 +- integration-tests/.golangci.yml | 4 ++-- integration-tests/.tool-versions | 2 +- integration-tests/actions/seth/actions.go | 2 +- integration-tests/actions/seth/keeper_helpers.go | 2 +- integration-tests/contracts/contract_deployer.go | 12 ++++++------ 13 files changed, 25 insertions(+), 22 deletions(-) diff --git a/.github/actions/golangci-lint/action.yml b/.github/actions/golangci-lint/action.yml index d3758bca9e0..f3697ed7195 100644 --- a/.github/actions/golangci-lint/action.yml +++ b/.github/actions/golangci-lint/action.yml @@ -53,7 +53,7 @@ runs: - name: golangci-lint uses: golangci/golangci-lint-action@3cfe3a4abbb849e10058ce4af15d205b6da42804 # v4.0.0 with: - version: v1.55.2 + version: v1.59.1 # We already cache these directories in setup-go skip-pkg-cache: true skip-build-cache: true diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 56d3a959871..82a5381d63c 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -166,7 +166,7 @@ jobs: - name: Lint Go uses: golangci/golangci-lint-action@3cfe3a4abbb849e10058ce4af15d205b6da42804 # v4.0.0 with: - version: v1.55.2 + version: v1.59.1 # We already cache these directories in setup-go skip-pkg-cache: true skip-build-cache: true diff --git a/.golangci.yml b/.golangci.yml index 19121c3d476..4f66d59ec2a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -16,6 +16,8 @@ linters: - depguard - whitespace - containedctx + - fatcontext + - mirror linters-settings: exhaustive: default-signifies-exhaustive: true @@ -31,8 +33,8 @@ linters-settings: # - G304 # - G404 govet: - # report about shadowed variables - check-shadowing: true + enable: + - shadow settings: printf: # Additionally check chainlink custom loggers diff --git a/.tool-versions b/.tool-versions index ebf563134eb..365218c5648 100644 --- a/.tool-versions +++ b/.tool-versions @@ -5,5 +5,5 @@ pnpm 8.15.8 postgres 15.1 helm 3.10.3 zig 0.11.0 -golangci-lint 1.55.2 +golangci-lint 1.59.1 protoc 25.1 diff --git a/GNUmakefile b/GNUmakefile index 329a038b783..b09e0ee3cc7 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -158,7 +158,7 @@ config-docs: ## Generate core node configuration documentation .PHONY: golangci-lint golangci-lint: ## Run golangci-lint for all issues. [ -d "./golangci-lint" ] || mkdir ./golangci-lint && \ - docker run --rm -v $(shell pwd):/app -w /app golangci/golangci-lint:v1.56.2 golangci-lint run --max-issues-per-linter 0 --max-same-issues 0 > ./golangci-lint/$(shell date +%Y-%m-%d_%H:%M:%S).txt + docker run --rm -v $(shell pwd):/app -w /app golangci/golangci-lint:v1.59.1 golangci-lint run --max-issues-per-linter 0 --max-same-issues 0 > ./golangci-lint/$(shell date +%Y-%m-%d_%H:%M:%S).txt GORELEASER_CONFIG ?= .goreleaser.yaml diff --git a/core/utils/deferable_write_closer_test.go b/core/utils/deferable_write_closer_test.go index ef03acf9d66..18d08bd80c2 100644 --- a/core/utils/deferable_write_closer_test.go +++ b/core/utils/deferable_write_closer_test.go @@ -1,6 +1,7 @@ package utils import ( + "io" "os" "path/filepath" "testing" @@ -16,7 +17,7 @@ func TestDeferableWriteCloser_Close(t *testing.T) { wc := NewDeferableWriteCloser(f) wantStr := "wanted" - _, err = wc.Write([]byte(wantStr)) + _, err = io.WriteString(wc, wantStr) assert.NoError(t, err) defer func() { assert.NoError(t, wc.Close()) @@ -27,10 +28,10 @@ func TestDeferableWriteCloser_Close(t *testing.T) { // safe to close multiple times assert.NoError(t, wc.Close()) - _, err = f.Write([]byte("after close")) + _, err = io.WriteString(f, "after close") assert.ErrorIs(t, err, os.ErrClosed) - _, err = wc.Write([]byte("write to wc after close")) + _, err = io.WriteString(f, "write to wc after close") assert.ErrorIs(t, err, os.ErrClosed) r, err := os.ReadFile(f.Name()) diff --git a/core/web/bridge_types_controller_test.go b/core/web/bridge_types_controller_test.go index e964114e7e6..d425d821567 100644 --- a/core/web/bridge_types_controller_test.go +++ b/core/web/bridge_types_controller_test.go @@ -258,7 +258,7 @@ func TestBridgeTypesController_Update_Success(t *testing.T) { require.NoError(t, app.BridgeORM().CreateBridgeType(ctx, bt)) body := fmt.Sprintf(`{"name": "%s","url":"http://yourbridge"}`, bridgeName) - ud := bytes.NewBuffer([]byte(body)) + ud := bytes.NewBufferString(body) resp, cleanup := client.Patch("/v2/bridge_types/"+bridgeName, ud) t.Cleanup(cleanup) cltest.AssertServerResponse(t, resp, http.StatusOK) diff --git a/core/web/evm_transfer_controller_test.go b/core/web/evm_transfer_controller_test.go index fff30a7df31..ccb2f0774ca 100644 --- a/core/web/evm_transfer_controller_test.go +++ b/core/web/evm_transfer_controller_test.go @@ -268,7 +268,7 @@ func TestTransfersController_JSONBindingError(t *testing.T) { client := app.NewHTTPClient(nil) - resp, cleanup := client.Post("/v2/transfers", bytes.NewBuffer([]byte(`{"address":""}`))) + resp, cleanup := client.Post("/v2/transfers", bytes.NewBufferString(`{"address":""}`)) t.Cleanup(cleanup) cltest.AssertServerResponse(t, resp, http.StatusBadRequest) diff --git a/integration-tests/.golangci.yml b/integration-tests/.golangci.yml index d22b26b8260..897c72d1ecb 100644 --- a/integration-tests/.golangci.yml +++ b/integration-tests/.golangci.yml @@ -21,8 +21,8 @@ linters-settings: excludes: - G101 govet: - # report about shadowed variables - check-shadowing: true + enable: + - shadow revive: confidence: 0.8 rules: diff --git a/integration-tests/.tool-versions b/integration-tests/.tool-versions index 6381da7eaf9..7b9e8ab6bf4 100644 --- a/integration-tests/.tool-versions +++ b/integration-tests/.tool-versions @@ -2,4 +2,4 @@ golang 1.21.7 k3d 5.4.6 kubectl 1.25.5 nodejs 20.13.1 -golangci-lint 1.55.2 +golangci-lint 1.59.1 diff --git a/integration-tests/actions/seth/actions.go b/integration-tests/actions/seth/actions.go index 68f6df9b49e..719f71002b4 100644 --- a/integration-tests/actions/seth/actions.go +++ b/integration-tests/actions/seth/actions.go @@ -919,7 +919,7 @@ func SendLinkFundsToDeploymentAddresses( return nil } -var noOpSethConfigFn = func(cfg *seth.Config) error { return nil } +var noOpSethConfigFn = func(_ *seth.Config) error { return nil } type SethConfigFunction = func(*seth.Config) error diff --git a/integration-tests/actions/seth/keeper_helpers.go b/integration-tests/actions/seth/keeper_helpers.go index 5e91d639d42..09b23e5f8f6 100644 --- a/integration-tests/actions/seth/keeper_helpers.go +++ b/integration-tests/actions/seth/keeper_helpers.go @@ -346,7 +346,7 @@ func DeployKeeperConsumers(t *testing.T, client *seth.Client, numberOfContracts executor := ctf_concurrency.NewConcurrentExecutor[contracts.KeeperConsumer, keeperConsumerResult, ctf_concurrency.NoTaskType](l) - var deployContractFn = func(channel chan keeperConsumerResult, errorCh chan error, executorNum int) { + var deployContractFn = func(channel chan keeperConsumerResult, _ chan error, executorNum int) { keyNum := executorNum + 1 // key 0 is the root key var keeperConsumerInstance contracts.KeeperConsumer var err error diff --git a/integration-tests/contracts/contract_deployer.go b/integration-tests/contracts/contract_deployer.go index 99198aa6352..dab50e7aab5 100644 --- a/integration-tests/contracts/contract_deployer.go +++ b/integration-tests/contracts/contract_deployer.go @@ -1257,7 +1257,7 @@ func (e *EthereumContractDeployer) DeployKeeperRegistry( registryLogicAAddr, _, _, err := e.client.DeployContract("AutomationRegistryLogicA2_2", func( auth *bind.TransactOpts, - backend bind.ContractBackend, + _ bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { return registrylogica22.DeployAutomationRegistryLogicA( @@ -1275,7 +1275,7 @@ func (e *EthereumContractDeployer) DeployKeeperRegistry( address, _, _, err := e.client.DeployContract("AutomationRegistry2_2", func( auth *bind.TransactOpts, - backend bind.ContractBackend, + _ bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { return registry22.DeployAutomationRegistry( auth, @@ -1460,7 +1460,7 @@ func (e *EthereumContractDeployer) DeployKeeperConsumer(updateInterval *big.Int) func (e *EthereumContractDeployer) DeployAutomationLogTriggerConsumer(testInterval *big.Int) (KeeperConsumer, error) { address, _, instance, err := e.client.DeployContract("LogUpkeepCounter", func( auth *bind.TransactOpts, - backend bind.ContractBackend, + _ bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { return log_upkeep_counter_wrapper.DeployLogUpkeepCounter( auth, wrappers.MustNewWrappedContractBackend(e.client, nil), testInterval, @@ -1498,7 +1498,7 @@ func (e *EthereumContractDeployer) DeployAutomationSimpleLogTriggerConsumer(isSt func (e *EthereumContractDeployer) DeployAutomationStreamsLookupUpkeepConsumer(testRange *big.Int, interval *big.Int, useArbBlock bool, staging bool, verify bool) (KeeperConsumer, error) { address, _, instance, err := e.client.DeployContract("StreamsLookupUpkeep", func( auth *bind.TransactOpts, - backend bind.ContractBackend, + _ bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { return streams_lookup_upkeep_wrapper.DeployStreamsLookupUpkeep( auth, wrappers.MustNewWrappedContractBackend(e.client, nil), testRange, interval, useArbBlock, staging, verify, @@ -1517,7 +1517,7 @@ func (e *EthereumContractDeployer) DeployAutomationStreamsLookupUpkeepConsumer(t func (e *EthereumContractDeployer) DeployAutomationLogTriggeredStreamsLookupUpkeepConsumer() (KeeperConsumer, error) { address, _, instance, err := e.client.DeployContract("LogTriggeredStreamsLookupUpkeep", func( auth *bind.TransactOpts, - backend bind.ContractBackend, + _ bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { return log_triggered_streams_lookup_wrapper.DeployLogTriggeredStreamsLookup( auth, wrappers.MustNewWrappedContractBackend(e.client, nil), false, false, false, @@ -1536,7 +1536,7 @@ func (e *EthereumContractDeployer) DeployAutomationLogTriggeredStreamsLookupUpke func (e *EthereumContractDeployer) DeployUpkeepCounter(testRange *big.Int, interval *big.Int) (UpkeepCounter, error) { address, _, instance, err := e.client.DeployContract("UpkeepCounter", func( auth *bind.TransactOpts, - backend bind.ContractBackend, + _ bind.ContractBackend, ) (common.Address, *types.Transaction, interface{}, error) { return upkeep_counter_wrapper.DeployUpkeepCounter(auth, wrappers.MustNewWrappedContractBackend(e.client, nil), testRange, interval) })