Skip to content

Commit 5e9e009

Browse files
authored
Merge pull request #8223 from onflow/peter/fix-ci-lint
[CI] update golanglint-ci
2 parents 7e0964b + ac526c5 commit 5e9e009

File tree

4 files changed

+91
-84
lines changed

4 files changed

+91
-84
lines changed

.custom-gcl.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# The version of golangci-lint used to build the custom binary
2-
version: v1.63.4
2+
version: v2.7.1
33

44
# The name of the custom binary
55
name: custom-gcl

.github/workflows/ci.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,12 @@ jobs:
5555
path: tools/custom-gcl # path defined in .custom-gcl.yml
5656
lookup-only: 'true' # if already cached, don't download here
5757
# We install the non-custom golangci-lint binary using the golangci-lint action.
58-
# The action is set up to always install and run the linter - there isn't a way to only install.
59-
# We provide args to disable all linters which results in the step immediately failing.
6058
- name: Install golangci-lint
6159
if: steps.cache-linter.outputs.cache-hit != 'true'
62-
uses: golangci/golangci-lint-action@v6
63-
continue-on-error: true # after installation (what we care about), this step will fail - this line allows workflow to continue
60+
uses: golangci/golangci-lint-action@v9
6461
with:
65-
args: "--no-config --disable-all" # set args so that no linters are actually run
66-
- name: Build custom linter binary
67-
if: steps.cache-linter.outputs.cache-hit != 'true'
68-
run: |
69-
golangci-lint custom
62+
install-only: true
63+
version: v2.7.1
7064

7165
golangci:
7266
strategy:
@@ -112,7 +106,7 @@ jobs:
112106
- name: Add custom linter binary to path
113107
run: echo "$(pwd)/tools" >> $GITHUB_PATH
114108
- name: Run golangci-lint
115-
uses: golangci/golangci-lint-action@v6
109+
uses: golangci/golangci-lint-action@v9
116110
with:
117111
install-mode: 'none' # looks for binary in path rather than downloading
118112
args: "-v"

.golangci.yml

Lines changed: 85 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,90 @@
1-
run:
2-
timeout: 10m
3-
4-
linters-settings:
5-
goimports:
6-
# enforced by linter
7-
# put imports beginning with prefix after 3rd-party packages;
8-
# it's a comma-separated list of prefixes
9-
local-prefixes: github.com/onflow/flow-go/
10-
11-
# used to generate canonical import ordering
12-
# not enforced by linter
13-
gci:
14-
sections:
15-
- standard # 1. standard library
16-
- default # 2. external packages
17-
- prefix(github.com/onflow/) # 3. org packages
18-
- prefix(github.com/onflow/flow-go/) # 4. project packages
19-
skip-generated: true
20-
custom-order: true
21-
22-
gosec:
23-
# To select a subset of rules to run.
24-
# Available rules: https://github.com/securego/gosec#available-rules
25-
includes:
26-
- G401
27-
- G402
28-
- G501
29-
- G502
30-
- G503
31-
- G505
32-
33-
staticcheck:
34-
# Disable SA1019 to allow use of deprecated label
35-
checks: ["all", "-SA1019"]
36-
37-
custom:
38-
structwrite:
39-
type: module
40-
description: "disallow struct field writes outside constructor"
41-
original-url: "github.com/onflow/flow-go/tools/structwrite"
42-
1+
version: "2"
432
linters:
443
enable:
45-
- goimports
464
- gosec
475
- structwrite
6+
settings:
7+
gosec:
8+
includes:
9+
- G401
10+
- G402
11+
- G501
12+
- G502
13+
- G503
14+
- G505
15+
staticcheck:
16+
checks:
17+
- all
18+
- -SA1019
4819

49-
issues:
50-
exclude-rules:
51-
- path: _test\.go # disable some linters on test files
52-
linters:
53-
- unused
54-
- structwrite
55-
- path: 'consensus/hotstuff/helper/*' # disable some linters on test helper files
56-
linters:
57-
- structwrite
58-
- path: 'utils/unittest/*' # disable some linters on test files
59-
linters:
60-
- structwrite
61-
- path: 'consensus/hotstuff/helper/*' # disable some linters on test files
62-
linters:
63-
- structwrite
64-
- path: 'engine/execution/testutil/*' # disable some linters on test files
65-
linters:
66-
- structwrite
67-
# typecheck currently not handling the way we do function inheritance well
68-
# disabling for now
69-
- path: 'cmd/access/node_build/*'
70-
linters:
71-
- typecheck
72-
- path: 'cmd/observer/node_builder/*'
73-
linters:
74-
- typecheck
75-
- path: 'follower/*'
76-
linters:
77-
- typecheck
20+
# TODO: these were added to allow updating to the latest version of the linter.
21+
# Update the code to remove these issues instead of suppressing them.
22+
- -QF1001 # could apply De Morgan's law" were hidden
23+
- -QF1003 # could use tagged switch on chainID (staticcheck)
24+
- -QF1006 # could lift into loop condition (staticcheck)
25+
- -QF1008 # could remove embedded field \"BaseConfig\" from selector" were hidden
26+
- -QF1011 # could omit type flow.IdentifierList from declaration; it will be inferred from the right-hand side" were hidden
27+
- -QF1012 # Use fmt.Fprintf(...) instead of Write([]byte(fmt.Sprintf(...))) (staticcheck)
28+
- -S1021 # should merge variable declaration with assignment on next line (staticcheck)
29+
- -ST1003 # should not use underscores in package names" were hidden
30+
- -ST1005 # error strings should not be capitalized" were hidden
31+
- -ST1006 # receiver name should not be an underscore, omit the name if it is unused (staticcheck)
32+
- -ST1008 # error should be returned as the last argument" were hidden
33+
- -ST1012 # error var factoryError should have name of the form errFoo" were hidden
34+
- -ST1016 # methods on the same type should have the same receiver name (seen 45x "db", 4x "s") (staticcheck)
35+
- -ST1017 # don't use Yoda conditions" were hidden
36+
- -ST1019 # other import of \"github.com/onflow/flow-go/model/bootstrap\"" were hidden
37+
- -ST1023 # should omit type flow.IdentifierList from declaration; it will be inferred from the right-hand side" were hidden
38+
custom:
39+
structwrite:
40+
type: module
41+
description: disallow struct field writes outside constructor
42+
original-url: github.com/onflow/flow-go/tools/structwrite
43+
exclusions:
44+
generated: lax
45+
presets:
46+
- comments
47+
- common-false-positives
48+
- legacy
49+
- std-error-handling
50+
rules:
51+
- linters:
52+
- structwrite
53+
- unused
54+
path: _test\.go
55+
- linters:
56+
- structwrite
57+
path: consensus/hotstuff/helper/*
58+
- linters:
59+
- structwrite
60+
path: utils/unittest/*
61+
- linters:
62+
- structwrite
63+
path: consensus/hotstuff/helper/*
64+
- linters:
65+
- structwrite
66+
path: engine/execution/testutil/*
67+
paths:
68+
- third_party$
69+
- builtin$
70+
- examples$
71+
formatters:
72+
enable:
73+
- goimports
74+
settings:
75+
gci:
76+
sections:
77+
- standard
78+
- default
79+
- prefix(github.com/onflow/)
80+
- prefix(github.com/onflow/flow-go/)
81+
custom-order: true
82+
goimports:
83+
local-prefixes:
84+
- github.com/onflow/flow-go/
85+
exclusions:
86+
generated: lax
87+
paths:
88+
- third_party$
89+
- builtin$
90+
- examples$

state/protocol/datastore/validity.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ func validateClusterQC(cluster protocol.Cluster) error {
176176
// version beacon is invalid
177177
func validateVersionBeacon(snap protocol.Snapshot) error {
178178
errf := func(msg string, args ...any) error {
179-
return protocol.NewInvalidServiceEventErrorf(msg, args)
179+
return protocol.NewInvalidServiceEventErrorf(msg, args...)
180180
}
181181

182182
versionBeacon, err := snap.VersionBeacon()

0 commit comments

Comments
 (0)