-
Notifications
You must be signed in to change notification settings - Fork 0
/
.golangci.yaml
1051 lines (1047 loc) · 39.7 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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# This file contains all available configuration options
# with their default values.
# options for analysis running
run:
# The default concurrency value is the number of available CPU.
concurrency: 4
# Timeout for analysis, e.g. 30s, 5m.
# Default: 1m
timeout: 5m
# Exit code when at least one issue was found.
# Default: 1
issues-exit-code: 1
# Include test files or not.
# Default: true
tests: true
# List of build tags, all linters use it.
# Default: [].
build-tags:
- mytag
# Which dirs to skip: issues from them won't be reported.
# Can use regexp here: `generated.*`, regexp is applied on full path.
# Default value is empty list,
# but default dirs are skipped independently of this option's value (see skip-dirs-use-default).
# "/" will be replaced by current OS file path separator to properly work on Windows.
skip-dirs: [ ]
# Enables skipping of directories:
# - vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
# Default: true
skip-dirs-use-default: true
# Which files to skip: they will be analyzed, but issues from them won't be reported.
# Default value is empty list,
# but there is no need to include all autogenerated files,
# we confidently recognize autogenerated files.
# If it's not please let us know.
# "/" will be replaced by current OS file path separator to properly work on Windows.
skip-files: [ ]
# If set we pass it to "go list -mod={option}". From "go help modules":
# If invoked with -mod=readonly, the go command is disallowed from the implicit
# automatic updating of go.mod described above. Instead, it fails when any changes
# to go.mod are needed. This setting is most useful to check that go.mod does
# not need updates, such as in a continuous integration and testing system.
# If invoked with -mod=vendor, the go command assumes that the vendor
# directory holds the correct copies of dependencies and ignores
# the dependency descriptions in go.mod.
#
# Allowed values: readonly|vendor|mod
# By default, it isn't set.
# modules-download-mode:
# Allow multiple parallel golangci-lint instances running.
# If false (default) - golangci-lint acquires file lock on start.
allow-parallel-runners: false
# Define the Go version limit.
# Mainly related to generics support since go1.18.
# Default: use Go version from the go.mod file, fallback on the env var `GOVERSION`, fallback on 1.18
# go: 'GOVERSION'
# output configuration options
output:
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
format: colored-line-number
# print lines of code with issue, default is true
print-issued-lines: true
# print linter name in the end of issue text, default is true
print-linter-name: true
# make issues output unique by line, default is true
uniq-by-line: true
# add a prefix to the output file references; default is no prefix
path-prefix: ""
# Sort results by: filepath, line and column.
sort-results: false
# all available settings of specific linters
linters:
disable-all: true
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- containedctx
- contextcheck
# - cyclop
- decorder
- depguard
- dogsled
# - dupl
- durationcheck
- errchkjson
- errcheck
- errname
- errorlint
- execinquery
- exhaustive
# - exhaustruct
- exportloopref
- forcetypeassert
# - funlen
- gosimple
- govet
- gci
# - gochecknoglobals
- gochecknoinits
# - gocognit
- goconst
# - gocritic
# - gocyclo
- godot
- godox
- goerr113
- gofumpt
- goheader
# - gomnd
- gomoddirectives
- gomodguard
- goprintffuncname
- gosec
- grouper
- ineffassign
- importas
# - ireturn
# - lll
# - maintidx
- makezero
- misspell
- nakedret
# - nestif
- nilerr
- nilnil
- nlreturn
- noctx
# - nolintlint
- nonamedreturns
- nosprintfhostport
# - paralleltest
- prealloc
- predeclared
- promlinter
# - revive
- rowserrcheck
- sqlclosecheck
- stylecheck
- staticcheck
- tagliatelle
- tenv
- testpackage
- thelper
# - tparallel
- typecheck
- unconvert
- unparam
- unused
- varnamelen
- wastedassign
- whitespace
# - wrapcheck
- wsl
presets:
- bugs
- unused
# Run only fast linters from enabled linters set (first run won't be fast)
# Default: false
fast: false
linters-settings:
asasalint:
# to specify a set of function names to exclude
# the values are merged with the builtin exclusions
# the builtin exclusions can be disabled by setting `use-builtin-exclusions` to `false`
# default: ["^(fmt|log|logger|t|)\.(Print|Fprint|Sprint|Fatal|Panic|Error|Warn|Warning|Info|Debug|Log)(|f|ln)$"]
exclude:
- Append
- \.Wrapf
# to enable/disable the asasalint builtin exclusions of function names
# see the default value of `exclude` to get the builtin exclusions, true by default
use-builtin-exclusions: true
# ignore *_test.go files, false by default
ignore-test: true
bidichk:
# the following configurations check for all mentioned invisible unicode runes.
# all runes are enabled by default.
left-to-right-embedding: true
right-to-left-embedding: true
pop-directional-formatting: true
left-to-right-override: true
right-to-left-override: true
left-to-right-isolate: true
right-to-left-isolate: true
first-strong-isolate: true
pop-directional-isolate: true
cyclop:
# the maximal code complexity to report, 10 by default
max-complexity: 10
# the maximal average package complexity, 0.0 by default
# if it's higher than 0.0 (float) the check is enabled
package-average: 0.0
# should ignore tests, false by default
skip-tests: true
decorder:
# required order of `type`, `const`, `var` and `func` declarations inside a file
# default: types before constants before variables before functions
dec-order:
- type
- const
- var
- func
# if true, order of declarations is not checked at all, true (disabled) by default
disable-dec-order-check: true
# if true, `init` func can be anywhere in file (does not have to be declared before all other functions), true (disabled) by default
disable-init-func-first-check: false
# if true, multiple global `type`, `const` and `var` declarations are allowed, true (disabled) by default
disable-dec-num-check: true
depguard:
# kind of list is passed in
# allowed values: allowlist|denylist, default: denylist
list-type: blacklist
# check the list against standard lib, false by default
include-go-root: false
# a list of packages for the list type specified
# can accept both string prefixes and string glob patterns
# default: []
packages: [ ]
# a list of packages for the list type specifyed
# specify an error message to output when a denied package is used
# default: []
packages-with-error-message: [ ]
# specify rules by which the linter ignores certain files for consideration
# can accept both string prefixes and string glob patterns
# the ! character in front of the rule is a special character
# which signals that the linter should negate the rule
# this allows for more precise control, but it is only available for glob patterns
# default: []
ignore-file-rules: [ ]
# create additional guards that follow the same configuration pattern
# results from all guards are aggregated together
additional-guards: [ ]
# for example
# - list-type: denylist
# include-go-root: false
# packages:
# - github.com/stretchr/testify
# specify rules by which the linter ignores certain files for consideration
# ignore-file-rules:
# - "**/*_test.go"
# - "**/mock/**/*.go"
dogsled:
# checks assignments with too many blank identifiers; 2 by default
max-blank-identifiers: 2
dupl:
# tokens count to trigger issue, 150 by default
threshold: 100
errcheck:
# report about not checking of errors in type assertions: `a := b.(MyStruct)`
# false by default: such cases aren't reported by default
check-type-assertions: true
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`
# false by default: such cases aren't reported by default
check-blank: false
# path to a file containing a list of functions to exclude from checking
# see https://github.com/kisielk/errcheck#excluding-functions for details
disable-default-exclusions: true
# list of functions to exclude from checking, where each entry is a single function to exclude
# see https://github.com/kisielk/errcheck#excluding-functions for details
exclude-functions: [ ]
errchkjson:
# with check-error-free-encoding set to true, errchkjson does warn about errors
# from json encoding functions that are safe to be ignored,
# because they are not possible to happen
#
# if check-error-free-encoding is set to true and errcheck linter is enabled,
# it is recommended to add the following exceptions to prevent from false positives:
#
# linters-settings:
# errcheck:
# exclude-functions:
# - encoding/json.Marshal
# - encoding/json.MarshalIndent
#
# false by default
check-error-free-encoding: false
# issue on struct encoding that doesn't have exported fields, false by default
report-no-exported: false
errorlint:
# check whether fmt.Errorf uses the %w verb for formatting errors
# see the https://github.com/polyfloyd/go-errorlint for caveats, true by default
errorf: true
# check for plain type assertions and type switches, true by default
asserts: true
# check for plain error comparisons, true by default
comparison: true
exhaustive:
# check switch statements in generated files also, false by default
check-generated: false
# indicates that switch statements are to be considered exhaustive if a
# 'default' case is present, even if all enum members aren't listed in the
# switch
default-signifies-exhaustive: false
# enum members matching the supplied regex do not have to be listed in
# switch statements to satisfy exhaustiveness
# default: ""
ignore-enum-members: ""
# consider enums only in package scopes, not in inner scopes, false by default
package-scope-only: false
funlen:
# checks the number of lines in a function.
# if lower than 0, disable the check, 60 by default
lines: 100
# checks the number of statements in a function.
# if lower than 0, disable the check, 40 by default
statements: 50
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`,
# if `custom-order` is `true`, it follows the order of `sections` option
# custom section: groups all imports with the specified Prefix
# blank section: contains all blank imports. This section is not present unless explicitly enabled
# dot section: contains all dot imports. This section is not present unless explicitly enabled
# 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/dataphos)
# skip generated files, true by default
skip-generated: true
# enable custom order of sections
# if `true`, make the section order the same as the order of `sections`, false by default
custom-order: false
gocognit:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 15
goconst:
# minimal length of string constant, 3 by default
min-len: 3
# minimal occurrences count to trigger, 3 by default
min-occurrences: 3
# ignore test files, false by default
ignore-tests: true
# look for existing constants matching the values, true by default
match-constant: true
# search also for duplicated numbers, false by default
numbers: false
# minimum value, only works with goconst.numbers, 3 by default
min: 3
# maximum value, only works with goconst.numbers, 3 by default
max: 3
# ignore when constant is not used as function argument, true by default
ignore-calls: true
gocritic:
# which checks should be enabled; can't be combined with 'disabled-checks'
# see https://go-critic.github.io/overview#checks-overview
# to check which checks are enabled run `GL_DEBUG=gocritic golangci-lint run`
# by default, list of stable checks is used
enabled-checks:
- nestingReduce
- unnamedResult
- ruleguard
- truncateCmp
# which checks should be disabled; can't be combined with 'enabled-checks'
# default: []
disabled-checks: [ ]
# enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks
# see https://github.com/go-critic/go-critic#usage -> section "Tags"
# default: []
enabled-tags: [ ]
disabled-tags: [ ]
# settings passed to gocritic.
# the settings key is the name of a supported gocritic checker.
# the list of supported checkers can be find in https://go-critic.github.io/overview.
settings:
# must be valid enabled check name.
nestingReduce:
# min number of statements inside a branch to trigger a warning, 5 by default
bodyWidth: 5
# whether to check test functions, true by default
# skipTestFuncs: true
ruleguard:
# enable debug to identify which 'Where' condition was rejected
# the value of the parameter is the name of a function in a ruleguard file
#
# when a rule is evaluated:
# If:
# the Match() clause is accepted; and
# one of the conditions in the Where() clause is rejected,
# Then:
# ruleguard prints the specific Where() condition that was rejected
#
# The flag is passed to the ruleguard 'debug-group' argument
# Default: ""
debug: ""
# determines the behavior when an error occurs while parsing ruleguard files
# if flag is not set, log error and skip rule files that contain an error
# if flag is set, the value must be a comma-separated list of error conditions
# - 'all': fail on all errors
# - 'import': ruleguard rule imports a package that cannot be found
# - 'dsl': gorule file does not comply with the ruleguard DSL
# default: ""
failOn: ""
# comma-separated list of file paths containing ruleguard rules
# if a path is relative, it is relative to the directory where the golangci-lint command is executed
# the special '${configDir}' variable is substituted with the absolute directory containing the golangci config file
# glob patterns such as 'rules-*.go' may be specified
# default: ""
rules: ""
# comma-separated list of enabled groups or skip empty to enable everything
# tags can be defined with # character prefix
# default: "<all>"
enable: "<all>"
# comma-separated list of disabled groups or skip empty to enable everything
# tags can be defined with # character prefix
# default: ""
disable: ""
truncateCmp:
# whether to skip int/uint/uintptr types, true by deafult
skipArchDependent: true
unnamedResult:
# whether to check exported functions, false by default
checkExported: false
gocyclo:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 10
godot:
# check all top-level comments, not only declarations
check-all: true
godox:
# report any comments starting with keywords, this is useful for TODO or FIXME comments that
# might be left in the code accidentally and should be resolved before merging
keywords: # default keywords are TODO, BUG, and FIXME, these can be overwritten by this setting
- NOTE
- OPTIMIZE # marks code that should be optimized before merging
- HACK # marks hack-arounds that should be removed before merging
gofmt:
# Simplify code: gofmt with `-s` option.
# Default: true
simplify: true
# Apply the rewrite rules to the source before reformatting.
# https://pkg.go.dev/cmd/gofmt
# Default: []
rewrite-rules: [ ]
gofumpt:
# module path which contains the source code being formatted
# default: ""
module-path: ""
# choose whether to use the extra rules
# false by default
extra-rules: false
goheader:
# supports two types 'const` and `regexp`
# values can be used recursively
# default: {}
values: { }
# the template use for checking
# default: ""
template: ""
# ss alternative of directive 'template', you may put the path to file with the template source
# useful if you need to load the template from a specific file
# default: ""
template-path: ""
goimports:
# put imports beginning with prefix after 3rd-party packages
# it's a comma-separated list of prefixes
# default: ""
local-prefixes: ""
gomnd:
# list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description
# default: ["argument", "case", "condition", "operation", "return", "assign"]
checks: [ argument,case,condition,operation,return,assign ]
# list of numbers to exclude from analysis
# the numbers should be written as string
# values always ignored: "1", "1.0", "0" and "0.0"
# default: []
ignored-numbers: [ ]
# list of file patterns to exclude from analysis
# values always ignored: `.+_test.go`
# default: []
ignored-files: [ ]
# list of function patterns to exclude from analysis
# values always ignored: `time.Date`
# default: []
ignored-functions: [ ]
gomoddirectives:
# allow local `replace` directives.
# false by default
replace-local: false
# list of allowed `replace` directives.
# default: []
replace-allow-list: [ ]
# allow to not explain why the version has been retracted in the `retract` directives.
# false by default
retract-allow-no-explanation: false
# forbid the use of the `exclude` directives.
# false by default
exclude-forbidden: false
gomodguard:
allowed:
# list of allowed modules
# default: []
modules: [ ]
# list of allowed module domains
# default: []
domains: [ ]
blocked:
# list of blocked modules
# default: []
modules:
# blocked module
- github.com/uudashr/go-module:
# recommended modules that should be used instead. (Optional)
recommendations:
- golang.org/x/mod
# reason why the recommended module should be used. (Optional)
reason: "`mod` is the official go.mod parser library."
# list of blocked module version constraints
# default: []
versions: [ ]
# set to true to raise lint issues for packages that are loaded from a local path via replace directive
# false by default
local_replace_directives: false
gosimple:
# https://staticcheck.io/docs/configuration/options/#checks
# default: ["*"]
checks: [ "*" ]
gosec:
# to select a subset of rules to run.
# available rules: https://github.com/securego/gosec#available-rules
# default: [] - means include all rules
includes: [ ]
# to specify a set of rules to explicitly exclude.
# available rules: https://github.com/securego/gosec#available-rules
# default: []
excludes: [ ]
# exclude generated files
# false by default
exclude-generated: false
# filter out the issues with a lower severity than the given value
# valid options are: low, medium, high.
# low by default
severity: low
# filter out the issues with a lower confidence than the given value
# valid options are: low, medium, high.
# low by default
confidence: low
# concurrency value.
# default: the number of logical CPUs usable by the current process
concurrency: 12
# to specify the configuration of rules
config:
# globals are applicable to all rules
global:
# if true, ignore #nosec in comments (and an alternative as well)
# false by default
nosec: false
# add an alternative comment prefix to #nosec (both will work at the same time)
# default: ""
"#nosec": ""
# define whether nosec issues are counted as finding or not
# default: false
show-ignored: false
# audit mode enables addition checks that for normal code analysis might be too nosy
# default: false
audit: false
G101:
# regexp pattern for variables and constants to find
# default: "(?i)passwd|pass|password|pwd|secret|token|pw|apiKey|bearer|cred"
pattern: "(?i)passwd|pass|password|pwd|secret|token|pw|apiKey|bearer|cred"
# if true, complain about all cases (even with low entropy)
# false by default
ignore_entropy: false
# maximum allowed entropy of the string
# "80.0" by default
entropy_threshold: "80.0"
# maximum allowed value of entropy/string length
# is taken into account if entropy >= entropy_threshold/2
# "3.0" by default
per_char_threshold: "3.0"
# calculate entropy for first N chars of the string
# "16" by default
truncate: "16"
# additional functions to ignore while checking unhandled errors
# following functions always ignored:
# bytes.Buffer:
# - Write
# - WriteByte
# - WriteRune
# - WriteString
# fmt:
# - Print
# - Printf
# - Println
# - Fprint
# - Fprintf
# - Fprintln
# strings.Builder:
# - Write
# - WriteByte
# - WriteRune
# - WriteString
# io.PipeWriter:
# - CloseWithError
# hash.Hash:
# - Write
# os:
# - Unsetenv
# default: {}
G104: { }
G111:
# Regexp pattern to find potential directory traversal.
# Default: "http\\.Dir\\(\"\\/\"\\)|http\\.Dir\\('\\/'\\)"
pattern: "http\\.Dir\\(\"\\/\"\\)|http\\.Dir\\('\\/'\\)"
# maximum allowed permissions mode for os.Mkdir and os.MkdirAll
# "0750" by default
G301: "0750"
# maximum allowed permissions mode for os.OpenFile and os.Chmod
# "0600" by default
G302: "0600"
# maximum allowed permissions mode for os.WriteFile and ioutil.WriteFile
# "0600" by default
G306: "0600"
govet:
# report about shadowed variables.
# false by default
check-shadowing: false
# settings per analyzer.
# settings:
# analyzer name, run `go tool vet help` to see all analyzers
# printf:
# comma-separated list of print function names to check (in addition to default, see `go tool vet help printf`)
# default: []
# funcs: []
# shadow:
# Whether to be strict about shadowing; can be noisy
# false by default
# strict: false
# unusedresult:
# comma-separated list of functions whose results must be used
# (in addition to defaults context.WithCancel,context.WithDeadline,context.WithTimeout,context.WithValue,
# errors.New,fmt.Errorf,fmt.Sprint,fmt.Sprintf,sort.Reverse)
# default: []
# funcs: []
# comma-separated list of names of methods of type func() string whose results must be used
# (in addition to default Error,String)
# default: []
# stringmethods: []
# disable all analyzers
# false by default
disable-all: true
# enable analyzers by name (in addition to default)
# run `go tool vet help` to see all analyzers
# default: []
enable: [ ]
# enable all analyzers
# false by default
enable-all: false
# disable analyzers by name
# run `go tool vet help` to see all analyzers
# default: []
disable: [ ]
importas:
# so not allow unaliased imports of aliased packages, false by default
no-unaliased: false
# so not allow non-required aliases, false by default
no-extra-aliases: false
# list of aliases, default: []
alias: [ ]
interfacebloat:
# the maximum number of methods allowed for an interface
# 10 by default
max: 10
lll:
# max line length, lines longer will be reported, 120 by default
# '\t' is counted as 1 character by default, and can be changed with the tab-width option
line-length: 130
# tab width in spaces, 1 by default
tab-width: 2
maintidx:
# show functions with maintainability index lower than N
# a high index indicates better maintainability (it's kind of the opposite of complexity)
# 20 by default
under: 20
makezero:
# allow only slices initialized with a length of zero
# false by default
always: false
misspell:
# correct spellings using locale preferences for US or UK
# setting locale to US will correct the British spelling of 'colour' to 'color'
# default is to use a neutral variety of English.
locale: US
# default: []
ignore-words: [ ]
nakedret:
# make an issue if func has more lines of code than this setting, and it has naked returns
# 30 by default
max-func-lines: 30
nestif:
# minimal complexity of if statements to report, 5 by default
min-complexity: 4
nilnil:
# checks that there is no simultaneous return of `nil` error and an invalid value
# default: ["ptr", "func", "iface", "map", "chan"]
checked-types:
- ptr
- func
- iface
- map
- chan
nolintlint:
# enable to ensure that nolint directives are all used. Default is true.
allow-unused: false
# disable to ensure that nolint directives don't have a leading space, true by default
allow-leading-space: true
# exclude following linters from requiring an explanation. Default is [].
allow-no-explanation: [ ]
# enable to require an explanation of nonzero length after each nolint directive, false by default
require-explanation: true
# enable to require nolint directives to mention the specific linter being suppressed, false by default
require-specific: true
nonamedreturns:
# report named error if it is assigned inside defer
# false by default
report-error-in-defer: false
prealloc:
# IMPORTANT: we don't recommend using this linter before doing performance profiling
# for most programs usage of prealloc will be a premature optimization
# report pre-allocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them, true by default
simple: true
# report pre-allocation suggestions on range loops, true by default
range-loops: true
# Report pre-allocation suggestions on for loops, false by default
for-loops: false
promlinter:
# promlinter cannot infer all metrics name in static analysis
# enable strict mode will also include the errors caused by failing to parse the args
# false by default
strict: false
# please refer to https://github.com/yeya24/promlinter#usage for detailed usage
# default: []
disabled-linters: [ ]
reassign:
# patterns for global variable names that are checked for reassignment
# see https://github.com/curioswitch/go-reassign#usage
# default: ["EOF", "Err.*"]
patterns: [ "EOF", "Err.*" ]
revive:
# maximum number of open files at the same time
# see https://github.com/mgechev/revive#command-line-flags
# defaults to unlimited.
max-open-files: 2048
# when set to false, ignores files with "GENERATED" header, similar to golint
# see https://github.com/mgechev/revive#available-rules for details
# false by default
ignore-generated-header: false
# sets the default severity.
# see https://github.com/mgechev/revive#configuration
# warning by default
severity: warning
# enable all available rules
# default: false
enable-all-rules: false
# sets the default failure confidence
# this means that linting errors with less than 0.8 confidence will be ignored
# 0.8 by default
confidence: 0.8
rules:
- name: atomic
- name: blank-imports
- name: bool-literal-in-expr
- name: call-to-gc
- name: constant-logical-expr
- name: context-as-argument
- name: context-keys-type
- name: defer
- name: dot-imports
- name: duplicated-imports
- name: early-return
- name: empty-block
- name: empty-lines
- name: error-naming
- name: error-return
- name: error-strings
- name: errorf
- name: get-return
- name: identical-branches
- name: if-return
- name: increment-decrement
- name: indent-error-flow
- name: optimize-operands-order
- name: package-comments
- name: range
- name: range-val-in-closure
- name: receiver-naming
- name: string-of-int
- name: struct-tag
- name: superfluous-else
- name: time-equal
- name: time-naming
- name: var-declaration
- name: unconditional-recursion
- name: unexported-naming
- name: unexported-return
- name: unnecessary-stmt
- name: unreachable-code
- name: unused-parameter
- name: unused-receiver
- name: useless-break
- name: waitgroup-by-value
rowserrcheck:
# database/sql is always checked
# default: []
packages: [ ]
staticcheck:
# https://staticcheck.io/docs/configuration/options/#checks
# default: ["*"]
checks: [ "*" ]
stylecheck:
# https://staticcheck.io/docs/configuration/options/#checks
# default: ["*"]
checks: [ "*" ]
# https://staticcheck.io/docs/configuration/options/#dot_import_whitelist
# default: ["github.com/mmcloughlin/avo/build", "github.com/mmcloughlin/avo/operand", "github.com/mmcloughlin/avo/reg"]
dot-import-whitelist: [ ]
# https://staticcheck.io/docs/configuration/options/#initialisms
# default: ["ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "QPS", "RAM", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "GID", "UID", "UUID", "URI", "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS", "SIP", "RTP", "AMQP", "DB", "TS"]
initialisms: [ "ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "QPS", "RAM", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "GID", "UID", "UUID", "URI", "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS", "SIP", "RTP", "AMQP", "DB", "TS" ]
# https://staticcheck.io/docs/configuration/options/#http_status_code_whitelist
# default: ["200", "400", "404", "500"]
http-status-code-whitelist: [ "200", "400", "404", "500" ]
tagliatelle:
# check the struck tag name case.
case:
# use the struct field name to check the name of the struct tag
# false by default
use-field-name: false
# `camel` is used for `json` and `yaml` (can be overridden)
# default: {}
rules: { }
tenv:
# the option `all` will run against whole test files (`_test.go`) regardless of method/function signatures
# otherwise, only methods that take `*testing.T`, `*testing.B`, and `testing.TB` as arguments are checked
# false by default
all: false
thelper:
test:
# check *testing.T is first param (or after context.Context) of helper function
# true by default
first: true
# check *testing.T param has name t
# true by default
name: true
# check t.Helper() begins helper function
# true by default
begin: true
benchmark:
# check *testing.B is first param (or after context.Context) of helper function
# true by default
first: true
# check *testing.B param has name b
# true by default
name: true
# check b.Helper() begins helper function
# true by default
begin: true
tb:
# check *testing.TB is first param (or after context.Context) of helper function
# true by default
first: true
# check *testing.TB param has name tb
# true by default
name: true
# check tb.Helper() begins helper function
# true by default
begin: true
fuzz:
# check *testing.F is first param (or after context.Context) of helper function
# true by default
first: true
# check *testing.F param has name f
# true by default
name: true
# check f.Helper() begins helper function
# true by default
begin: true
usestdlibvars:
# suggest the use of http.MethodXX
# true by default
http-method: true
# suggest the use of http.StatusXX
# true by default
http-status-code: true
# suggest the use of time.Weekday
# true by default
time-weekday: true
# suggest the use of time.Month
# false by default
time-month: false
# suggest the use of time.Layout
# false by default
time-layout: false
# suggest the use of crypto.Hash
# false by default
crypto-hash: false
# suggest the use of rpc.DefaultXXPath
# false by default
default-rpc-path: false
unparam:
# inspect exported functions.
#
# set to true if no external program/library imports your code.
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
# if it's called for subdir of a project it can't find external interfaces. All text editor integrations
# with golangci-lint call it on a directory with the changed file
#
# false by default
check-exported: false
varnamelen:
# the longest distance, in source lines, that is being considered a "small scope".
# variables used in at most this many lines will be ignored
# 5 by default
max-distance: 5
# the minimum length of a variable's name that is considered "long"
# variable names that are at least this long will be ignored
# 3 by default
min-name-length: 3
# check method receivers
# false by default
check-receiver: false
# check named return values
# false by default
check-return: false
# check type parameters
# false by default
check-type-param: false
# ignore "ok" variables that hold the bool return value of a type assertion
# false by default
ignore-type-assert-ok: false
# Ignore "ok" variables that hold the bool return value of a map index
# false by default
ignore-map-index-ok: false
# ignore "ok" variables that hold the bool return value of a channel receive
# false by default
ignore-chan-recv-ok: false
# optional list of variable names that should be ignored completely
# default: []
ignore-names: [ ]
# optional list of variable declarations that should be ignored completely
# entries must be in one of the following forms (see below for examples):
# - for variables, parameters, named return values, method receivers, or type parameters:
# <name> <type> (<type> can also be a pointer/slice/map/chan/...)
# - for constants: const <name>
#
# default: []
ignore-decls: [ ]
wsl:
# if true append is only allowed to be cuddled if appending value is
# matching variables, fields or types online above, true by default
strict-append: true
# allow calls and assignments to be cuddled as long as the lines have any
# matching variables, fields or types, true by default
allow-assign-and-call: true
# allow multiline assignments to be cuddled, true by default
allow-multiline-assign: true
# allow declarations (var) to be cuddled
allow-cuddle-declarations: false
# allow trailing comments in ending of blocks
allow-trailing-comment: false
# force newlines in end of case at this limit (0 = never)
force-case-trailing-whitespace: 0
# force cuddling of err checks with err var assignment
force-err-cuddling: false
# allow leading comments to be separated with empty liens
allow-separated-leading-comment: false
wrapcheck:
# an array of strings that specify substrings of signatures to ignore
# if this set, it will override the default set of ignored signatures
# see https://github.com/tomarrell/wrapcheck#configuration for more information
# default: [".Errorf(", "errors.New(", "errors.Unwrap(", ".Wrap(", ".Wrapf(", ".WithMessage(", ".WithMessagef(", ".WithStack("]
ignoreSigs:
- .Errorf(
- errors.New(
- errors.Unwrap(
- .Wrap(
- .Wrapf(
- .WithMessage(
- .WithMessagef(
- .WithStack(
# an array of strings that specify regular expressions of signatures to ignore
# default: []
ignoreSigRegexps: [ ]
# an array of strings that specify globs of packages to ignore
# default: []
ignorePackageGlobs: [ ]
# an array of strings that specify regular expressions of interfaces to ignore
# default: []
ignoreInterfaceRegexps: [ ]
# the custom section can be used to define linter plugins to be loaded at runtime
# see README documentation for more info
issues:
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
- path: _test\.go