github.com/GuanceCloud/cliutils@v1.1.21/.golangci.toml (about) 1 [run] 2 timeout = "10m" 3 issues-exit-code = 1 4 skip-files = ["packrd"] 5 go = "1.18" 6 skip-dirs = [ 7 # TODO: we should add lint check on the package 8 "internal/obfuscate", 9 ] 10 11 [linters-settings] 12 13 [linters-settings.govet] 14 check-shadowing = false 15 16 [linters-settings.golint] 17 min-confidence = 0.0 18 19 [linters-settings.gocyclo] 20 min-complexity = 14.0 21 22 [linters-settings.gocognit] 23 min-complexity = 14.0 24 25 [linters-settings.cyclo] 26 min-complexity = 14.0 27 28 [linters-settings.fieldalignment] 29 suggest-new = true 30 31 [linters-settings.goconst] 32 min-len = 3.0 33 min-occurrences = 4.0 34 35 [linters-settings.misspell] 36 locale = "US" 37 38 [linters-settings.funlen] 39 lines = 230 # default 60 40 statements = 150 # default 40 41 42 [linters-settings.forbidigo] 43 forbid = ['^print(ln)?$', '^spew\.Print(f|ln)?$', '^spew\.Dump$'] 44 45 [linters-settings.depguard] 46 list-type = "blacklist" 47 include-go-root = false 48 packages = ["github.com/pkg/errors"] 49 50 [linters-settings.godox] 51 keywords = ["FIXME"] 52 53 [linters-settings.wsl] 54 allow-assign-and-anything = true 55 56 [linters-settings.importas] 57 corev1 = "k8s.io/api/core/v1" 58 networkingv1beta1 = "k8s.io/api/networking/v1beta1" 59 extensionsv1beta1 = "k8s.io/api/extensions/v1beta1" 60 metav1 = "k8s.io/apimachinery/pkg/apis/meta/v1" 61 kubeerror = "k8s.io/apimachinery/pkg/api/errors" 62 63 [linters-settings.gomoddirectives] 64 replace-allow-list = [ 65 "github.com/abbot/go-http-auth", 66 "github.com/go-check/check", 67 "github.com/gorilla/mux", 68 "github.com/mailgun/minheap", 69 "github.com/mailgun/multibuf", 70 ] 71 72 [linters-settings.lll] 73 line-length = 150 74 tab-width = 2 75 76 [linters] 77 enable-all = true 78 disable = [ 79 # 权且放开他们 80 "testpackage", # Too strict 81 "wrapcheck", # 不便于错误处理 82 "tagliatelle", # 跟现有 json tag 命名方式 83 "paralleltest", # 可开启,改动范围较大 84 "noctx", # 要求 HTTP 请求都用 context 形式,改动较大 85 "nlreturn", # 要求 return 语句前有一个空行 86 "gomnd", # 不放过任何一个魔术数 87 "wsl", # 更好代码分段 88 "prealloc", # Too many false-positive. 89 "nestif", # Too many false-positive. 90 "goerr113", # 不能 fmt.Errorf/errors.New 91 "gochecknoglobals", # 不能搞全局变量 92 "exhaustivestruct", # 结构体初始化字段是否完整 93 "golint", # Too strict 94 "interfacer", 95 "scopelint", # obsoluted: https://github.com/kyoh86/scopelint#obsoleted 96 97 98 # 代码太复杂 99 "gocognit", 100 "gocyclo", 101 102 "dupl", # 还不允许有相似代码 103 104 "cyclop", 105 "gomoddirectives", # used `replace' in go.mod 106 "nolintlint", 107 "revive", 108 "exhaustruct", # [升级 Go1.18 后加入] 要求结构体每次务必每个字段都要填 109 "varnamelen", # [升级 Go1.18 后加入] 变量名长度检查 110 "nonamedreturns", # [升级 Go1.18 后加入] 不允许函数有名返回 111 "forcetypeassert", # [升级 Go1.18 后加入] 强制断言检查 112 "gci", # [升级 Go1.18 后加入] Tab 键检查 113 "maintidx", # [升级 Go1.18 后加入] 函数长度检查 114 "containedctx", # [升级 Go1.18 后加入] Go 不推荐把 context 放在结构体中:https://go.dev/blog/context-and-structs 115 "ireturn", # [升级 Go1.18 后加入] 函数 interface 返回检查 116 "contextcheck", # [升级 Go1.18 后加入] 函数参数必须传入 context 117 "errchkjson", # [升级 Go1.18 后加入] json 序列化/反序列化必须检查 118 "nilnil", # [升级 Go1.18 后加入] 函数返回 nil, nil 检查 119 ] 120 121 [issues] 122 exclude-use-default = false 123 max-per-linter = 0 124 max-same-issues = 0 125 exclude = [] 126 127 [[issues.exclude-rules]] 128 path = "(.+)_test.go" 129 linters = [ 130 "errcheck", 131 "goconst", 132 "funlen", 133 "godot", 134 "lll", 135 "gosec", 136 "stylecheck", 137 "wsl", 138 "unused", 139 "deadcode", 140 "unparam", 141 "fieldalignment", 142 "maligned", 143 "varcheck"]