Skip to content

Commit 764cc23

Browse files
Add tangled workflows and switch to mise
1 parent fcd1215 commit 764cc23

7 files changed

Lines changed: 176 additions & 219 deletions

File tree

.golangci.yml

Lines changed: 54 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -11,64 +11,57 @@ formatters:
1111
extra-rules: true
1212

1313
golines:
14-
max-len: 140
14+
max-len: 120
1515

1616
linters:
1717
default: all
1818
disable:
19-
- decorder # Don't care about this
20-
- dupl # Basically every table driven test ever triggers this
21-
- dupword # Messes with test cases more often than not
22-
- err113 # Out of date
23-
- exhaustruct # No
24-
- forbidigo # Nothing to forbid
25-
- funlen # Bad metric for complexity
26-
- ginkgolinter # I don't use whatever this is
27-
- gochecknoglobals # Globals are fine sometimes, use common sense
28-
- gocyclo # cyclop does this instead
29-
- godox # "todo" and "fixme" comments are allowed
30-
- goheader # No need
31-
- gosmopolitan # No need
32-
- grouper # Imports take care of themselves, rest is common sense
33-
- ireturn # This is just not necessary or practical in a real codebase
34-
- lll # Auto formatters do this and what they can't do I don't care about
35-
- maintidx # This is just the inverse of complexity... which is cyclop
36-
- nestif # cyclop does this
37-
- nlreturn # Similar to wsl, I think best left to judgement
38-
- noinlineerr # Inline errors are fine
39-
- nonamedreturns # Named returns are often helpful, it's naked returns that are the issue
40-
- paralleltest # I've never had Go tests take longer than a few seconds, it's fine
41-
- thelper # Everything in here is a helper basically
42-
- unparam # gopls is better and more subtle
43-
- varnamelen # Lots of false positives of things that are fine
44-
- wrapcheck # Not every error must be wrapped
45-
- wsl # Very aggressive, some of this I like but tend to do anyway
46-
- mnd # Magic numbers are fine, context makes them clear
19+
- cyclop # gocognit is the single complexity linter, cognitive beats cyclomatic
20+
- decorder # Don't care about this
21+
- err113 # Not everything needs this
22+
- exhaustruct # This is just a bad idea
23+
- forbidigo # Nothing to forbid
24+
- funlen # Bad metric for complexity
25+
- goconst # Got significantly more annoying recently
26+
- gocyclo # Prefer cognitive complexity over naive metrics
27+
- godox # "todo" and "fixme" comments are allowed
28+
- gomodguard # Deprecated
29+
- ireturn # AST is full of interfaces we need to return (e.g. Expression)
30+
- lll # Auto formatters do this and what they can't do I don't care about
31+
- maintidx # Prefer cognitive
32+
- mnd # Annoying and too sensitive
33+
- nestif # Nesting depth is the dominant factor in gocognit's score already
34+
- noinlineerr # Inline errors are fine
35+
- nonamedreturns # Named returns are often helpful documentation, it's naked returns that are the issue
36+
- paralleltest # I've never had Go tests take longer than a few seconds, it's fine
37+
- unparam # gopls is better and more subtle
38+
- varnamelen # Lots of false positives of things that are fine
39+
- wrapcheck # Not every error must be wrapped
40+
- wsl # Deprecated
4741

4842
exclusions:
4943
presets:
5044
# See https://golangci-lint.run/usage/false-positives/#exclusion-presets
51-
- comments # Revive in particular has lots of false positives
52-
- std-error-handling
5345
- common-false-positives
46+
- std-error-handling
5447
rules:
5548
- path: _test\.go
5649
linters:
57-
- prealloc # These kinds of optimisations will make no difference to test code
58-
- gosec # Tests don't need security stuff
59-
- goconst # Nah
60-
61-
# test.ErrorAs returns the matched error for optional chained assertions;
62-
# discarding it is a supported pattern. errcheck's exclude-functions
63-
# doesn't currently match generic instantiations, so match by source instead.
50+
- dupl # Common false positives with table driven tests
51+
- dupword # Messes with test cases more often than not
52+
- gochecknoglobals # Flags and env vars
53+
- goconst # Sometimes repetition is okay in tests
54+
- gosec # Tests don't need security stuff
55+
- prealloc # These kinds of optimisations will make no difference to test code
56+
- thelper # Everything in here could be consider a "helper", this is noisy
57+
58+
# test.ErrorAs returns the matched error for optional chained assertions
59+
# discarding it is a supported pattern
6460
- source: 'test\.ErrorAs\['
6561
linters:
6662
- errcheck
6763

6864
settings:
69-
cyclop:
70-
max-complexity: 20
71-
7265
depguard:
7366
rules:
7467
main:
@@ -80,100 +73,50 @@ linters:
8073
desc: use math/rand/v2 instead
8174

8275
errcheck:
83-
check-type-assertions: true
8476
check-blank: true
77+
check-type-assertions: true
8578

8679
exhaustive:
8780
check:
88-
- switch
8981
- map
82+
- switch
9083
default-signifies-exhaustive: true
9184

92-
staticcheck:
93-
checks:
94-
- all
95-
9685
gosec:
9786
excludes:
98-
- G104 # Errors not checked, handled by errcheck
87+
- G104 # Errors not checked, handled by errcheck
9988

10089
govet:
10190
enable-all: true
10291

10392
nakedret:
104-
max-func-lines: 0 # Disallow any naked returns
93+
max-func-lines: 0 # Disallow any naked returns
10594

10695
nolintlint:
10796
allow-unused: false
10897
require-explanation: true
10998
require-specific: true
11099

100+
revive:
101+
# every other revive rule overlaps one or more of the other
102+
# linters. These are the ones nothing else covers.
103+
enable-all-rules: false
104+
rules:
105+
- name: context-as-argument # ctx must be the first parameter
106+
- name: deep-exit # os.Exit / log.Fatal outside main and init
107+
- name: modifies-parameter # don't mutate value parameters
108+
- name: modifies-value-receiver # value receiver mutations are lost
109+
- name: unexported-return # exported func returning an unexported type
110+
111+
staticcheck:
112+
checks:
113+
- all
114+
111115
usetesting:
112116
context-background: true
113117
context-todo: true
114118
os-chdir: true
119+
os-create-temp: true
115120
os-mkdir-temp: true
116121
os-setenv: true
117-
os-create-temp: true
118122
os-temp-dir: true
119-
120-
revive:
121-
max-open-files: 256
122-
enable-all-rules: true
123-
rules:
124-
- name: add-constant
125-
disabled: true # goconst does this
126-
127-
- name: argument-limit
128-
arguments:
129-
- 5
130-
131-
- name: cognitive-complexity
132-
disabled: true # gocognit does this
133-
134-
- name: comment-spacings
135-
arguments:
136-
- "nolint:"
137-
138-
- name: cyclomatic
139-
disabled: true # cyclop does this
140-
141-
- name: exported
142-
arguments:
143-
- checkPrivateReceivers
144-
- checkPublicInterface
145-
146-
- name: function-length
147-
disabled: true # Bad proxy for complexity
148-
149-
- name: function-result-limit
150-
arguments:
151-
- 3
152-
153-
- name: import-shadowing
154-
disabled: true # predeclared does this
155-
156-
- name: line-length-limit
157-
disabled: true # gofmt/golines handles this well enough
158-
159-
- name: max-public-structs
160-
disabled: true # This is a dumb rule
161-
162-
- name: redefines-builtin-id
163-
disabled: true # predeclared does this
164-
165-
- name: unhandled-error
166-
arguments:
167-
- fmt\.(Fp|P)rint(ln|f)?
168-
- strings.Builder.Write(String|Byte)?
169-
- bytes.Buffer.Write(String|Byte)?
170-
- go/printer.(Fp|P)rint(ln|f)?
171-
172-
- name: flag-parameter
173-
disabled: true # As far as I can work out this just doesn't like bools
174-
175-
- name: unused-parameter
176-
disabled: true # The gopls unused analyzer covers this better
177-
178-
- name: unused-receiver
179-
disabled: true # As above

.tangled/workflows/Lint.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
when:
2+
- event: [push]
3+
branch: [main]
4+
- event: [pull_request]
5+
branch: [main]
6+
7+
engine: nixery
8+
9+
dependencies:
10+
nixpkgs/nixpkgs-unstable:
11+
- go
12+
- golangci-lint
13+
14+
steps:
15+
- name: Format
16+
command: golangci-lint fmt ./... --diff-colored
17+
18+
- name: Lint
19+
command: golangci-lint run ./...

.tangled/workflows/Test.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
when:
2+
- event: [push]
3+
branch: [main]
4+
- event: [pull_request]
5+
branch: [main]
6+
7+
engine: nixery
8+
9+
dependencies:
10+
nixpkgs/nixpkgs-unstable:
11+
- go
12+
nixpkgs:
13+
- gcc # Needed for CGO_ENABLED=1 (go test -race)
14+
15+
steps:
16+
- name: Test
17+
environment:
18+
CGO_ENABLED: "1"
19+
command: go test -race ./...

Taskfile.yml

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

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ require (
1010
require (
1111
go.followtheprocess.codes/diff v0.2.0
1212
go.yaml.in/yaml/v4 v4.0.0-rc.4 // indirect
13-
golang.org/x/sys v0.45.0 // indirect
14-
golang.org/x/term v0.43.0 // indirect
13+
golang.org/x/sys v0.46.0 // indirect
14+
golang.org/x/term v0.44.0 // indirect
1515
)

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ go.followtheprocess.codes/snapshot v0.10.1 h1:GWNOdDxGtRiw0HVKnidhCHI0ymmZaaiHAA
66
go.followtheprocess.codes/snapshot v0.10.1/go.mod h1:vCkJeHMLa4mOP451SrA9m+Ym5tumx66hXm318jAwf5Y=
77
go.yaml.in/yaml/v4 v4.0.0-rc.4 h1:UP4+v6fFrBIb1l934bDl//mmnoIZEDK0idg1+AIvX5U=
88
go.yaml.in/yaml/v4 v4.0.0-rc.4/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfPPfY0=
9-
golang.org/x/sys v0.45.0 h1:dO4czNzziLiiXplLQgBCEpCvXQ3dnkn0SdaZSYdQ+FY=
10-
golang.org/x/sys v0.45.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
11-
golang.org/x/term v0.43.0 h1:S4RLU2sB31O/NCl+zFN9Aru9A/Cq2aqKpTZJ6B+DwT4=
12-
golang.org/x/term v0.43.0/go.mod h1:lrhlHNdQJHO+1qVYiHfFKVuVioJIheAc3fBSMFYEIsk=
9+
golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw=
10+
golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
11+
golang.org/x/term v0.44.0 h1:0rLvDRCtNj0gZkyIXhCyOb2OAzEhLVqc4B+hrsBhrmc=
12+
golang.org/x/term v0.44.0/go.mod h1:7ze4MdzUzLXpSAoFP1H0bOI9aXDqveSvatT5vKcFh2Y=
1313
golang.org/x/tools v0.44.0 h1:UP4ajHPIcuMjT1GqzDWRlalUEoY+uzoZKnhOjbIPD2c=
1414
golang.org/x/tools v0.44.0/go.mod h1:KA0AfVErSdxRZIsOVipbv3rQhVXTnlU6UhKxHd1seDI=

0 commit comments

Comments
 (0)