Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

unseen: stop reading files once every file is withheld

Open Beginner friendly
#127 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
86/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Active
Tech stack
go

Research direction

Start at internal/subject.go:375 and trace how unseen processes directory entries, then review ignore.go:177, rename.go:158, and surplus.go:228 to confirm their all checks. Done means unseen stops processing once all is set and uses the parser option described in the issue, without changing reader behavior.

Written by the indexing model from the issue text.

Description

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.

Dominant language
Go
Stars
18
Forks
0
Avg merge
52m
Merged PRs (30d)
72

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from mpyw/declscope

All issues in mpyw/declscope

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.