## 主要改进 ### 架构重构 - 将单体 provider.go 拆分为多个专门的模块文件 - 实现了清晰的职责分离和模块化设计 - 遵循 SOLID 原则,提高代码可维护性 ### 新增功能 - **验证规则系统**: 实现了完整的 provider 验证框架 - **报告生成器**: 支持多种格式的验证报告 (JSON/HTML/Markdown/Text) - **解析器优化**: 重新设计了解析流程,提高性能和可扩展性 - **错误处理**: 增强了错误处理和诊断能力 ### 修复关键 Bug - 修复 @provider(job) 注解缺失 __job 注入参数的问题 - 统一了 job 和 cronjob 模式的处理逻辑 - 确保了 provider 生成的正确性和一致性 ### 代码质量提升 - 添加了完整的测试套件 - 引入了 golangci-lint 代码质量检查 - 优化了代码格式和结构 - 增加了详细的文档和规范 ### 文件结构优化 ``` pkg/ast/provider/ ├── types.go # 类型定义 ├── parser.go # 解析器实现 ├── validator.go # 验证规则 ├── report_generator.go # 报告生成 ├── renderer.go # 渲染器 ├── comment_parser.go # 注解解析 ├── modes.go # 模式定义 ├── errors.go # 错误处理 └── validator_test.go # 测试文件 ``` ### 兼容性 - 保持向后兼容性 - 支持现有的所有 provider 模式 - 优化了 API 设计和用户体验 This completes the implementation of T025-T029 tasks following TDD principles, including validation rules implementation and critical bug fixes.
134 lines
2.5 KiB
YAML
134 lines
2.5 KiB
YAML
# GolangCI-Lint configuration for pkg/ast/provider package
|
|
run:
|
|
timeout: 5m
|
|
modules-download-mode: readonly
|
|
go: '1.24'
|
|
build-tags:
|
|
- go1.24
|
|
|
|
linters:
|
|
disable-all: true
|
|
enable:
|
|
# Default linters
|
|
- errcheck
|
|
- gosimple
|
|
- govet
|
|
- ineffassign
|
|
- staticcheck
|
|
- typecheck
|
|
- unused
|
|
|
|
# Additional recommended linters
|
|
- gofmt
|
|
- goimports
|
|
- misspell
|
|
- unconvert
|
|
- unparam
|
|
- nakedret
|
|
- prealloc
|
|
- gocritic
|
|
- bodyclose
|
|
- depguard
|
|
- dogsled
|
|
- dupl
|
|
- errname
|
|
- errorlint
|
|
- exportloopref
|
|
- forbidigo
|
|
- forcetypeassert
|
|
- gci
|
|
- gocyclo
|
|
- godot
|
|
- goerr113
|
|
- gomnd
|
|
- gomodguard
|
|
- goprintffuncname
|
|
- gosec
|
|
- importas
|
|
- makezero
|
|
- nolintlint
|
|
- paralleltest
|
|
- predeclared
|
|
- revive
|
|
- tenv
|
|
- testpackage
|
|
- thelper
|
|
- tparallel
|
|
- wastedassign
|
|
- whitespace
|
|
|
|
linters-settings:
|
|
gofmt:
|
|
simplify: true
|
|
|
|
goimports:
|
|
local-prefixes: go.ipao.vip/atomctl/v2
|
|
|
|
gocyclo:
|
|
min-complexity: 15
|
|
|
|
gomnd:
|
|
settings:
|
|
mnd:
|
|
# The next line enables the detection of `00000000` magic numbers
|
|
checks: argument,case,condition,operation,return,assign
|
|
|
|
gci:
|
|
sections:
|
|
- standard
|
|
- default
|
|
- prefix(go.ipao.vip/atomctl/v2)
|
|
|
|
revive:
|
|
rules:
|
|
- name: exported
|
|
disabled: false
|
|
|
|
unparam:
|
|
check-exported: false
|
|
|
|
dupl:
|
|
threshold: 100
|
|
|
|
gosec:
|
|
excludes:
|
|
- G115 # Potential integer overflow when converting between integer types
|
|
- G404 # Use of weak random number generator (math/rand instead of crypto/rand)
|
|
- G501 # Blocklisted import crypto/md5: weak cryptographic primitive
|
|
- G502 # Blocklisted import crypto/sha1: weak cryptographic primitive
|
|
- G505 # Blocklisted import crypto/des: weak cryptographic primitive
|
|
- G506 # Blocklisted import crypto/rc4: weak cryptographic primitive
|
|
|
|
issues:
|
|
exclude-use-default: false
|
|
exclude-rules:
|
|
- path: _test\.go
|
|
linters:
|
|
- gomnd
|
|
- unparam
|
|
- dupl
|
|
- gosec
|
|
- bodyclose
|
|
- forcetypeassert
|
|
- makezero
|
|
- path: tests/
|
|
linters:
|
|
- gomnd
|
|
- unparam
|
|
- dupl
|
|
- gosec
|
|
- bodyclose
|
|
- forcetypeassert
|
|
- makezero
|
|
- path: '.*\.pb\.go$'
|
|
linters:
|
|
- all
|
|
- text: "weak cryptographic primitive"
|
|
linters:
|
|
- gosec
|
|
|
|
output:
|
|
format: colored-line-number
|
|
print-issued-lines: true
|
|
print-linter-name: true
|
|
uniq-by-line: true |