Skip to content

Commit c4de94c

Browse files
committed
Update .golangci.yml to use version 2
The config file was migrated using `golangci-lint migrate`, and then edited by hand to disable a few checks that we don't want.
1 parent 92093ce commit c4de94c

File tree

2 files changed

+92
-32
lines changed

2 files changed

+92
-32
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,9 @@ jobs:
169169
with:
170170
go-version: 1.24.x
171171
- name: Lint
172-
uses: golangci/golangci-lint-action@v6.5.0
172+
uses: golangci/golangci-lint-action@v8
173173
with:
174-
version: v1.64.6
174+
version: v2.2.1
175175
- name: errors
176176
run: golangci-lint run
177177
if: ${{ failure() }}

.golangci.yml

Lines changed: 90 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,96 @@
1+
version: "2"
2+
run:
3+
go: "1.24"
14
linters:
25
enable:
3-
- gofumpt
4-
- thelper
5-
- goimports
6-
- tparallel
7-
- wastedassign
8-
- unparam
9-
- prealloc
10-
- unconvert
6+
- copyloopvar
117
- exhaustive
128
- makezero
139
- nakedret
14-
- copyloopvar
15-
fast: false
16-
17-
linters-settings:
18-
copyloopvar:
19-
# Check all assigning the loop variable to another variable.
20-
# Default: false
21-
# If true, an assignment like `a := x` will be detected as an error.
22-
check-alias: true
23-
exhaustive:
24-
default-signifies-exhaustive: true
25-
staticcheck:
26-
# SA1019 is for checking that we're not using fields marked as deprecated
27-
# in a comment. It decides this in a loose way so I'm silencing it. Also because
28-
# it's tripping on our own structs.
29-
checks: ["all", "-SA1019"]
30-
nakedret:
31-
# the gods will judge me but I just don't like naked returns at all
32-
max-func-lines: 0
10+
- prealloc
11+
- thelper
12+
- tparallel
13+
- unconvert
14+
- unparam
15+
- wastedassign
16+
settings:
17+
copyloopvar:
18+
check-alias: true
19+
exhaustive:
20+
default-signifies-exhaustive: true
21+
nakedret:
22+
# the gods will judge me but I just don't like naked returns at all
23+
max-func-lines: 0
24+
staticcheck:
25+
checks:
26+
- all
3327

34-
run:
35-
go: "1.24"
36-
timeout: 10m
28+
# SA1019 is for checking that we're not using fields marked as
29+
# deprecated in a comment. It decides this in a loose way so I'm
30+
# silencing it. Also because it's tripping on our own structs.
31+
- -SA1019
32+
33+
# ST1003 complains about names like remoteUrl or itemId (should be
34+
# remoteURL and itemID). While I like these suggestions, it also
35+
# complains about enum constants that are all caps, and we use these and
36+
# I like them, and also about camelCase identifiers that contain an
37+
# underscore, which we also use in a few places. Since it can't be
38+
# configured to ignore specific cases, and I don't want to use nolint
39+
# comments in the code, we have to disable it altogether.
40+
- -ST1003 # Poorly chosen identifier
41+
42+
# Probably a good idea, but we first have to review our error reporting
43+
# strategy to be able to use it everywhere.
44+
- -ST1005 # Error strings should not be capitalized
45+
46+
# Many of our classes use self as a receiver name, and we think that's fine.
47+
- -ST1006 # Use of self or this as receiver name
48+
49+
# De Morgan's law suggests to replace `!(a && b)` with `!a || !b`; but
50+
# sometimes I find one more readable than the other, so I want to decide
51+
# that myself.
52+
- -QF1001 # De Morgan's law
53+
54+
# QF1003 is about using a tagged switch instead of an if-else chain. In
55+
# many cases this is a useful suggestion; however, sometimes the change
56+
# is only possible by adding a default case to the switch (when there
57+
# was no `else` block in the original code), in which case I don't find
58+
# it to be an improvement.
59+
- -QF1003 # Could replace with tagged switch
60+
61+
# We need to review our use of embedded fields. I suspect that in some
62+
# cases the fix is not to remove the selector for the embedded field,
63+
# but to turn the embedded field into a named field.
64+
- -QF1008 # Could remove embedded field from selector
65+
66+
# The following checks are all disabled by default in golangci-lint, but
67+
# we disable them again explicitly here to make it easier to keep this
68+
# list in sync with the gopls config in .vscode/settings.json.
69+
- -ST1000, # At least one file in a package should have a package comment
70+
- -ST1020, # The documentation of an exported function should start with the function's name
71+
- -ST1021, # The documentation of an exported type should start with type's name
72+
- -ST1022, # The documentation of an exported variable or constant should start with variable's name
73+
74+
dot-import-whitelist:
75+
- github.com/jesseduffield/lazygit/pkg/integration/components
76+
exclusions:
77+
generated: lax
78+
presets:
79+
- comments
80+
- common-false-positives
81+
- legacy
82+
- std-error-handling
83+
paths:
84+
- third_party$
85+
- builtin$
86+
- examples$
87+
formatters:
88+
enable:
89+
- gofumpt
90+
- goimports
91+
exclusions:
92+
generated: lax
93+
paths:
94+
- third_party$
95+
- builtin$
96+
- examples$

0 commit comments

Comments
 (0)