Skip to content

Commit 6b6a0df

Browse files
committed
Add golangi-lint config
Adds a configuration file for golangci-lint based from the config in stacklok/minder Signed-off-by: Adolfo García Veytia (Puerco) <[email protected]>
1 parent 10d5797 commit 6b6a0df

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed

.golangci.yaml

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
run:
2+
issues-exit-code: 1
3+
timeout: 5m
4+
5+
linters-settings:
6+
lll:
7+
line-length: 130
8+
gocyclo:
9+
min-complexity: 15
10+
gci:
11+
sections:
12+
- standard
13+
- default
14+
- prefix(github.com/stacklok/trusty-sdk-go)
15+
revive:
16+
# see https://github.com/mgechev/revive#available-rules for details.
17+
ignore-generated-header: true
18+
severity: warning
19+
errorCode: 0
20+
warningCode: 0
21+
rules:
22+
- name: blank-imports
23+
severity: warning
24+
- name: context-as-argument
25+
- name: context-keys-type
26+
- name: duplicated-imports
27+
- name: error-naming
28+
# - name: error-strings #BDG: This was enabled for months, but it suddenly started working on 3/2/2022.. come to find out we have TONS of error messages starting with capital... disabling for now(ever?)
29+
- name: error-return
30+
- name: exported
31+
severity: error
32+
- name: if-return
33+
# - name: get-return // BDG: We have a lot of API endpoint handlers named like getFoos but write to response vs return... maybe later can figure that out
34+
- name: identical-branches
35+
- name: indent-error-flow
36+
- name: import-shadowing
37+
- name: package-comments
38+
# NOTE: range-val-address and range-val-in-closure are irrelevant in Go 1.22 and later
39+
- name: redefines-builtin-id
40+
- name: struct-tag
41+
- name: unconditional-recursion
42+
- name: unnecessary-stmt
43+
- name: unreachable-code
44+
- name: unused-parameter
45+
- name: unused-receiver
46+
- name: unhandled-error
47+
disabled: true
48+
gosec:
49+
excludes:
50+
- G114 # for the moment we need to use listenandserve that has no support for timeouts
51+
- G404 # use unsafe random generator until logic change is discussed
52+
- G307 # Deferring unsafe method "Close" on type "io.ReadCloser"
53+
- G601 # Irrelevant for Go 1.22 and later, see: https://github.com/securego/gosec/issues/1099
54+
55+
depguard:
56+
rules:
57+
prevent_unmaintained_packages:
58+
list-mode: lax # allow unless explicitely denied
59+
files:
60+
- $all
61+
- "!$test"
62+
deny:
63+
- pkg: io/ioutil
64+
desc: "this is deprecated"
65+
66+
linters:
67+
disable-all: true
68+
enable:
69+
- lll
70+
- exhaustive
71+
- depguard
72+
- goconst
73+
- gocyclo
74+
- gofmt
75+
- gosec
76+
- gci
77+
- unparam
78+
- gosimple
79+
- govet
80+
- ineffassign
81+
- paralleltest
82+
- promlinter
83+
- revive
84+
- staticcheck
85+
- unused
86+
- thelper
87+
- tparallel
88+
89+
issues:
90+
exclude-use-default: false
91+
exclude-rules:
92+
- path: '(.+)_test\.go'
93+
linters:
94+
- lll
95+
96+
output:
97+
formats:
98+
- format: colored-line-number
99+
print-issued-lines: true
100+
print-linter-name: true
101+
sort-results: true

0 commit comments

Comments
 (0)