From 59015f1f91d640502fdfc34019cf0154b5206bb8 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Tue, 15 Sep 2026 00:27:43 +0200 Subject: explain walks the directory for a duplicate test in an exclude too --- internal/engine/match.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'internal/engine/match.go') diff --git a/internal/engine/match.go b/internal/engine/match.go index 6b98d73..c252596 100644 --- a/internal/engine/match.go +++ b/internal/engine/match.go @@ -280,10 +280,11 @@ func (e *Engine) Explain(ctx context.Context, path string) (*Explanation, error) excl := e.excludeDirs(d) skip := explainSkip(d, sf, excl, now) - // The directory is walked only for a duplicate test, the one thing that - // needs its other files (triage 21). + // The directory is walked only for a duplicate test - in a rule or in an + // exclude - the one thing that needs its other files (triage 21, plan 11 + // review M3). files := []scan.File{sf} - if len(d.DupScopes) > 0 { + if len(d.DupScopes) > 0 || excludesUseDuplicate(d) { files = e.filesForExplain(d, sf, excl, now) } run := newMatchRun(e, d, ctx, now, files) @@ -332,6 +333,17 @@ func (e *Engine) Explain(ctx context.Context, path string) (*Explanation, error) return &Explanation{Dir: d, File: sf, Skip: skip, Excludes: excludes, Excluded: excluded, Rules: rules, NoDelete: noDel}, nil } +// excludesUseDuplicate reports whether any of d's excludes has a +// (duplicate) test. +func excludesUseDuplicate(d *Dir) bool { + for _, x := range d.Excludes { + if len(x.Cond.DupDirs) > 0 { + return true + } + } + return false +} + // cacheFingerprint identifies what a cached keyword answer of d depends on // besides the file: the extractor (its version and tools), normalisation // and its Unicode tables, the Go release, and d's max-read, which caps what -- cgit v1.3