Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン 初心者向け
#255 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
84/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
go
領域
testing-qa

調査の方向性

internal/shrink/candidate.goの68~70行付近を読み、テスト開始時のcontinueの前にparse(b.Func(d)...)がどのようにignoreのバインディングを記録するかを追ってください。テスト関数での動作を、通常のfunc F()の場合およびissueの再現例と比較してください。テスト関数のignoreが1つのバインディングとしてグループ化され、アナライザーによる重複の報告が1件となり、対になった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
平均マージ
1時間 18分
マージ済み PR(30日)
94

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

mpyw/declscope のほかの issue

mpyw/declscope の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。