ignores: a Windows-style, absolute, ./-prefixed or trailing-slash ignores.global entry silently matches nothing
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 56/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- node.js, typescript
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- TypeScript
- スター
- 0
- フォーク
- 0
- 平均マージ
- 38分
- マージ済み PR(30日)
- 96
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Rule-Of-Code/RoC のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Rule-Of-Code/RoC#436 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
Rule-Of-Code/RoC#439 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 49/100
Rule-Of-Code/RoC#438 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 53/100
Rule-Of-Code/RoC#437 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 74/100
Rule-Of-Code/RoC#435 ·
メンテナーはふだん 1 日以内に返信
Rule-Of-Code/RoC の issue をすべて見る
似ている issue
-
ready-for-agent
難易度 1/5 1時間未満 初心者へのやさしさ 86/100
LucasSantana-Dev/Lucky#3257 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
XiaomiMiMo/MiMo-Code#2849 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
danielmiessler/LifeOS#2894 ·
メンテナーはふだん 5 日以内に返信
-
enhancement frontend good first issue help wanted testing-infrastructure
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 2 日以内に返信
-
enhancement follow-up
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信