-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.golangci.yaml
141 lines (131 loc) · 4.58 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
run:
concurrency: 4
timeout: 5m
issues-exit-code: 2
tests: false
output:
print-issued-lines: false
print-linter-name: true
uniq-by-line: false
path-prefix: ""
sort-results: true
linters:
disable-all: true
enable:
# Bugs & Errors
- copyloopvar # Detects places where loop variables are copied unnecessarily (in Go 1.22+)
- dupl # Detects duplicate code
- errcheck # Check for unexamined errors
- gosec # Check for security issues
- govet # Check for common Go mistakes
- nilnil # Detects return of nil errors and an invalid value
- paralleltest # Detects missing t.Parallel() calls in tests
- promlinter # Check Prometheus metrics names
- revive # Framework with many sub-linters
- sqlclosecheck # Check that SQL rows/statements are closed
- staticcheck # Subset of checks from the stand-along staticcheck tool
- tparallel # Finds incorrect usage of t.Parallel()
- zerologlint # Check for correct usage of zerolog
# Performance
- gocritic # An opinionated linter to enforce best practices
- prealloc # Find slice declarations that could be preallocated
- perfsprint # Check for usage of fmt.Sprintf that could be implemented with more efficient alternatives
# Style & Formatting
- goconst # Find repeated strings that could be replaced by constants
- gofumpt # Aggressive formatter Go code
- goheader # Check for correct headers in source files
- intrange # Look for loops that could use the Go 1.22+ integer range syntax
- nolintlint # Ensure proper usage of nolint directives
- stylecheck # Check for style issues
- tagliatelle # Check for correct usage formatting of struct tags
linters-settings:
#
# Bugs & Errors
#
dupl:
# Tokens count to trigger issue, Default: 150
threshold: 100
errcheck:
# Report about not checking of errors in type assertions: `a := b.(MyStruct)`.
# Such cases aren't reported by default.
# Default: false
check-type-assertions: true
# For a full list of Revive linters, see https://github.com/mgechev/revive
revive:
rules:
# Check for common mistaken usages of the sync/atomic package
- name: atomic
# Suggests using constant for magic numbers and string literals
- name: add-constant
arguments:
- maxLitCount: "3"
allowStrs: '""'
allowInts: "0,1,2,3"
allowFloats: "0.0,0.,1.0,1.,2.0,2.,3.0,3."
# Warns on malformed comments
- name: comment-spacings
# Warns on methods with names that differ only by capitalization
- name: confusing-naming
# Suggests to name potentially confusing function results
- name: confusing-results
# Warns on constant logical expressions
- name: constant-logical-expr
# context.Context should be the first argument of a function.
- name: context-as-argument
# Disallows the usage of basic types in context.WithValue.
- name: context-keys-type
# Spots potential dataraces
- name: datarace
# Looks for program exits in funcs other than main() or init()
- name: deep-exit
# Naming and commenting conventions on exported symbols.
- name: exported
arguments:
- "checkPrivateReceivers"
- "disableStutteringCheck"
- "checkPublicInterface"
- "disableChecksOnFunctions"
#
# Performance
#
#
# Style & Formatting
#
gofumpt:
# Apply the rewrite rules to the source before reformatting.
# https://github.com/mvdan/gofumpt
# Default: []
rewrite-rules:
- pattern: "interface{}"
replacement: "any"
- pattern: "a[b:len(a)]"
replacement: "a[b:]"
goheader:
template: |-
SPDX-FileCopyrightText: Copyright (c) 2016-2024, CloudZero, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
exclude-dirs:
- pkg/types/mocks
nolintlint:
# Always require //nolint instead of // nolint
require-machine: true
# Always require //nolint:mylinter instead of just //nolint
require-specific: true
# Always require //nolint // my explanation instead of just //nolint
require-explanation: true
tagliatelle:
case:
use-field-name: true
rules:
# Any struct tag type can be used.
# Support string case: `camel`, `pascal`, `kebab`, `snake`, `upperSnake`, `goCamel`, `goPascal`, `goKebab`, `goSnake`, `upper`, `lower`, `header`.
yaml: snake
issues:
exclude-dirs:
- pkg/status
- .go
- .git
exclude-rules:
- path: pkg/types/mocks
linters:
- goheader