unseen: stop reading files once every file is withheld
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
- Domain
- devtools, performance
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
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from mpyw/declscope
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
enhancement
Difficulty 1/5 Under an hour Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
enhancement
Difficulty 3/5 1-2 days Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
enhancement
Difficulty 3/5 1-2 days Newbie friendliness 78/100
Maintainers usually reply within 1 day
Similar issues
-
agentic-workflows
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
priority/4/normal status/needs-triage type/bug/unconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
authelia/authelia#13292 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
blinklabs-io/actions#138 ·
Maintainers usually reply within 1 day
-
[UI] AlbumDetails collapses multi-genre list to single primary genre on viewports < lg breakpointOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day