Skip to content

refactor(lint): 更严格的 golangci-lint 代码规范配置#19

Merged
wutongci merged 1 commit into
astercloud:mainfrom
lwmacct:tmp/251220-0516
Dec 20, 2025
Merged

refactor(lint): 更严格的 golangci-lint 代码规范配置#19
wutongci merged 1 commit into
astercloud:mainfrom
lwmacct:tmp/251220-0516

Conversation

@lwmacct

@lwmacct lwmacct commented Dec 19, 2025

Copy link
Copy Markdown
Contributor

概述

升级 golangci-lint 配置,启用更全面的代码质量检查(default: all),并修复所有阻塞性 lint 问题。

变更内容

代码修复

  • pkg/executionplan/generator.go - 修复变量遮蔽问题(errorserrs
  • pkg/tools/bridge/runtime.go - 修复 else if 语法错误和添加缺失的 errors 导入
  • server/auth/jwt.go - 调整嵌入字段位置,添加空行分隔
  • pkg/memory/semantic.go - 修复循环中字符串拼接(改用 strings.Builder
  • pkg/workflow/project_manager.go - 移除不必要的 int64 类型转换

配置更新

  • .golangci.yml - 启用 default: all 并合理禁用过于严格的 linter
  • .pre-commit-config.yaml - 改用本地 golangci-lint hook,支持增量检查

禁用的 Linter 说明

当前禁用的 linter 将在后续 PR 中逐步解除并修复:

  • errcheck - 错误检查(大量存量代码需要修复)
  • gosec - 安全检查(需要评估后逐步修复)
  • gocritic - 代码风格建议(57 处需要修复)
  • 其他测试相关和过于严格的检查

测试

  • golangci-lint run 通过(0 issues)
  • go build ./... 通过
  • pre-commit hooks 全部通过

Lint fixes:
- Fix variable shadowing in generator.go (errors -> errs)
- Fix else-if syntax error in runtime.go with composite literal
- Add missing errors import in runtime.go
- Reorder embedded field in jwt.go struct
- Fix string concatenation in loop in semantic.go
- Remove unnecessary int64 conversion in project_manager.go

Config updates:
- Optimize .golangci.yml to disable overly strict linters
- Update .pre-commit-config.yaml to use local golangci-lint hook
- Update go-ci.yml workflow configuration

Documentation and examples updates included.
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 27.04019% with 599 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/knowledge/manager.go 0.00% 24 Missing ⚠️
pkg/tools/builtin/task_manager.go 0.00% 24 Missing ⚠️
pkg/memory/semantic.go 0.00% 18 Missing ⚠️
pkg/provider/custom_claude.go 0.00% 17 Missing ⚠️
pkg/agent/processor.go 0.00% 16 Missing ⚠️
pkg/tools/builtin/subagent_manager.go 21.05% 15 Missing ⚠️
pkg/executionplan/generator.go 0.00% 12 Missing ⚠️
pkg/tools/builtin/storage_manager.go 33.33% 12 Missing ⚠️
pkg/agent/agent.go 57.14% 9 Missing ⚠️
pkg/memory/memory.go 0.00% 9 Missing ⚠️
... and 141 more

📢 Thoughts on this report? Let us know!

@wutongci
wutongci merged commit da827ef into astercloud:main Dec 20, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants