Skip to content

Commit 4391ff2

Browse files
ldezSeigeC
authored andcommitted
docs: improve configuration documentation (golangci#2514)
1 parent 032c7fd commit 4391ff2

File tree

1 file changed

+95
-35
lines changed

1 file changed

+95
-35
lines changed

.golangci.example.yml

+95-35
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ run:
4747
- ".*\\.my\\.go$"
4848
- lib/bad.go
4949

50-
# By default, it isn't set.
5150
# If set we pass it to "go list -mod={option}". From "go help modules":
5251
# If invoked with -mod=readonly, the go command is disallowed from the implicit
5352
# automatic updating of go.mod described above. Instead, it fails when any changes
@@ -56,7 +55,10 @@ run:
5655
# If invoked with -mod=vendor, the go command assumes that the vendor
5756
# directory holds the correct copies of dependencies and ignores
5857
# the dependency descriptions in go.mod.
59-
modules-download-mode: readonly|vendor|mod
58+
#
59+
# Allowed values: readonly|vendor|mod
60+
# By default, it isn't set.
61+
modules-download-mode: readonly
6062

6163
# Allow multiple parallel golangci-lint instances running.
6264
# If false (default) - golangci-lint acquires file lock on start.
@@ -143,13 +145,26 @@ linters-settings:
143145
disable-dec-num-check: false
144146

145147
depguard:
146-
list-type: denylist
147-
include-go-root: false
148+
# Kind of list is passed in.
149+
# Allowed values: allowlist|denylist
150+
# Default: denylist
151+
list-type: allowlist
152+
153+
# Check the list against standard lib.
154+
# Default: false
155+
include-go-root: true
156+
157+
# A list of packages for the list type specified.
158+
# Default: []
148159
packages:
149160
- github.com/sirupsen/logrus
161+
162+
# A list of packages for the list type specified.
163+
# Specify an error message to output when a denied package is used.
164+
# Default: []
150165
packages-with-error-message:
151-
# Specify an error message to output when a denied package is used.
152166
- github.com/sirupsen/logrus: 'logging is allowed only by logutils.Log'
167+
153168
# Create additional guards that follow the same configuration pattern.
154169
# Results from all guards are aggregated together.
155170
additional-guards:
@@ -226,23 +241,30 @@ linters-settings:
226241
errorlint:
227242
# Check whether fmt.Errorf uses the %w verb for formatting errors.
228243
# See the https://github.com/polyfloyd/go-errorlint for caveats.
229-
errorf: true
244+
# Default: true
245+
errorf: false
230246
# Check for plain type assertions and type switches.
231-
asserts: true
247+
# Default: true
248+
asserts: false
232249
# Check for plain error comparisons.
233-
comparison: true
250+
# Default: true
251+
comparison: false
234252

235253
exhaustive:
236254
# Check switch statements in generated files also.
237-
check-generated: false
255+
# Default: false
256+
check-generated: true
238257
# Presence of "default" case in switch statements satisfies exhaustiveness,
239258
# even if all enum members are not listed.
240-
default-signifies-exhaustive: false
259+
# Default: false
260+
default-signifies-exhaustive: true
241261
# Enum members matching the supplied regex do not have to be listed in
242262
# switch statements to satisfy exhaustiveness.
243-
ignore-enum-members: ""
263+
# Default: ""
264+
ignore-enum-members: "Example.+"
244265
# Consider enums only in package scopes, not in inner scopes.
245-
package-scope-only: false
266+
# Default: false
267+
package-scope-only: true
246268

247269
exhaustivestruct:
248270
# Struct Patterns is list of expressions to match struct packages and names.
@@ -263,8 +285,14 @@ linters-settings:
263285
exclude_godoc_examples: false
264286

265287
funlen:
266-
lines: 60
267-
statements: 40
288+
# Checks the number of lines in a function.
289+
# If lower than 0, disable the check.
290+
# Default: 60
291+
lines: -1
292+
# Checks the number of statements in a function.
293+
# If lower than 0, disable the check.
294+
# Default: 40
295+
statements: -1
268296

269297
gci:
270298
# Put imports beginning with prefix after 3rd-party packages.
@@ -274,7 +302,7 @@ linters-settings:
274302

275303
gocognit:
276304
# Minimal code complexity to report
277-
# Default: 30, (but we recommend 10-20)
305+
# Default: 30 (but we recommend 10-20)
278306
min-complexity: 10
279307

280308
goconst:
@@ -323,9 +351,17 @@ linters-settings:
323351
# See https://github.com/go-critic/go-critic#usage -> section "Tags".
324352
# Default: []
325353
enabled-tags:
354+
- diagnostic
355+
- style
326356
- performance
357+
- experimental
358+
- opinionated
327359
disabled-tags:
360+
- diagnostic
361+
- style
362+
- performance
328363
- experimental
364+
- opinionated
329365

330366
# Settings passed to gocritic.
331367
# The settings key is the name of a supported gocritic checker.
@@ -408,7 +444,7 @@ linters-settings:
408444

409445
gocyclo:
410446
# Minimal code complexity to report.
411-
# Default: 30, (but we recommend 10-20)
447+
# Default: 30 (but we recommend 10-20)
412448
min-complexity: 10
413449

414450
godot:
@@ -444,23 +480,26 @@ linters-settings:
444480
gofumpt:
445481
# Select the Go version to target.
446482
# Default: 1.15
447-
lang-version: "1.15"
483+
lang-version: "1.17"
448484

449485
# Choose whether to use the extra rules.
450486
# Default: false
451487
extra-rules: true
452488

453489
goheader:
490+
# Supports two types 'const` and `regexp`.
491+
# Values can be used recursively.
454492
values:
455493
const:
456494
# Define here const type values in format k:v.
457495
# For example:
458-
# COMPANY: MY COMPANY
496+
COMPANY: MY COMPANY
459497
regexp:
460498
# Define here regexp type values.
461499
# for example:
462-
# AUTHOR: .*@mycompany\.com
463-
template: # |-
500+
AUTHOR: .*@mycompany\.com
501+
# The template use for checking.
502+
template: |-
464503
# Put here copyright header template for source code files
465504
# For example:
466505
# Note: {{ YEAR }} is a builtin value that returns the year relative to the current machine time.
@@ -479,8 +518,9 @@ linters-settings:
479518
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
480519
# See the License for the specific language governing permissions and
481520
# limitations under the License.
482-
template-path:
483-
# Also, as alternative of directive 'template' you may put the path to file with the template source.
521+
# As alternative of directive 'template', you may put the path to file with the template source.
522+
# Useful if you need to load the template from a specific file.
523+
template-path: /path/to/my/template.tmpl
484524

485525
goimports:
486526
# Put imports beginning with prefix after 3rd-party packages.
@@ -575,18 +615,26 @@ linters-settings:
575615
- G401
576616
- G306
577617
- G101
618+
578619
# To specify a set of rules to explicitly exclude.
579620
# Available rules: https://github.com/securego/gosec#available-rules
580621
excludes:
581622
- G204
623+
582624
# Exclude generated files
625+
# Default: false
583626
exclude-generated: true
627+
584628
# Filter out the issues with a lower severity than the given value.
585629
# Valid options are: low, medium, high.
586-
severity: "low"
630+
# Default: low
631+
severity: medium
632+
587633
# Filter out the issues with a lower confidence than the given value.
588634
# Valid options are: low, medium, high.
589-
confidence: "low"
635+
# Default: low
636+
confidence: medium
637+
590638
# To specify the configuration of rules.
591639
# The configuration of rules is not fully documented by gosec:
592640
# https://github.com/securego/gosec#configuration
@@ -730,9 +778,11 @@ linters-settings:
730778
ifshort:
731779
# Maximum length of variable declaration measured in number of lines, after which linter won't suggest using short syntax.
732780
# Has higher priority than max-decl-chars.
733-
max-decl-lines: 1
781+
# Default: 1
782+
max-decl-lines: 2
734783
# Maximum length of variable declaration measured in number of characters, after which linter won't suggest using short syntax.
735-
max-decl-chars: 30
784+
# Default: 30
785+
max-decl-chars: 40
736786

737787
importas:
738788
# Do not allow unaliased imports of aliased packages.
@@ -834,15 +884,16 @@ linters-settings:
834884
nlreturn:
835885
# Size of the block (including return statement that is still "OK")
836886
# so no return split required.
837-
block-size: 1
887+
# Default: 1
888+
block-size: 2
838889

839890
nolintlint:
840891
# Disable to ensure that all nolint directives actually have an effect.
841892
# Default: false
842-
allow-unused: false
893+
allow-unused: true
843894
# Disable to ensure that nolint directives don't have a leading space.
844895
# Default: true
845-
allow-leading-space: true
896+
allow-leading-space: false
846897
# Exclude following linters from requiring an explanation.
847898
# Default: []
848899
allow-no-explanation: [ ]
@@ -869,9 +920,11 @@ linters-settings:
869920

870921
predeclared:
871922
# Comma-separated list of predeclared identifiers to not report on.
872-
ignore: ""
923+
# Default: ""
924+
ignore: "new,int"
873925
# Include method names and field names (i.e., qualified names) in checks.
874-
q: false
926+
# Default: false
927+
q: true
875928

876929
promlinter:
877930
# Promlinter cannot infer all metrics name in static analysis.
@@ -1197,13 +1250,15 @@ linters-settings:
11971250
- github.com/jmoiron/sqlx
11981251

11991252
staticcheck:
1200-
# Select the Go version to target. The default is '1.13'.
1253+
# Select the Go version to target.
1254+
# Default: 1.13
12011255
go: "1.15"
12021256
# https://staticcheck.io/docs/options#checks
12031257
checks: [ "all" ]
12041258

12051259
stylecheck:
1206-
# Select the Go version to target. The default is '1.13'.
1260+
# Select the Go version to target.
1261+
# Default: 1.13
12071262
go: "1.15"
12081263
# https://staticcheck.io/docs/options#checks
12091264
checks: [ "all", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022" ]
@@ -1269,6 +1324,7 @@ linters-settings:
12691324

12701325
varcheck:
12711326
# Check usage of exported fields and variables.
1327+
# Default: false
12721328
exported-fields: true
12731329

12741330
varnamelen:
@@ -1313,9 +1369,11 @@ linters-settings:
13131369

13141370
whitespace:
13151371
# Enforces newlines (or comments) after every multi-line if statement.
1316-
multi-if: false
1372+
# Default: false
1373+
multi-if: true
13171374
# Enforces newlines (or comments) after every multi-line function signature.
1318-
multi-func: false
1375+
# Default: false
1376+
multi-func: true
13191377

13201378
wrapcheck:
13211379
# An array of strings that specify substrings of signatures to ignore.
@@ -1405,6 +1463,7 @@ linters-settings:
14051463
# Optional.
14061464
original-url: github.com/golangci/example-linter
14071465

1466+
14081467
linters:
14091468
# Disable all linters.
14101469
disable-all: true
@@ -1687,6 +1746,7 @@ issues:
16871746
# Fix found issues (if it's supported by the linter).
16881747
fix: true
16891748

1749+
16901750
severity:
16911751
# Set the default severity for issues.
16921752
#

0 commit comments

Comments
 (0)