Commit 5e415d6
fix(checkers): load custom YAML checkers from disk, not embedded FS (#230)
`LoadCustomYamlCheckers(dir)` walks `os.DirFS(dir)` to find YAML files
on local disk, but the closure it used read file content via
`builtinCheckers.ReadFile(path)` — i.e. always the embedded FS. For
every custom YAML file, `ReadFile` returned `fs.ErrNotExist`, the error
was silently swallowed by the top-level error check in the walk
callback, and the checker was never loaded.
Net result: `globstar check --checkers=local` in a repo with a
`.globstar/*.yml` found zero issues regardless of the YAML's content,
while the same YAML loaded via `--checkers=builtin` worked fine —
confirming the loader (not the YAML) was the problem.
Fix: thread a per-backend `readFile func(string) ([]byte, error)`
through `findYamlCheckers`. `LoadBuiltinYamlCheckers` passes
`builtinCheckers.ReadFile`; `LoadCustomYamlCheckers` passes a closure
that reads from disk via `os.ReadFile(filepath.Join(dir, p))`. No
public API breakage.
Add a regression test that writes a YAML checker to a temp dir and
asserts `LoadCustomYamlCheckers` returns it.
Co-authored-by: Sanket Saurav <sanketsaurav@gmail.com>1 parent 62a26ad commit 5e415d6
2 files changed
Lines changed: 58 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
57 | 59 | | |
58 | 60 | | |
59 | 61 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
0 commit comments