Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit 84ab0d7

Browse files
authored
chore: update golangci-lint configuration (#344)
1 parent 75ef1bc commit 84ab0d7

File tree

2 files changed

+115
-56
lines changed

2 files changed

+115
-56
lines changed

.github/workflows/test.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,44 @@ jobs:
66
runs-on: ubuntu-20.04
77
steps:
88
- uses: actions/checkout@v2
9+
910
- uses: actions/cache@v2
1011
with:
1112
path: ~/go/pkg/mod
1213
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
1314
restore-keys: |
1415
${{ runner.os }}-go-
16+
1517
- name: fmt
1618
uses: ./ci/image
1719
with:
1820
args: make -j fmt
21+
1922
- run: ./ci/scripts/files_changed.sh
23+
2024
lint:
2125
runs-on: ubuntu-20.04
2226
steps:
2327
- uses: actions/checkout@v2
28+
2429
- name: golangci-lint
2530
uses: golangci/golangci-lint-action@v2.5.2
2631
with:
2732
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
28-
version: v1.36
33+
version: v1.39
34+
2935
test:
3036
runs-on: ubuntu-20.04
3137
steps:
3238
- uses: actions/checkout@v2
39+
3340
- uses: actions/cache@v2
3441
with:
3542
path: ~/go/pkg/mod
3643
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
3744
restore-keys: |
3845
${{ runner.os }}-go-
46+
3947
- name: test
4048
uses: ./ci/image
4149
env:
@@ -45,18 +53,22 @@ jobs:
4553
CODER_PASSWORD: ${{ secrets.CODER_PASSWORD }}
4654
with:
4755
args: make -j test/coverage
56+
4857
gendocs:
4958
runs-on: ubuntu-20.04
5059
steps:
5160
- uses: actions/checkout@v2
61+
5262
- uses: actions/cache@v2
5363
with:
5464
path: ~/go/pkg/mod
5565
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
5666
restore-keys: |
5767
${{ runner.os }}-go-
68+
5869
- name: generate-docs
5970
uses: ./ci/image
6071
with:
6172
args: make -j gendocs
73+
6274
- run: ./ci/scripts/files_changed.sh

.golangci.yml

Lines changed: 102 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,120 @@
11
# See https://golangci-lint.run/usage/configuration/
22
linters-settings:
3-
goconst:
4-
min-len: 4
5-
min-occurrences: 3
63
gocognit:
74
# tunnel.go has a 150 line function. Someone should fix it and
85
# decrement this back down to a rational number.
96
min-complexity: 52
7+
goconst:
8+
min-len: 4
9+
min-occurrences: 3
1010
nestif:
1111
min-complexity: 10
12-
govet:
13-
settings:
14-
printf:
15-
funcs: # Run `go tool vet help printf` to see available settings for `printf` analyzer.
16-
- (cdr.dev/coder-cli/pkg/clog).Tipf
17-
- (cdr.dev/coder-cli/pkg/clog).Hintf
18-
- (cdr.dev/coder-cli/pkg/clog).Causef
12+
revive:
13+
# see https://github.com/mgechev/revive#available-rules for details.
14+
ignore-generated-header: true
15+
severity: warning
16+
rules:
17+
- name: atomic
18+
# - name: bare-return
19+
- name: blank-imports
20+
- name: bool-literal-in-expr
21+
- name: call-to-gc
22+
- name: confusing-naming
23+
- name: confusing-results
24+
- name: constant-logical-expr
25+
- name: context-as-argument
26+
- name: context-keys-type
27+
# - name: deep-exit
28+
- name: defer
29+
- name: dot-imports
30+
- name: duplicated-imports
31+
# - name: early-return
32+
# - name: empty-block
33+
- name: empty-lines
34+
- name: error-naming
35+
- name: error-return
36+
- name: error-strings
37+
- name: errorf
38+
- name: exported
39+
# - name: flag-parameter
40+
- name: get-return
41+
- name: identical-branches
42+
# - name: if-return
43+
# - name: import-shadowing
44+
- name: increment-decrement
45+
- name: indent-error-flow
46+
- name: modifies-parameter
47+
- name: modifies-value-receiver
48+
- name: package-comments
49+
- name: range
50+
- name: range-val-address
51+
- name: range-val-in-closure
52+
- name: receiver-naming
53+
- name: redefines-builtin-id
54+
- name: string-of-int
55+
- name: struct-tag
56+
- name: superfluous-else
57+
- name: time-naming
58+
- name: unconditional-recursion
59+
- name: unexported-naming
60+
- name: unexported-return
61+
# - name: unhandled-error
62+
- name: unnecessary-stmt
63+
- name: unreachable-code
64+
# - name: unused-parameter
65+
# - name: unused-receiver
66+
# - name: var-declaration
67+
- name: var-naming
68+
- name: waitgroup-by-value
69+
70+
issues:
71+
fix: true
72+
max-issues-per-linter: 0
73+
max-same-issues: 0
74+
75+
run:
76+
timeout: 5m
77+
1978
linters:
2079
disable-all: true
21-
exclude-use-default: false
2280
enable:
23-
- megacheck
24-
- govet
25-
- golint
26-
- goconst
27-
- gocognit
28-
- nestif
29-
- misspell
30-
- unparam
31-
- unused
3281
- bodyclose
3382
- deadcode
34-
- depguard
3583
- dogsled
3684
- errcheck
37-
- unconvert
38-
- unparam
39-
- varcheck
40-
- whitespace
85+
# - errorlint
86+
- exportloopref
87+
# - forcetypeassert
88+
- gocognit
89+
- goconst
90+
- gocritic
91+
- gocyclo
92+
- godot
93+
- gofmt
94+
- goimports
95+
- golint
96+
- gomodguard
97+
- goprintffuncname
98+
# - gosec
99+
- gosimple
100+
- govet
101+
- ineffassign
102+
- makezero
103+
- megacheck
104+
- misspell
105+
- nestif
106+
- noctx
107+
- nolintlint
108+
- revive
109+
- rowserrcheck
110+
- sqlclosecheck
111+
- staticcheck
41112
- structcheck
42113
- stylecheck
43114
- typecheck
44-
- nolintlint
45-
- rowserrcheck
46-
- scopelint
47-
- goprintffuncname
48-
- gofmt
49-
- godot
50-
- ineffassign
51-
- gocritic
52-
53-
issues:
54-
exclude-use-default: false
55-
exclude:
56-
# errcheck: Almost all programs ignore errors on these functions and in most cases it's ok
57-
- Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*printf?|os\.(Un)?Setenv). is not checked
58-
# golint: False positive when tests are defined in package 'test'
59-
- func name will be used as test\.Test.* by other packages, and that stutters; consider calling this
60-
# govet: Common false positives
61-
- (possible misuse of unsafe.Pointer|should have signature)
62-
# staticcheck: Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore
63-
- ineffective break statement. Did you mean to break out of the outer loop
64-
# gosec: Too many false-positives on 'unsafe' usage
65-
- Use of unsafe calls should be audited
66-
# gosec: Too many false-positives for parametrized shell calls
67-
- Subprocess launch(ed with variable|ing should be audited)
68-
# gosec: Duplicated errcheck checks
69-
- G104
70-
# gosec: Too many issues in popular repos
71-
- (Expect directory permissions to be 0750 or less|Expect file permissions to be 0600 or less)
72-
# gosec: False positive is triggered by 'src, err := ioutil.ReadFile(filename)'
73-
- Potential file inclusion via variable
115+
- unconvert
116+
- unparam
117+
- unused
118+
- varcheck
119+
- wastedassign
120+
- whitespace

0 commit comments

Comments
 (0)