-
Notifications
You must be signed in to change notification settings - Fork 144
Expand file tree
/
Copy path.golangci-strict.yml
More file actions
130 lines (127 loc) · 5.67 KB
/
.golangci-strict.yml
File metadata and controls
130 lines (127 loc) · 5.67 KB
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
# Copyright 2025-Present Couchbase, Inc.
#
# Use of this software is governed by the Business Source License included
# in the file licenses/BSL-Couchbase.txt. As of the Change Date specified
# in that file, in accordance with the Business Source License, use of this
# software will be governed by the Apache License, Version 2.0, included in
# the file licenses/APL2.txt.
version: "2"
linters:
enable:
- exhaustive
- gocritic # The most opinionated Go source code linter
#- goprintffuncname # Checks that printf-like functions are named with `f` at the end
#- gosec # Inspects source code for security problems
#- gosimple # (megacheck) Linter for Go source code that specializes in simplifying a code
- govet # (vet, vetshadow) Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
- ineffassign # Detects when assignments to existing variables are not used
- misspell # Finds commonly misspelled English words in comments
#- nakedret # Finds naked returns in functions greater than a specified function length
#- prealloc # Finds slice declarations that could potentially be preallocated
#- revive # Golint differs from gofmt. Gofmt reformats Go source code, whereas golint prints out style mistakes
- staticcheck # (megacheck) Staticcheck is a go vet on steroids, applying a ton of static analysis checks
- unconvert # Remove unnecessary type conversions
#- unparam # Reports unused function parameters
- unused # (megacheck) Checks Go code for unused constants, variables, functions and types
settings:
exhaustive:
check:
- switch
- map
default-signifies-exhaustive: true
explicit-exhaustive-map: true
ignore-enum-members: "(auditdSyncGatewayEndID|levelCount)" # these mark end of an enum
gocritic:
enabled-checks:
- ruleguard
disabled-checks:
- appendAssign
- assignOp
- badCond
- captLocal
- commentFormatting
- deprecatedComment
- elseif
- ifElseChain
- regexpMust
- singleCaseSwitch
- sloppyLen
- unlambda
- valSwap
- wrapperFunc
settings:
ruleguard:
failOn: all
rules: ${base-path}/ruleguard/rules-*.go
staticcheck:
checks:
- all # enable all
# disable some checks until fixed
- -QF1001 # Apply De Morgan's law.
- -QF1003 # could use tagged switch
- -QF1004 # Use 'strings.ReplaceAll' instead of 'strings.Replace' with 'n == -1'.
- -QF1007 # could merge conditional assignment into variable declaration
- -QF1008 # Omit embedded fields from selector expression.
- -QF1010 # Convert slice of bytes to string when printing it.
- -QF1011 # Omit redundant type from variable declaration.
- -QF1012 # Use 'fmt.Fprintf(x, ...)' instead of 'x.Write(fmt.Sprintf(...))'.
- -S1000 # Use plain channel send or receive instead of single-case select.
- -S1002 # Omit comparison with boolean constant.
- -S1005 # unnecssary assignment to the blank identifier
- -S1007 # Simplify regular expression by using raw string literal.
- -S1008 # Simplify returning boolean expression.
- -S1009 # Omit redundant nil check on slices, maps, and channels.
- -S1011 # Use a single 'append' to concatenate two slices.
- -S1012 # Replace 'time.Now().Sub(x)' with 'time.Since(x)'.
- -S1021 # Merge variable declaration and assignment.
- -S1023 # redundant return statement
- -S1024 # Replace 'x.Sub(time.Now())' with 'time.Until(x)'.
- -S1025 # Don't use 'fmt.Sprintf("%s", x)' unnecessarily.
- -S1028 # Simplify error construction with 'fmt.Errorf'.
- -S1030 # Use 'bytes.Buffer.String' or 'bytes.Buffer.Bytes'.
- -S1031 # unnecessary nil check around range
- -S1039 # Unnecessary use of 'fmt.Sprint'.
- -ST1003 # Poorly chosen identifier.
- -ST1005 # errors strings should not end with punctuation or newlines
- -ST1006 # Poorly chosen receiver name.
- -ST1008 # A function's error value should be its last return value.
- -ST1011 # Poorly chosen name for variable of type 'time.Duration'.
- -ST1012 # Poorly chosen name for error variable.
- -ST1016 # methods on the same type should have the same receiver name
- -ST1017 # Don't use Yoda conditions.
- -ST1023 # Redundant type in variable declaration.
exclusions:
generated: strict
rules:
# Disable goconst in test files, often we have duplicated strings across tests, but don't make sense as constants.
- linters:
- goconst
# cover _testing.go (utility testing files) and _test.go files
# base/util_testing.go / rest/utilities_testing\.*.go
path: (_test.*\.go)
- linters:
- unused
path: rest/debug.go
- text: "ST1000:" # at least one file in a package should have a package comment
linters:
- staticcheck
- text: "ST1020:" # comment on exported method should be of the form "MethodName ..."
linters:
- staticcheck
- text: "ST1021:" # comment on exported type should be of the form "TypeName ..."
linters:
- staticcheck
- text: "ST1022:" # comment on exported type should be of the form "TypeName ..."
linters:
- staticcheck
- text: "missing cases in switch"
linters:
- exhaustive
path: (_test.go)
formatters:
enable:
- goimports
exclusions:
generated: strict
run:
allow-parallel-runners: true