akiomik / akiomik/mado

Decide: should a path already covered by another one be dropped before the walk?

オープン
#443 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
question
主要言語
Rust
スター
407
フォーク
12
平均マージ
5時間 45分
マージ済み PR(30日)
30

説明

## Context

Two paths that name the same tree, by two names or by one containing the other,
are walked twice and reported twice:

```console
$ mado check . docs # every file under docs/ reported twice
$ mado check ./d1 sub/../d1
```

The reporting has been that way since before #436 and is not something that PR
changed. What #436 adds is the second walk: a path outside a repository is
grouped with the others that need the same ignore files read for them, and the
files are named the way the path names them, because `WalkBuilder::add_ignore`
roots a file at the name it is handed and the walk yields paths built from the
name its pattern was written as. `./d1` and `sub/../d1` are therefore two keys
and two walks, and they have to be — a walk over `sub/../d1/docs` handed
`./.gitignore` would not line up an anchored pattern in it against
`sub/../d1/docs/ignored.md`. There is a test on that.

## The decision to make

**Should a path already covered by another be dropped before the walk?**

Dropping it would settle both: one walk, and one report per file. It is a
change to what mado prints, though, and the argument for the change is the
argument against printing a file twice rather than anything about ignore files.

- *Leave it as it is:* naming a tree twice is asking for it twice, and the
answer is the same either way. What it costs is a walk and a repeat.
- *Drop the covered path:* compare the canonical paths and keep the one that
covers, before grouping. Then `mado check . docs` prints each file once and
walks once. Whoever wrote the command probably meant that, but they did write
both, and a path named on the command line is otherwise always honoured — see
the file that `.gitignore` lists and `mado check` still reports.
- *Report once and walk twice:* the visitors could drop a path they have
already linted, which fixes the printing without touching what is walked.

Worth deciding before anything is built: the three answers differ in what mado
prints, not in how it is implemented.

## Related

- #436

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。