forked from mongodb/mongodb-kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.golangci.yml
More file actions
123 lines (122 loc) · 4.62 KB
/
Copy path.golangci.yml
File metadata and controls
123 lines (122 loc) · 4.62 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
---
#########################
#########################
## Golang Linter rules ##
#########################
#########################
# configure golangci-lint
# see https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml
version: "2"
run:
# Number of operating system threads (`GOMAXPROCS`) that can execute golangci-lint simultaneously.
# Default: 0 (automatically set to match Linux container CPU quota and
# fall back to the number of logical CPUs in the machine)
concurrency: 4
# Timeout for total work, e.g. 30s, 5m, 5m30s.
# If the value is lower or equal to 0, the timeout is disabled.
# Default: 0 (disabled)
timeout: 5m
modules-download-mode: mod
go: 1.24
linters:
enable:
- dupl
- errcheck
- forbidigo
- goconst
- gosec
- govet
- ineffassign
- rowserrcheck
- staticcheck
- unconvert
- unused
settings:
forbidigo:
forbid:
- pattern: os\.(Getenv|LookupEnv|Environ|ExpandEnv)
pkg: os
msg: "Reading environment variables here is prohibited. Please read environment variables in the main package."
- pattern: os\.(Clearenv|Unsetenv|Setenv)
pkg: os
msg: "Modifying environment variables is prohibited."
- pattern: env\.(Read.*?|EnsureVar)
pkg: github.com/mongodb/mongodb-kubernetes/pkg/util/env
msg: "Using this env package here is prohibited. Please work with environment variables in the main package."
- p: envvar\.(Read.*?|MergeWithOverride|GetEnvOrDefault)
pkg: github.com/mongodb/mongodb-kubernetes/mongodb-community-operator/pkg/util/envvar
msg: "Using this envvar package here is prohibited. Please work with environment variables in the main package."
# Rules with the `pkg` depend on it
analyze-types: true
staticcheck:
# STxxxx checks in https://staticcheck.io/docs/configuration/options/#checks
# Default: ["*"]
checks:
- all
- -ST1000
- -ST1003
- -ST1020
- -ST1021
- -ST1022
- -ST1023
- -QF1003
exclusions:
# Mode of the generated files analysis.
#
# - `strict`: sources are excluded by strictly following the Go generated file convention.
# Source files that have lines matching only the following regular expression will be excluded: `^// Code generated .* DO NOT EDIT\.$`
# This line must appear before the first non-comment, non-blank text in the file.
# https://go.dev/s/generatedcode
# - `lax`: sources are excluded if they contain lines like `autogenerated file`, `code generated`, `do not edit`, etc.
# - `disable`: disable the generated files exclusion.
#
# Default: lax
generated: lax
presets:
- common-false-positives
- legacy
rules:
- linters:
- dupl
- goconst
- gosec
- errcheck
path: _test\.go
- linters:
- forbidigo
path: ^pkg\/util\/env
- linters:
- forbidigo
path: ^main.go$
- linters:
- forbidigo
path: ^mongodb-community-operator\/pkg\/util\/envvar
- linters:
- forbidigo
path: ^mongodb-community-operator\/cmd\/(readiness|versionhook)\/main\.go$
formatters:
enable:
- gci
- gofmt
- gofumpt
settings:
gci:
# Section configuration to compare against.
# Section names are case-insensitive and may contain parameters in ().
# The default order of sections is `standard > default > custom > blank > dot > alias > localmodule`,
# If `custom-order` is `true`, it follows the order of `sections` option.
# Default: ["standard", "default"]
sections:
- standard # Standard section: captures all standard packages.
- default # Default section: contains all imports that could not be matched to another section type.
- prefix(github.com/mongodb/mongodb-kubernetes) # Custom section: groups all imports with the specified Prefix.
- blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled.
- dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled.
- alias # Alias section: contains all alias imports. This section is not present unless explicitly enabled.
- localmodule # Local module section: contains all local packages. This section is not present unless explicitly enabled.
gofumpt:
# Module path which contains the source code being formatted.
# Default: ""
module-path: github.com/mongodb/mongodb-kubernetes
exclusions:
generated: lax