mirror of
https://github.com/shadow1ng/fscan.git
synced 2025-11-05 10:45:27 +00:00
- 分离i18n.GetText和GetTextF接口,消除API歧义 - 添加.golangci.yml配置,禁用printf检查保留其他检查 - 添加Makefile统一构建命令 - 升级CI流程:lint -> test -> build三阶段 - 修复.gitignore排除Makefile问题
155 lines
3.3 KiB
YAML
155 lines
3.3 KiB
YAML
# golangci-lint 配置
|
||
# 文档: https://golangci-lint.run/usage/configuration/
|
||
|
||
run:
|
||
# 超时时间
|
||
timeout: 5m
|
||
|
||
# 测试文件也检查
|
||
tests: true
|
||
|
||
# 跳过自动生成的文件
|
||
skip-dirs:
|
||
- vendor
|
||
- testdocker
|
||
- image
|
||
|
||
skip-files:
|
||
- ".*\\.pb\\.go$"
|
||
|
||
# 输出配置
|
||
output:
|
||
# 输出格式: colored-line-number|line-number|json|tab|checkstyle|code-climate
|
||
format: colored-line-number
|
||
|
||
# 显示所有问题
|
||
print-issued-lines: true
|
||
print-linter-name: true
|
||
|
||
# Linter 配置
|
||
linters:
|
||
# 禁用所有默认linters
|
||
disable-all: true
|
||
|
||
# 启用指定的linters
|
||
enable:
|
||
# Go 官方工具
|
||
- govet # Go官方检查工具(会特殊处理printf)
|
||
- gofmt # 代码格式化检查
|
||
- goimports # import排序检查
|
||
|
||
# 错误检查
|
||
- errcheck # 检查未处理的错误
|
||
- errorlint # 错误包装检查
|
||
|
||
# 代码质量
|
||
- staticcheck # 静态分析
|
||
- unused # 未使用的代码
|
||
- gosimple # 简化建议
|
||
- ineffassign # 无效赋值
|
||
- typecheck # 类型检查
|
||
|
||
# 代码复杂度
|
||
- gocyclo # 圈复杂度
|
||
- gocognit # 认知复杂度
|
||
|
||
# 安全检查(安全工具必备)
|
||
- gosec # 安全检查
|
||
|
||
# 代码风格
|
||
- misspell # 拼写检查
|
||
- whitespace # 空白符检查
|
||
- revive # 代码风格检查(golint的替代品)
|
||
|
||
# Linter 特定配置
|
||
linters-settings:
|
||
# govet 配置
|
||
govet:
|
||
# 启用所有检查
|
||
enable-all: true
|
||
|
||
# 禁用 printf 检查
|
||
# 原因: i18n.GetTextF 使用键名查找格式化字符串,静态分析无法识别
|
||
disable:
|
||
- printf
|
||
|
||
# errcheck 配置
|
||
errcheck:
|
||
# 检查类型断言
|
||
check-type-assertions: true
|
||
# 检查空白标识符
|
||
check-blank: false
|
||
|
||
# gocyclo 配置
|
||
gocyclo:
|
||
# 圈复杂度阈值
|
||
min-complexity: 15
|
||
|
||
# gocognit 配置
|
||
gocognit:
|
||
# 认知复杂度阈值
|
||
min-complexity: 20
|
||
|
||
# gosec 配置
|
||
gosec:
|
||
# 严重级别: low, medium, high
|
||
severity: medium
|
||
confidence: medium
|
||
|
||
# 排除特定规则
|
||
excludes:
|
||
- G104 # 未处理的错误(由errcheck处理)
|
||
- G304 # 文件路径由用户输入(扫描工具特性)
|
||
|
||
# revive 配置
|
||
revive:
|
||
confidence: 0.8
|
||
rules:
|
||
# 启用基础规则
|
||
- name: blank-imports
|
||
- name: context-as-argument
|
||
- name: dot-imports
|
||
- name: error-return
|
||
- name: error-strings
|
||
- name: error-naming
|
||
- name: exported
|
||
- name: increment-decrement
|
||
- name: var-naming
|
||
- name: package-comments
|
||
- name: range
|
||
- name: receiver-naming
|
||
- name: indent-error-flow
|
||
- name: superfluous-else
|
||
- name: unreachable-code
|
||
- name: redefines-builtin-id
|
||
|
||
# misspell 配置
|
||
misspell:
|
||
locale: US
|
||
|
||
# 问题配置
|
||
issues:
|
||
# 显示所有问题
|
||
max-issues-per-linter: 0
|
||
max-same-issues: 0
|
||
|
||
# 新代码检查
|
||
new: false
|
||
|
||
# 排除规则
|
||
exclude-rules:
|
||
# 排除测试文件的某些检查
|
||
- path: _test\.go
|
||
linters:
|
||
- gocyclo
|
||
- gocognit
|
||
- errcheck
|
||
|
||
# 排除长行(某些场景下合理)
|
||
- linters:
|
||
- lll
|
||
source: "^//go:generate "
|
||
|
||
# 不排除默认的问题
|
||
exclude-use-default: false
|