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

unseen: stop reading files once every file is withheld

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

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

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

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
86/100
issue の種類
リファクタリング
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
go

調査の方向性

internal/subject.go:375 から始めて、unseen がディレクトリエントリをどのように処理するかを追跡し、次に ignore.go:177、rename.go:158、surplus.go:228 を確認して、それぞれの all checks を確認します。unseen が all の設定後に処理を停止し、issue に記載された parser オプションを使用し、reader の動作を変更しないことが完了条件です。

索引モデルが issue の本文から書いたものです。

説明

enhancement

Summary

unseen (internal/subject.go:375) keeps reading and parsing files after it has set u.all = true. At that point the answer is already final. Every reader checks u.all first and ignores u.names.

Current shape

for _, e := range entries {
	...
	if strings.HasSuffix(e.Name(), "_test.go") {
		u.all = true
		continue // keeps going through the rest of the directory
	}
	if f, err = parser.ParseFile(fset, p, nil, 0); err != nil { // full parse
		u.all = true
		continue
	}
	ast.Inspect(f, func(n ast.Node) bool { // collects names nobody will read
		if id, ok := n.(*ast.Ident); ok {
			u.names[id.Name] = true
		}
		return true
	})
}

The readers:

Reader What it does with all
ignore.go:177 Returns when all is set
rename.go:158 Returns false when all is set
surplus.go:228 surplusSeesEveryFile Returns false when all is set, before it reads names

Why the change helps

In the ordinary variant of a package with tests, the directory holds _test.go files the pass does not see. The first one sets u.all. The loop then fully parses, and walks, every build-excluded file left in the directory. ignore.go:177 calls unseen under the default strict unused mode, so nearly every package pays for this.

for _, e := range entries {
	if u.all {
		break // the answer cannot change
	}
	...
	if f, err = parser.ParseFile(fset, p, nil, parser.SkipObjectResolution); err != nil {
		...
	}
}

parser.SkipObjectResolution skips building the deprecated ast.Object scopes. unseen only reads ident.Name, so it does not need them.

Risk

None, since every reader checks .all first.

Not measured yet.

主要言語
Go
スター
42
フォーク
1
平均マージ
57分
マージ済み PR(30日)
135

環境構築

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

はじめの一歩

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

似ている issue

Go の issue をもっと見る

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

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