Skip to content

Commit 4d25847

Browse files
Merge branch 'master' into JonathanOppenheimer/sync-pr-1279-forbidgo
2 parents 6743707 + c576302 commit 4d25847

File tree

8 files changed

+73
-1230
lines changed

8 files changed

+73
-1230
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ jobs:
2222
cache-dependency-path: |
2323
go.sum
2424
tools/go.sum
25-
tools/legacy-golangci-lint.sum
2625
- name: Run all lint checks
2726
run: ./scripts/run_task.sh lint-all-ci
2827
- name: Check go.mod and go.sum are up-to-date

.golangci.yml

Lines changed: 65 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,77 @@
1-
# This file configures github.com/golangci/golangci-lint.
2-
1+
version: "2"
32
run:
4-
timeout: 10m
53
tests: true
64

75
linters:
8-
disable-all: true
6+
default: none
97
enable:
10-
- goimports
11-
- gosimple
8+
- bidichk
9+
- copyloopvar
10+
- durationcheck
11+
- gocheckcompilerdirectives
1212
- govet
1313
- ineffassign
14+
- mirror
1415
- misspell
16+
- reassign
17+
# - revive # only certain checks enabled
18+
- staticcheck
1519
- unconvert
16-
- typecheck
1720
- unused
18-
# - staticcheck
19-
- bidichk
20-
- durationcheck
21-
- copyloopvar
2221
- whitespace
23-
# - revive # only certain checks enabled
24-
- durationcheck
25-
- gocheckcompilerdirectives
26-
- reassign
27-
- mirror
28-
- tenv
22+
settings:
23+
goconst:
24+
min-len: 3 # minimum length of string constant
25+
min-occurrences: 6 # minimum number of occurrences
26+
staticcheck:
27+
checks:
28+
- all
29+
30+
# There's a lot of legacy code that triggers these warnings after upgrading golangci-lint.
31+
# These checks are removed.
32+
- -QF1001 # Apply De Morgan’s law
33+
- -QF1002 # Convert an untagged switch comparing the same variable into a “tagged” switch
34+
- -QF1003 # Convert if / else-if chains comparing the same variable into a tagged switch
35+
- -QF1006 # Lift if + break into loop condition
36+
- -QF1008 # Omit embedded fields from selector expression
37+
- -QF1010 # Convert slice of bytes to string when printing it
38+
- -SA1019 # Use of deprecated identifiers: triggers when you import or use something marked deprecated.
39+
- -SA4009 # A function argument is overwritten before its first use.
40+
- -SA9003 # Empty body in an if or else branch.
41+
- -ST1003 # Poorly chosen identifier.
42+
- -ST1008 # A function’s error value should be its last return value.
43+
- -ST1016 # Use consistent method receiver names (e.g. avoid mixing `s *S`, `s S`, `t *T` in same type).
44+
45+
exclusions:
46+
generated: lax
47+
presets:
48+
- comments
49+
- common-false-positives
50+
- legacy
51+
- std-error-handling
52+
rules:
53+
- linters:
54+
- unused
55+
# Exclude unused geth symbols from ethclient/ethclient.go to simplify upgrading Geth to a newer version.
56+
path: ethclient\/ethclient\.go
57+
text: (type `rpcProgress`|func `\(\*rpcProgress\)\.toSyncProgress`) is unused
58+
- linters:
59+
- goconst
60+
path: (.+)_test\.go
61+
paths:
62+
- third_party$
63+
- builtin$
64+
- examples$
2965

30-
linters-settings:
31-
gofmt:
32-
simplify: true
33-
goconst:
34-
min-len: 3 # minimum length of string constant
35-
min-occurrences: 6 # minimum number of occurrences
36-
ignore-tests: true
66+
formatters:
67+
enable:
68+
- goimports
69+
settings:
70+
gofmt:
71+
simplify: true
72+
exclusions:
73+
generated: lax
74+
paths:
75+
- third_party$
76+
- builtin$
77+
- examples$

Taskfile.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ tasks:
7373
- task: check-clean-branch
7474
- cmd: cd tools && go mod tidy
7575
- task: check-clean-branch
76-
- cmd: cd tools && go mod tidy -modfile=legacy-golangci-lint.mod
77-
- task: check-clean-branch
7876

7977
coverage:
8078
desc: Display test coverage statistics from coverage.out file
@@ -125,6 +123,12 @@ tasks:
125123
- task: check-generate-codec
126124
- task: check-generate-mocks
127125
- task: check-generate-rlp
126+
127+
lint-fix:
128+
desc: Run golangci-lint with auto-fix where possible
129+
# TODO(alarso16): Create a script to run the avalanchego linter as well.
130+
# See https://github.com/ava-labs/coreth/issues/1374
131+
cmd: go tool -modfile=tools/go.mod golangci-lint run --config .golangci.yml --fix
128132

129133
setup-contracts:
130134
desc: Set up contracts by compiling Solidity contracts and generating Go bindings

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module github.com/ava-labs/subnet-evm
77
// - Changes to the minimum golang version must also be replicated in:
88
// - go.mod (here)
99
// - tools/go.mod
10-
// - tools/legacy-golangci-lint.mod
10+
// - RELEASES.md
1111
//
1212
// - If updating between minor versions (e.g. 1.24.x -> 1.25.x):
1313
// - Consider updating the version of golangci-lint (see tools/go.mod)

miner/worker.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,6 @@ func (w *worker) handleResult(env *environment, block *types.Block, createdAt ti
515515
var (
516516
hash = block.Hash()
517517
receipts = make([]*types.Receipt, len(unfinishedReceipts))
518-
logs []*types.Log
519518
)
520519
for i, unfinishedReceipt := range unfinishedReceipts {
521520
receipt := new(types.Receipt)
@@ -536,7 +535,6 @@ func (w *worker) handleResult(env *environment, block *types.Block, createdAt ti
536535
*log = *unfinishedLog
537536
log.BlockHash = hash
538537
}
539-
logs = append(logs, receipt.Logs...)
540538
}
541539

542540
feesInEther, err := core.TotalFeesFloat(block, receipts)

scripts/lint.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,7 @@ function read_dirs {
9494
TESTS=${TESTS:-"golangci_lint avalanche_golangci_lint license_header require_error_is_no_funcs_as_params single_import interface_compliance_nil require_no_error_inline_func import_testing_only_in_tests"}
9595

9696
function test_golangci_lint {
97-
# Since there are 2 versions of golangci-lint in play, and only one
98-
# can be managed by a given go.mod file, we use a separate mod file
99-
# for the older version.
100-
# TODO(marun) Switch everything to v2 when possible
101-
go tool -modfile=tools/legacy-golangci-lint.mod golangci-lint run --config .golangci.yml
97+
go tool -modfile=tools/go.mod golangci-lint run --config .golangci.yml
10298
}
10399

104100
function test_avalanche_golangci_lint {

tools/legacy-golangci-lint.mod

Lines changed: 0 additions & 208 deletions
This file was deleted.

0 commit comments

Comments
 (0)