From 5302f35413153f65243a0210b986af60b6e66aa1 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sat, 10 Oct 2026 11:15:39 +0200 Subject: [PATCH 1/2] Count skip-matched files in blink run summary ECS counts every discovered .php file in its run summary, skip-matched ones included, then applies no rules to them. blink counted only the files it processed, so its summary was lower than ECS's on projects with path skips (e.g. 2652 vs 3305 on rector-src). Finder now reports the pre-skip discovered total alongside the files to process; the summary uses it while only the non-skipped files are checked. --- blink/internal/finder/finder.go | 18 +++++++++++----- blink/internal/finder/finder_test.go | 31 +++++++++++++++++++++++++++- blink/internal/runner/runner.go | 5 +++-- 3 files changed, 46 insertions(+), 8 deletions(-) diff --git a/blink/internal/finder/finder.go b/blink/internal/finder/finder.go index 2c3ee2a61d..033df3c7bc 100644 --- a/blink/internal/finder/finder.go +++ b/blink/internal/finder/finder.go @@ -14,10 +14,14 @@ var alwaysSkipDirs = map[string]bool{ ".git": true, } -// Find walks paths and returns every .php file not matching a skip glob. -func Find(paths []string, skip []string) ([]string, error) { +// Find walks paths and returns every .php file not matching a skip glob, plus the +// count of distinct .php files discovered before skip globs are applied. ECS counts +// every discovered file in its run summary (skipped ones included), so the caller +// reports this total while only processing the returned files. +func Find(paths []string, skip []string) ([]string, int, error) { var out []string seen := map[string]bool{} + discovered := 0 for _, p := range paths { err := filepath.WalkDir(p, func(path string, d fs.DirEntry, err error) error { @@ -33,18 +37,22 @@ func Find(paths []string, skip []string) ([]string, error) { if !strings.HasSuffix(path, ".php") { return nil } - if skipped(path, skip) || seen[path] { + if seen[path] { return nil } seen[path] = true + discovered++ + if skipped(path, skip) { + return nil + } out = append(out, path) return nil }) if err != nil { - return nil, err + return nil, 0, err } } - return out, nil + return out, discovered, nil } // Skipped reports whether path matches any of the skip globs, using the same diff --git a/blink/internal/finder/finder_test.go b/blink/internal/finder/finder_test.go index 602e52c79e..5c4862ffbc 100644 --- a/blink/internal/finder/finder_test.go +++ b/blink/internal/finder/finder_test.go @@ -27,7 +27,7 @@ func TestFindSkipsDependencyDirs(t *testing.T) { } } - found, err := Find([]string{root}, nil) + found, discovered, err := Find([]string{root}, nil) if err != nil { t.Fatal(err) } @@ -47,6 +47,35 @@ func TestFindSkipsDependencyDirs(t *testing.T) { t.Fatalf("missing %s in %v", w, found) } } + // dependency dirs and non-.php files are not discovered either + if discovered != len(want) { + t.Fatalf("discovered = %d, want %d", discovered, len(want)) + } +} + +func TestFindCountsSkippedFiles(t *testing.T) { + root := t.TempDir() + for _, rel := range []string{"src/a.php", "src/Fixture/b.php", "src/Fixture/c.php"} { + full := filepath.Join(root, rel) + if err := os.MkdirAll(filepath.Dir(full), 0o755); err != nil { + t.Fatal(err) + } + if err := os.WriteFile(full, []byte(" Date: Sat, 10 Oct 2026 11:18:20 +0200 Subject: [PATCH 2/2] Make finder skip test OS-portable filepath.Join produces backslash paths on Windows, so the forward-slash skip glob did not match there. Use filepath.FromSlash so the pattern matches the walked paths on every OS. --- blink/internal/finder/finder_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blink/internal/finder/finder_test.go b/blink/internal/finder/finder_test.go index 5c4862ffbc..c750fcc817 100644 --- a/blink/internal/finder/finder_test.go +++ b/blink/internal/finder/finder_test.go @@ -65,7 +65,7 @@ func TestFindCountsSkippedFiles(t *testing.T) { } } - found, discovered, err := Find([]string{root}, []string{"*/Fixture/*"}) + found, discovered, err := Find([]string{root}, []string{filepath.FromSlash("*/Fixture/*")}) if err != nil { t.Fatal(err) }