-
Notifications
You must be signed in to change notification settings - Fork 56
/
.golangci.yaml
104 lines (93 loc) · 3.89 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
run:
tests: false
issues:
# Show all errors
max-issues-per-linter: 0
max-same-issues: 0
# Exclude sources following the Go generated file convention.
exclude-generated: "strict"
# Add exclusions here.
exclude-rules:
# Licensed under ISC License, with different copyright owners.
- path: version/version\.go
linters: [ "goheader" ]
linters:
enable:
- "asasalint" # Check for pass []any as any in variadic func(...any).
- "bodyclose" # Checks whether HTTP response body is closed successfully.
- "dupword" # Checks for duplicate words in the source code.
- "errcheck" # Checks for unchecked errors.
- "errorlint" # Verifies errors are properly wrapped.
- "errname" # Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error.
- "gci" # Enforces package import order, making it deterministic.
- "gocheckcompilerdirectives" # Checks that go compiler directive comments (//go:) are valid.
- "gochecksumtype" # Run exhaustiveness checks on Go "sum types".
- "gofumpt" # Runs gofumpt.
- "goheader" # Enforces copyright header.
# TODO enable gosec, when bored run 'golangci-lint run -Egosec' to fix these
# - "gosec" # Checks for potential security issues
- "gosimple" # Checks for ways to simplify code.
- "gomoddirectives" # Manages 'replace', 'retract' and 'excludes' directives in go.mod.
- "gosmopolitan" # Report certain i18n/l10n anti-patterns in your Go codebase.
- "govet" # Runs go vet.
- "ineffassign" # Detects when assignments to variables are not used.
# TODO enable revive, when bored run 'golangci-lint run -Erevive' to fix these
# - "revive" # Checks for potential security issues
- "nilerr" # Finds the code that returns nil even if it checks that the error is not nil.
- "nolintlint" # Reports ill-formed or insufficient nolint directives.
- "prealloc" # Finds slice declarations that could potentially be pre-allocated.
- "predeclared" # Find code that shadows one of Go's predeclared identifiers.
- "promlinter" # Check Prometheus metrics naming via promlint.
- "staticcheck" # Runs staticcheck.
- "sqlclosecheck" # Checks that sql.Rows, sql.Stmt, sqlx.NamedStmt, pgx.Query are closed.
- "rowserrcheck" # Checks whether Rows.Err of rows is checked successfully.
- "unconvert" # Checks for unnecessary type conversions.
- "unused" # Checks for unused constants, variables, functions and types.
linters-settings:
# Checks for unchecked errors.
errcheck:
exclude-functions:
- "loggo.ConfigureLoggers(string)"
# Enforces import order in Go source files
gci:
sections:
- "standard"
- "default"
- "blank"
- "dot"
- "localmodule"
custom-order: true
gocritic:
disabled-checks:
- "elseif"
- "exitAfterDefer"
- "ifElseChain"
- "singleCaseSwitch"
# Detects XXX/TODO/FIXME comments. Useful for finding old todo items.
# Use: golangci-lint run --enable-only godox
godox:
keywords:
- "XXX"
- "TODO"
- "FIXME"
# Manages 'replace', 'retract' and 'excludes' directives in go.mod.
gomoddirectives:
replace-allow-list:
- "github.com/coder/websocket" # Currently uses our fork with a bug fix.
# Enforces copyright header
goheader: # TODO: Replace goheader, autofix is too buggy.
values:
const:
COMPANY: "Hemi Labs, Inc."
regexp:
YEAR_RANGE: "(\\d{4}-{{MOD-YEAR}})|({{MOD-YEAR}})"
template: |-
Copyright (c) {{ YEAR_RANGE }} {{ COMPANY }}
Use of this source code is governed by the MIT License,
which can be found in the LICENSE file.
# Lints nolint directives.
nolintlint:
# Require an explanation after each nolint directive.
# Explanation format example: '//nolint:ineffassign // Explanation goes here.'
# If this becomes too annoying, disable it.
require-explanation: true