Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

unseen: stop reading files once every file is withheld

Aperta Adatta ai principianti
#127 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
86/100
Tipo di issue
Refactoring
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go

Direzione di ricerca

Inizia da internal/subject.go:375 e segui il modo in cui unseen elabora le voci delle directory; poi esamina ignore.go:177, rename.go:158 e surplus.go:228 per confermare i relativi all checks. Il lavoro è completato quando unseen smette di elaborare le voci una volta impostato all e usa l’opzione del parser descritta nell’issue, senza modificare il comportamento di reader.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Go
Stelle
18
Fork
0
Merge medio
52m
PR unite (30g)
72

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di mpyw/declscope

Tutte le issue di mpyw/declscope

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.