-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.golangci.yaml
151 lines (133 loc) · 4.61 KB
/
.golangci.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# Reference: https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml
run:
concurrency: 4
timeout: 10m # Timeout for analysis
issues-exit-code: 2 # Exit code when at least one issue was found.
tests: true # Include test files or not
modules-download-mode: readonly # Don't update the go.mod file
allow-parallel-runners: true
allow-serial-runners: true
go: '1.19'
output:
formats:
- format: colored-line-number
print-issued-lines: false # Print lines of code with issue.
print-linter-name: false # Print linter name in the end of issue text.
sort-results: true # Sort results by the order defined in `sort-order`.
sort-order: # filepath, line, and column.
- linter
- severity
- file
show-stats: true # Show statistics per linter.
linters:
disable-all: true
enable:
# bugs/error
- staticcheck
- revive
- govet
- errcheck
- gosec
- dupl
# performance
- gocritic
- prealloc
# style, formatting
- stylecheck
- staticcheck
- goconst
- gofmt
- tagliatelle
- decorder
- lll
# Code complexity
- cyclop
linters-settings:
# Error check settings
errcheck:
# Report about not checking of errors
check-type-assertions: true # type assertions: `a := b.(MyStruct)`
check-blank: true # `num, _ := strconv.Atoi(numStr)`
# Gofmt settings
gofmt:
simplify: false
rewrite-rules:
- pattern: 'interface{}'
replacement: 'any'
- pattern: 'a[b:len(a)]'
replacement: 'a[b:]'
copyloopvar:
# Linting error to assign a loop variable into another
check-alias: true
# Code complexity settings
cyclop:
# The maximal code complexity to report.
# Default: 10
max-complexity: 10
# The maximal average package complexity.
# If it's higher than 0.0 (float) the check is enabled
# Default: 0.0
package-average: 3.0
# Should ignore tests.
# Default: false
skip-tests: false
# Code organisation
decorder:
# Required order of `type`, `const`, `var` and `func` declarations inside a file.
# Default: types before constants before variables before functions.
dec-order:
- type
- const
- var
- func
ignore-underscore-vars: false # Allow variables with underscore
disable-dec-order-check: false # Disable order of declaration
disable-dec-num-check: false # Multiple declaration of `type`, `var` and `const` not allowed
# Golang security settings
gosec:
# To select a subset of rules to run.
# Available rules: https://github.com/securego/gosec#available-rules
# Default: [] - means include all rules
includes:
- G101 # Look for hard coded credentials
- G102 # Bind to all interfaces
- G103 # Audit the use of unsafe block
- G104 # Audit errors not checked
- G106 # Audit the use of ssh.InsecureIgnoreHostKey
- G107 # Url provided to HTTP request as taint input
- G108 # Profiling endpoint automatically exposed on /debug/pprof
- G109 # Potential Integer overflow made by strconv.Atoi result conversion to int16/32
- G110 # Potential DoS vulnerability via decompression bomb
- G111 # Potential directory traversal
- G112 # Potential slowloris attack
- G113 # Usage of Rat.SetString in math/big with an overflow (CVE-2022-23772)
- G114 # Use of net/http serve function that has no support for setting timeouts
- G201 # SQL query construction using format string
- G202 # SQL query construction using string concatenation
- G203 # Use of unescaped data in HTML templates
- G204 # Audit use of command execution
- G301 # Poor file permissions used when creating a directory
- G302 # Poor file permissions used with chmod
- G303 # Creating tempfile using a predictable path
- G304 # File path provided as taint input
- G305 # File traversal when extracting zip/tar archive
- G306 # Poor file permissions used when writing to a new file
- G307 # Poor file permissions used when creating a file with os.Create
- G401 # Detect the usage of DES, RC4, MD5 or SHA1
- G402 # Look for bad TLS connection settings
- G403 # Ensure minimum RSA key length of 2048 bits
- G404 # Insecure random number source (rand)
- G601 # Implicit memory aliasing of items from a range statement
- G602 # Slice access out of bounds
revive:
# Maximum number of open files at the same time.
# See https://github.com/mgechev/revive#command-line-flags
# Defaults to unlimited.
max-open-files: 2048
lll:
line-length: 120
tab-width: 1
staticcheck:
# SAxxxx checks in https://staticcheck.io/docs/configuration/options/#checks
# Default: ["*"]
checks: ["all"]