ignores: a Windows-style, absolute, ./-prefixed or trailing-slash ignores.global entry silently matches nothing
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 56/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- node.js, typescript
Direzione di ricerca
Start in src/utils/file-filter-utils.ts, especially FileFilterUtils.shouldIgnoreFile and the include pattern handling around the lines shown in the issue. Compare how ignore and include patterns are normalized, then inspect the existing tests for file filtering and audit output. Done means the listed path forms behave as expected and regression tests cover them; the suggested unmatched-entry warning adds additional audit behavior to consider.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Version: 7.29.1 (npm latest, 5fc54afe). The same code is on develop (efee761).
Area: ignores.global matching (FileFilterUtils.shouldIgnoreFile, src/utils/file-filter-utils.ts)
What happens
An ignores.global entry written as a Windows path, an absolute path, with a ./ prefix or with a trailing slash matches nothing, and RoC says nothing about it. The files it was meant to exclude are still judged. The same forms work in includes.global.
// src/utils/file-filter-utils.ts (7.29.1 = develop)
189 filePath = filePath.replace(/\\/g, '/'); // the PATH is normalised …
193 const ignorePath = FileFilterUtils.projectRelative(filePath);
205 if (minimatch(ignorePath, pattern)) { // … the PATTERN is used raw
326 const pattern = rawPattern.replace(/\\/g, '/'); // includes: the pattern IS normalised,
327 return pattern.includes('*') ? [pattern] : [pattern, `${pattern.replace(/\/$/, '')}/**`]; // and a bare dir expands to its tree
minimatch reads \ in a pattern as an escape, so vendor\** can never match vendor/lib.js. An absolute pattern never matches the project-relative path it is compared with. ./vendor/** and vendor/ do not match vendor/lib.js either. The include side handles exactly these forms: it normalises slashes and expands a bare directory. The ignore side does neither.
The config validator does not catch it, by its own documented limit: "It validates only keys under laws.severity / laws.notApplicable / laws.enabled; a typo in any other config section (thresholds, ignores, project) is not checked."
Reproduction
One synthetic project: package.json (no test setup), src/app.ts, src/util/helper.ts and nine other source files, plus vendor/lib.js. It is committed to git and audited with ruleofcode audit --mode full --json, once per ruleofcode.config.json. Windows 11, Node 24.16. The observable is Test Coverage Constitutional Standard, which counts the source files it judges ("N source files lack corresponding test files").
ignores.global |
source files judged | vendor/lib.js excluded? |
|---|---|---|
| none | 11 | — |
["vendor/**"] |
10 | yes |
["**/vendor/**"] |
10 | yes |
["./vendor/**"] |
11 | no |
["vendor/"] |
11 | no |
["vendor\\**"] (Windows separator) |
11 | no |
["vendor\\lib.js"] |
11 | no |
["<absolute project path>/vendor/**"] |
11 | no |
["<absolute project path with backslashes>\\vendor\\**"] |
11 | no |
["VENDOR/**"] |
11 | no (case; see below) |
For comparison: includes.global: ["src\\**"] gives the same result as ["src/**"], because the include side normalises it.
The runs were also instrumented. A preload records every minimatch(path, pattern) call made from ruleofcode/dist:
vendor/**: 54 matches out of 2890 calls. They come through the directory probe${dirPath}/test.ts(vendor/test.ts, line 225), so the wholevendortree is skipped.vendor\**,./vendor/**,vendor/and both absolute forms: 0 matches out of 2924 calls each.
No warning is printed on stdout or stderr.
What I ruled out
- Not a cache effect: the cache was deleted before every run.
- Not the project type or the law selection: 77 laws ran in every variant, and only the ignore entry differs.
- The other laws that change between variants (Absolute Zero Tolerance Doctrine, Code Documentation Standards) change only because the absolute project path differs between the fixture folders. That path is part of their messages.
VENDOR/**: matching is case-sensitive on both the include and the ignore side. On a case-insensitive file system this may surprise people, but I am not claiming it is a defect.- Measured only on Windows. On Linux and macOS the absolute and
./cases should behave the same, because the code path does not depend on the OS. The backslash case is Windows-specific in practice. Not measured there.
Why it matters
An ignore that does nothing is invisible. The user believes vendored or generated code is excluded, and the audit keeps judging it (or reporting it) with no hint that the entry is dead. The opposite mistake is already handled: an empty or non-matching laws.enabled allowlist refuses to report compliance. A dead ignore entry gets no such treatment.
This also matters for the glob 10 → 14 / minimatch 9 → 11 upgrade (#21). Today's ignore results depend on how minimatch treats \ and ./ in patterns, so the upgrade should be measured against a fixed, explicit normalisation rather than whatever the library happens to do.
Suggested direction
- Normalise ignore patterns the way include patterns already are (
\→/; strip a leading./; make an absolute pattern under the project root project-relative; expand a baredir/todir/**). One shared helper for both sides. - Report an
ignores.globalentry that matched no file during the run as a warning in the audit output ("ignores.global 'vendor\**' matched nothing — check the separator"), in the spirit of the dead-waiver notice. - A regression test per form in the table above, on Windows-style and POSIX-style paths.
- Lingua principale
- TypeScript
- Stelle
- 0
- Fork
- 0
- Merge medio
- 38m
- PR unite (30g)
- 96
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Rule-Of-Code/RoC
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Rule-Of-Code/RoC#436 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
Rule-Of-Code/RoC#439 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 49/100
Rule-Of-Code/RoC#438 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 53/100
Rule-Of-Code/RoC#437 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 74/100
Rule-Of-Code/RoC#435 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di Rule-Of-Code/RoC
Issue simili
-
documentation lens:human needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
thebristolsound/birdbrain#2246 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
A voting window past about 69.9 million hours stores a deadline that reads back as no deadlineApertabug ready-for-human
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
BoardGamesEmpire/board-games-empire-backend#1452 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
good first issue stretch
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno