-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy path.golangci.yml
More file actions
120 lines (118 loc) · 5.39 KB
/
.golangci.yml
File metadata and controls
120 lines (118 loc) · 5.39 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
# 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:
- bodyclose # checks whether HTTP response body is closed successfully
- dupl # Tool for code clone detection
- goconst # Finds repeated strings that could be replaced by a constant
- 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
- 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
- unconvert # Remove unnecessary type conversions
# - unparam # Reports unused function parameters
settings:
gocritic:
disabled-checks:
- appendAssign
- ifElseChain
- valSwap
gosec:
excludes:
- G115 # integer overflow conversion
# fieldalignment needs special effort to decide or not
# govet:
# enable:
# - fieldalignment
revive:
enable-all-rules: true
rules:
- name: add-constant # avoid magic numbers, picked up by goconst linter
disabled: true
- name: bare-return
disabled: true
- name: cognitive-complexity
disabled: true
- name: comment-spacings # no space between comment delimiter and comment text
disabled: true
- name: confusing-naming # Method differs only be capitalization in same source file
disabled: true
- name: cyclomatic
disabled: true
- name: early-return
disabled: true
- name: enforce-switch-style # switch must have a default case
disabled: true
- name: exported # Exported function and methods should have comments
disabled: true
- name: empty-lines # extra empty line at start of a block
disabled: true
- name: error-strings # errors strings should not be capitalized or end with punctuation or a newline
disabled: true
- name: flag-parameter # parameter seems to be a control flag, avoid control coupling
disabled: true
- name: identical-switch-branches
disabled: true
- name: indent-error-flow # if block ends with a return statement, so drop this else and outdent its block # if block ends with a return statement, so drop this else and outdent its block # if block ends with a return statement, so drop this else and outdent its block # if block ends with a return statement, so drop this else and outdent its block
disabled: true
- name: line-length-limit
disabled: true
- name: max-public-structs
disabled: true
- name: receiver-naming # receiver name should be consistent across methods
disabled: true
- name: redefines-builtin-id # redefinition of the built-in function
disabled: true
- name: unchecked-type-assertion
disabled: true
- name: unhandled-error
disabled: true
- name: unnecessary-format # unnecessary use of formatting function "fmt.Errorf", you can replace with errors.New
disabled: true
- name: unused-parameter # parameter seems to be unused, consider removeing or renaming it as _
disabled: true
- name: unused-receiver # method receiver is not referenced in method's body, consider removing or renaming as _
disabled: true
- name: use-any # 'interface{}' can be replaced by any
disabled: true
- name: use-errors-new # replace fmt.Errorf by errors.New
disabled: true
- name: var-declaration # omit type or default value in a variable delcaration
disabled: true
staticcheck:
checks:
- all # enable all before turning off selected
# disable some checks
- -ST1005 # errors strings should not be capitalized
- -ST1020 # comment on exported method FuncName should be of form FuncName ...
- -ST1021 # comment on exported type Foo should be of form Foo ...
- -ST1022 # comment on exported var Foo should be of form Foo ...
- -ST1016 # methods on the same type should have same receiver name
- -ST1023 # should omit type from declartion, it will be inferred from right hand side
- -QF1011 # could omit type from declaration, it will be inferred from right hand side
exclusions:
generated: strict
rules:
- linters:
# Disable goconst in test files, often we have duplicated strings across tests, but don't make sense as constants.
- goconst
- prealloc
path: (_test.*\.go)
- linters:
- govet
path: (_test.*\.go)
text: fieldalignment # detect Go structs that would take less memory if their fields were sorted
formatters:
enable:
- goimports
exclusions:
generated: strict