-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
tidy: add if-installed prefix condition to extra checks system #149961
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tidy: add if-installed prefix condition to extra checks system #149961
Conversation
This comment has been minimized.
This comment has been minimized.
85db7e7 to
69df709
Compare
|
r? @Kobzol |
|
|
This comment has been minimized.
This comment has been minimized.
58e4347 to
1c26a75
Compare
|
|
|
Basically what you are recommending is that, once I also object to adding more undocumented behavior. Even if this behavior was documented, the way it is implemented currently needlessly ups the complexity of tidy, making spellcheck both an extra-check an a regular check. I think all the spellcheck logic should be contained in the Additionally, we already have a way to control if If we do want this behavior, I think it should be opt-in, at least as far as tidy is concerned, likely through another prefix along the lines of I would also like to remind everyone that an ad-hoc implementation of typo checking has already broken CI once, so let's not repeat that mistake. |
|
I'm going to give the |
|
FWIW, we agreed to use this mechanism with @jieyouxu in #t-infra/bootstrap > Should Spellcheck check all files? @ 💬. I don't think that this would ever affect CI. Both because it will never have the binary preinstalled, and in the Tidy is inherently stateful, it depends a lot on git state and it skips some checks if the filesystem is read-only (maybe there are also some other things). The original idea hwere was to make more people use spellcheck locally. I'm not actually sure if it's needed, I don't often see spellcheck errors on CI, but it also sounded like it wouldn't do much harm. The problem is that installing the |
Yes, and I would've appreciated a ping on that honestly because you seemed to be missing a lot of context (like with opt-level, I'm pretty sure I did a bunch of manual testing about that to figure out the best level).
I still think it should have an explicit check.
I think we have different definitions to what "stateful" means. To me, all of these things (git state, fs metadata, every file in the tree) act as the "input" to tidy, and tidy merely acts as a pure function on top of these, never mutating them unless
We're already doing that for everyone on the
The cost is in code complexity and maintenance burden, as it always is. The current PR has a lot of duplicated code, and it also breaks encapsulation on the |
Fair enough, will do next time!
Sure, but in that case the
Hmm, it seems surprising to me that tidy runs so slowly for you. Well, maybe we don't really need to do anything after all. People can opt into spellcheck with Maybe to suggest a compromise: would you agree with running typos on a best effort basis (without installing it) only in the pre-push hook? That was the original-original idea.
That seems surprising to me. If anything, this PR seems to remove duplication? Also, I would prefer to actually move stuff out from the |
It's different because tidy installs typos-cli, thus modifying it.
I would not oppose that change, as long as there is a reasonable way to opt out. That's basically just a stripped down version of my
Sure, but if we do that, we should move the actual logic into the new file, not just a shim. We could also make them into individual checks without moving them out of their current module, it would just likely mean not using the existing macro. |
|
This looks good! I fully entrust lolbinarycat to have the final say, as they wrote the parsing code originally, but it's r+ from me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just some small nitpicks and a question about what OS you used to test this locally.
| ]; | ||
|
|
||
| for (s, expected) in test_cases { | ||
| assert_eq!(ExtraCheckArg::from_str(s), expected); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| assert_eq!(ExtraCheckArg::from_str(s), expected); | |
| assert_eq!(ExtraCheckArg::from_str(s), Err(expected)); |
Instead of wrapping each test case in Err, you can just wrap them all here, which should hopefully make it easier to read. You can also do the same thing above with the Ok tests, though that's a bit less important due to the different formatting.
466c3a9 to
0dfff23
Compare
|
LGTM @bors r+ |
…k, r=lolbinarycat tidy: add if-installed prefix condition to extra checks system Ref: https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Should.20Spellcheck.20check.20all.20files.3F/with/543227610 tidy now runs spellcheck (typos-cli) without adding `--extra-checks=spellcheck` option if the tool is already installed under ./build/misc-tools and the version is expected. It will improve code quality without bothering engineers who doesn't want to use typos or who cleans up ./build directory frequently.
Rollup of 12 pull requests Successful merges: - #149961 (tidy: add if-installed prefix condition to extra checks system) - #150475 (std: sys: fs: uefi: Implement initial File) - #150533 (std: sys: fs: uefi: Implement remove_dir_all) - #150549 (fix missing_panics_doc in `std::os::fd::owned`) - #150699 (MGCA: Support literals as direct const arguments) - #150721 (Deprecated doc intra link) - #150752 (Update libc to v0.2.180) - #150802 (Minor cleanups to fn_abi_new_uncached) - #150803 (compiler-builtins subtree update) - #150809 (Update `literal-escaper` version to `0.0.7`) - #150811 (Store defids instead of symbol names in the aliases list) - #150825 (Query associated_item_def_ids when needed) r? @ghost
…k, r=lolbinarycat tidy: add if-installed prefix condition to extra checks system Ref: https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Should.20Spellcheck.20check.20all.20files.3F/with/543227610 tidy now runs spellcheck (typos-cli) without adding `--extra-checks=spellcheck` option if the tool is already installed under ./build/misc-tools and the version is expected. It will improve code quality without bothering engineers who doesn't want to use typos or who cleans up ./build directory frequently.
…k, r=lolbinarycat tidy: add if-installed prefix condition to extra checks system Ref: https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Should.20Spellcheck.20check.20all.20files.3F/with/543227610 tidy now runs spellcheck (typos-cli) without adding `--extra-checks=spellcheck` option if the tool is already installed under ./build/misc-tools and the version is expected. It will improve code quality without bothering engineers who doesn't want to use typos or who cleans up ./build directory frequently.
…k, r=lolbinarycat tidy: add if-installed prefix condition to extra checks system Ref: https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Should.20Spellcheck.20check.20all.20files.3F/with/543227610 tidy now runs spellcheck (typos-cli) without adding `--extra-checks=spellcheck` option if the tool is already installed under ./build/misc-tools and the version is expected. It will improve code quality without bothering engineers who doesn't want to use typos or who cleans up ./build directory frequently.
…k, r=lolbinarycat tidy: add if-installed prefix condition to extra checks system Ref: https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Should.20Spellcheck.20check.20all.20files.3F/with/543227610 tidy now runs spellcheck (typos-cli) without adding `--extra-checks=spellcheck` option if the tool is already installed under ./build/misc-tools and the version is expected. It will improve code quality without bothering engineers who doesn't want to use typos or who cleans up ./build directory frequently.
…k, r=lolbinarycat tidy: add if-installed prefix condition to extra checks system Ref: https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Should.20Spellcheck.20check.20all.20files.3F/with/543227610 tidy now runs spellcheck (typos-cli) without adding `--extra-checks=spellcheck` option if the tool is already installed under ./build/misc-tools and the version is expected. It will improve code quality without bothering engineers who doesn't want to use typos or who cleans up ./build directory frequently.
…k, r=lolbinarycat tidy: add if-installed prefix condition to extra checks system Ref: https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Should.20Spellcheck.20check.20all.20files.3F/with/543227610 tidy now runs spellcheck (typos-cli) without adding `--extra-checks=spellcheck` option if the tool is already installed under ./build/misc-tools and the version is expected. It will improve code quality without bothering engineers who doesn't want to use typos or who cleans up ./build directory frequently.
Rollup of 11 pull requests Successful merges: - #149961 (tidy: add if-installed prefix condition to extra checks system) - #150475 (std: sys: fs: uefi: Implement initial File) - #150533 (std: sys: fs: uefi: Implement remove_dir_all) - #150549 (fix missing_panics_doc in `std::os::fd::owned`) - #150699 (MGCA: Support literals as direct const arguments) - #150721 (Deprecated doc intra link) - #150802 (Minor cleanups to fn_abi_new_uncached) - #150803 (compiler-builtins subtree update) - #150809 (Update `literal-escaper` version to `0.0.7`) - #150811 (Store defids instead of symbol names in the aliases list) - #150825 (Query associated_item_def_ids when needed) r? @ghost
Rollup merge of #149961 - add-optional-spellcheck-in-pre-hook, r=lolbinarycat tidy: add if-installed prefix condition to extra checks system Ref: https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Should.20Spellcheck.20check.20all.20files.3F/with/543227610 tidy now runs spellcheck (typos-cli) without adding `--extra-checks=spellcheck` option if the tool is already installed under ./build/misc-tools and the version is expected. It will improve code quality without bothering engineers who doesn't want to use typos or who cleans up ./build directory frequently.
Ref: https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Should.20Spellcheck.20check.20all.20files.3F/with/543227610
tidy now runs spellcheck (typos-cli) without adding
--extra-checks=spellcheckoption if the tool is already installed under ./build/misc-tools and the version is expected.It will improve code quality without bothering engineers who doesn't want to use typos or who cleans up ./build directory frequently.