build: add cyclop, contextcheck, gosec and promlinter

This commit is contained in:
Siyuan Miao 2025-09-05 11:20:37 +02:00
parent bcc307b147
commit 82c5e6b38f
2 changed files with 37 additions and 1 deletions

6
.custom-gcl.yml Normal file
View File

@ -0,0 +1,6 @@
# This has to be >= v1.57.0 for module plugin system support.
version: v2.4.0
plugins:
- module: "go.uber.org/nilaway"
import: "go.uber.org/nilaway/cmd/gclplugin"
version: latest # Or a fixed version for reproducible builds.

View File

@ -1,10 +1,18 @@
version: "2" version: '2'
linters: linters:
enable: enable:
- forbidigo - forbidigo
- misspell - misspell
- whitespace - whitespace
- gochecknoinits - gochecknoinits
# Static analysis tool to detect potential nil panics in Go code.
- nilaway
# Checks function and package cyclomatic complexity.
- cyclop
# Check whether the function uses a non-inherited context.
- contextcheck
- gosec
- promlinter
settings: settings:
forbidigo: forbidigo:
forbid: forbid:
@ -12,6 +20,12 @@ linters:
msg: Do not commit print statements. Use logger package. msg: Do not commit print statements. Use logger package.
- pattern: ^log\.(Fatal|Panic|Print)(f|ln)?.*$ - pattern: ^log\.(Fatal|Panic|Print)(f|ln)?.*$
msg: Do not commit log statements. Use logger package. msg: Do not commit log statements. Use logger package.
custom:
nilaway:
type: module
description: 'Static analysis tool to detect potential nil panics in Go code.'
settings:
exclude-pkgs: vendor
exclusions: exclusions:
generated: lax generated: lax
presets: presets:
@ -33,6 +47,22 @@ linters:
- third_party$ - third_party$
- builtin$ - builtin$
- examples$ - examples$
severity:
default: error
rules:
- linters:
- cyclop
severity: warning
- linters:
- contextcheck
severity: warning
- linters:
- gosec
severity: warning
- linters:
- gosec
severity: warning
formatters: formatters:
enable: enable:
- goimports - goimports