Skip to content

Conversation

@dongjiang1989
Copy link
Member

No description provided.

@CLAassistant
Copy link

CLAassistant commented Dec 4, 2025

CLA assistant check
All committers have signed the CLA.

Signed-off-by: jiangdong <jiangdong@iflytek.com>
@lingma-agents
Copy link

lingma-agents bot commented Dec 4, 2025

更新 golangci-lint 版本并新增多项代码检查规则

变更概述
  • 依赖更新

    • golangci-lint 升级至 v2.6.2 版本,以支持更多现代 Go 语言特性及 lint 规则。
    • 添加多个间接依赖项如 maratori/testableexamplesmaratori/testpackage 等,用于增强 lint 功能。
  • 配置调整

    • .golangci.yml 中启用新的 Linter 工具集:
      • asciicheck: 检查非 ASCII 字符使用情况。
      • bodyclose: 确保 HTTP 响应体被正确关闭。
      • goconst: 查找可替换为常量的字符串字面值。
      • gocyclo: 控制函数圈复杂度。
      • misspell: 检测拼写错误。
      • nilerr: 防止忽略错误返回值。
      • unused: 发现未使用的代码元素。
      • whitespace: 检查多余的空白字符。
    • 同时在 Makefile 的 all 目标中加入格式化(format)步骤,并保留原有构建流程。
  • 问题修复

    • 修改了 test/framework/util.go 文件中的 URLToIOReader 函数,引入超时机制防止请求挂起。通过 wait.PollUntilContextTimeout 实现带超时重试逻辑,并标注忽略 bodyclose 警告(因后续处理会关闭响应体)。
  • 测试更新

    • 移除了部分中间件测试文件中不必要的空行,提升代码整洁性与一致性。
  • 其他

    • 删除了一些冗余的日志记录字段和变量声明,精简代码结构。
变更文件
文件路径 变更说明
.golangci.yml 启用多个新的 Linter 规则来加强静态代码分析能力。
Makefile 更新默认目标 all 包含 swag、format、test、build、e2e 步骤。
pkg/middleware/logging.go 删除 response-content-size 日志字段。
pkg/middleware/metrics.go 删除 computeApproximateRequestSize 函数签名中的无用参数。
pkg/​middleware/​metrics_​test.​go 移除测试结尾处多余的 sleep 行。
pkg/​middleware/​tracing_​test.​go 删除测试末尾多余换行。
scripts/go.mod 升级 golangci-lint 至 v2.6.2 并增加两个间接依赖。
scripts/go.sum 更新模块校验和信息匹配最新依赖版本。
test/framework/util.go 引入带超时控制的 HTTP 请求方法替代原生 Get 方法。
时序图
sequenceDiagram
    participant TF as TestFramework
    participant HTTP as HttpClient
    TF->>HTTP: 发起带超时限制的 GET 请求
    loop Polling with Timeout
        HTTP-->>TF: 返回状态码 != 200 或出错则继续轮询
    end
    TF->>TF: 成功获取资源后构造 io.Reader 返回
Loading

💡 小贴士

与 lingma-agents 交流的方式

📜 直接回复评论
直接回复本条评论,lingma-agents 将自动处理您的请求。例如:

  • 在当前代码中添加详细的注释说明。

  • 请详细介绍一下你说的 LRU 改造方案,并使用伪代码加以说明。

📜 在代码行处标记
在文件的特定位置创建评论并 @lingma-agents。例如:

  • @lingma-agents 分析这个方法的性能瓶颈并提供优化建议。

  • @lingma-agents 对这个方法生成优化代码。

📜 在讨论中提问
在任何讨论中 @lingma-agents 来获取帮助。例如:

  • @lingma-agents 请总结上述讨论并提出解决方案。

  • @lingma-agents 请根据讨论内容生成优化代码。

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request primarily updates the Go linter configuration by upgrading golangci-lint and its dependencies, and enabling several new linters such as asciicheck, bodyclose, goconst, gocyclo, misspell, nilerr, unused, and whitespace in .golangci.yml. It also adds a swag target to the Makefile and includes minor whitespace cleanups in middleware files. Additionally, a timeout in test/framework/util.go was reduced, and a //nolint:bodyclose directive was added, likely to address issues with the newly enabled bodyclose linter. A review comment points out that the unused linter is both enabled and explicitly disabled in .golangci.yml, suggesting the disable entry should be removed to ensure it runs.

Signed-off-by: dongjiang1989 <dongjiang1989@126.com>
@dongjiang1989 dongjiang1989 merged commit c7a9b9e into master Dec 4, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants