Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

shrink: an ignore on a test function is not read as one binding

已关闭 适合新手
#255 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
84/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
go
领域
testing-qa

调研方向

阅读 internal/shrink/candidate.go 第 68–70 行附近的代码,并追踪 parse(b.Func(d)...) 如何在测试入口处的 continue 之前记录 ignore 绑定。将测试函数的行为与普通的 func F() 情况以及 issue 中的复现进行比较。完成标准是:测试函数中的 ignore 被归为一个绑定,与 analyzer 唯一的重复项报告相符,同时不将配对的 ignore 报告为未使用。

由索引模型根据 Issue 内容生成。

描述

bug P2

For a Test*, Benchmark*, Fuzz*, Example* or TestMain function in a _test.go file, the loop in internal/shrink/candidate.go:68-70 reaches continue before parse(b.Func(d)...). That function's ignores get no siblings or repeated entries, so unusedIgnores falls back to reading each comment group on its own. This is the shrink side of #242 and #238.

Reproduction

// internal/i/i_test.go
//declscope:ignore overexported
func TestX(t *testing.T) {} //declscope:ignore unused

//declscope:ignore overexported
func TestY(t *testing.T) {} //declscope:ignore overexported
Tool Reports
declscope shrink ./... unused //declscope:ignore overexported at 5:1, 8:1 and 9:29
The analyzer Only 9:29: duplicate declscope:ignore directive
  • 5:1 should not be reported, because the unused ignore beside it answers it.
  • 9:29 gets two reports for one mistake, which #242 meant to prevent.
  • The same shape on an ordinary func F() is correctly silent.

Suggested fix

Call parse(b.Func(d)...) before the test-entry continue, so that the binding is recorded even when no candidate is made.

主要语言
Go
星标
42
派生
1
平均合并
57 分钟
30 天内合并 PR
135

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。