Open pnkfelix opened 4 years ago
@pnkfelix Do you know which "part" of tidy is doing this? I suspect rustfmt myself, but am not quite sure :)
Ideally we'd do a global audit I guess for using git ls-files
or so vs. direct traversal.
No, I don't know which part is doing it. I was assuming it was src/tools/tidy
that was gathering the set of paths to feed into rustfmt
, but I have not confirmed that hypothesis.
Well, I meant specifically what the errors were about -- I assume rustfmt based on your last message?
i.e., these are not (for example) line length or license check warnings, right?
Oh I see.
I've only observed the problem with the rustfmt
pass.
I just did a quick test; it seems like only the rustfmt
checks are inspecting the untracked files. (And I updated the description to include the output from my quick little test.)
Or at least, an untracked file with a long line does not seem to trigger the line length check.
I'm not clear on how the current license check works; I skimmed the deps.rs
code in src/tools/tidy
but couldn't work out where I should be finding a vendor/
directory, which seems to be tied into the workings of the tidy::deps::check
method.
I spent a bit of time trying to look at this, but failed to quickly figure out how to get a list of files from git. AFAICT, git ls-files
or git ls-tree
don't quite do what we want. In particular, I was unable to coax git into listing checked in files but not to list src/test, for example.
It was my impression based on some searching online that this is perhaps even expected behavior. It's possible that we could do some sort of dual listing, where we both apply the current ignore rules, but also only visit files in that list.
I also checked, and it's my impression that all of our checks would hit this problem -- rustfmt is just significantly more likely to do so.
I also checked, and it's my impression that all of our checks would hit this problem -- rustfmt is just significantly more likely to do so.
This is true. (E.g. I just ran into it with untracked files that each had more than one trailing newine.)
I suspect this was fixed by https://github.com/rust-lang/rust/pull/106440.
Ok, the current behavior is that tidy doesn't look at ignored files (i.e. files in .gitignore
), but it does look at untracked files. x fmt --check
looks at neither.
The fix for this is probably to run git ls-files . --exclude-standard --others
and skip files that it outputs in the default filter_dirs
function: https://github.com/rust-lang/rust/blob/8af42f695d493ed868098e3d1c02318f631998e4/src/tools/tidy/src/walk.rs#L5-L35
@rustbot claim
Imo tidy should check untracked files. If I run tidy before committing code and then commit+push I'd get CI errors because tidy skipped those.
Removing assignment due to https://github.com/rust-lang/rust/pull/112921#issuecomment-1681164841
assign it to me , i will look into it
@NoobProgrammer31 Done 🙂 In future you can use rustbot to claim issues (see example above )
Imo tidy should check untracked files. If I run tidy before committing code and then commit+push I'd get CI errors because tidy skipped those.
Totally agree. Being forced to stage files before running lint is annoying. Of course, there should be a flow here most developers are agreed on and once someone gets used to it, it would makes sense. I tried hard to think objective below:
x build
or x test
should be aware of this distinction (Sorry if they already are.).
I ran (effectively):
There are often extraneous files and directories in my source tree. And often they are not even files/directories that I had created (see (*) below).
The problem is that tidy does a blanket traversal of the tree under
src/
, as far as I can tell, and thus will happily flag "problems" in files that are no longer effectively part of the source code.(My most recent instance of this was tidy flagging a problem in a
.rs
file undersrc/stdsimd/
.)Eventually, after several rounds of trying to understand why non-tidy code got checked into the github repo, I'll eventually remember to look at
git status
and take note of the directories listed under untracked files. And then, usually, delete them.But this should not be necessary.
tidy
should be smart enough to rungit status
itself and use that to drive its traversal.(*) part of the above process is the build system will automatically update submodules. But old directories from old (outdated) submodule checkouts still stick around.