Skip to content

Commit e2dd463

Browse files
committed
add info about githooks and bootstrap.toml
1 parent 0023843 commit e2dd463

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/tools/tidy/Readme.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ Tidy is the Rust project's custom internal linter and a crucial part of our test
44
This document will cover how to use tidy, the specific checks tidy performs, and using tidy directives to manage its behavior. By understanding and utilizing tidy, you can help us maintain the high standards of the Rust project.
55
## Tidy Checks
66
### Style and Code Quality
7-
These lints focus on enforcing consistent formatting, style, and general code health. They ensure the codebase is readable, maintainable, and follows established conventions.
7+
These lints focus on enforcing consistent formatting, style, and general code health.
88
* [`alphabetical`](https://doc.rust-lang.org/nightly/nightly-rustc/tidy/alphabetical/index.html): Checks that lists are sorted alphabetically
99
* [`style`](https://doc.rust-lang.org/nightly/nightly-rustc/tidy/style/index.html): Check to enforce various stylistic guidelines on the Rust codebase.
1010
* [`filenames`](https://doc.rust-lang.org/nightly/nightly-rustc/tidy/filenames/index.html): Check to prevent invalid characters in file names.
1111
* [`pal`](https://doc.rust-lang.org/nightly/nightly-rustc/tidy/pal/index.html): Check to enforce rules about platform-specific code in std.
1212
* [`target_policy`](https://doc.rust-lang.org/nightly/nightly-rustc/tidy/target_policy/index.html): Check for target tier policy compliance.
1313
* [`error_codes`](https://doc.rust-lang.org/nightly/nightly-rustc/tidy/error_codes/index.html): Check to ensure error codes are properly documented and tested.
14+
1415
### Infrastructure
1516
These checks focus on the integrity of the project's dependencies, internal tools, and documentation.
1617
* [`bins`](https://doc.rust-lang.org/nightly/nightly-rustc/tidy/bins/index.html): Prevent stray binaries from being checked into the source tree.
@@ -19,6 +20,7 @@ These checks focus on the integrity of the project's dependencies, internal tool
1920
* [`gcc_submodule`](https://doc.rust-lang.org/nightly/nightly-rustc/tidy/gcc_submodule/index.html): Check that the `src/gcc` submodule version is valid.
2021
* [`triagebot`](https://doc.rust-lang.org/nightly/nightly-rustc/tidy/triagebot/index.html): Check to ensure paths mentioned in `triagebot.toml` exist in the project.
2122
* [`x_version`](https://doc.rust-lang.org/nightly/nightly-rustc/tidy/x_version/index.html): Validates the current version of the `x` tool.
23+
2224
* [`edition`](https://doc.rust-lang.org/nightly/nightly-rustc/tidy/edition/index.html) / [`features`](https://doc.rust-lang.org/nightly/nightly-rustc/tidy/features/index.html): Check for a valid Rust edition and proper ordering of unstable features.
2325
* [`rustdoc_css_themes`](https://doc.rust-lang.org/nightly/nightly-rustc/tidy/rustdoc_css_themes/index.html) / [`rustdoc_templates`](https://doc.rust-lang.org/nightly/nightly-rustc/tidy/rustdoc_templates/index.html): Verify that Rust documentation templates and themes are correct.
2426
* [`unstable_book`](https://doc.rust-lang.org/nightly/nightly-rustc/tidy/unstable_book/index.html): Synchronizes the unstable book with unstable features.
@@ -32,7 +34,12 @@ These checks ensure that tests are correctly structured, cleaned up, and free of
3234
* [`rustdoc_gui_tests`](https://doc.rust-lang.org/nightly/nightly-rustc/tidy/rustdoc_gui_tests/index.html): Checks that rustdoc gui tests start with a small description
3335
* [`rustdoc_json`](https://doc.rust-lang.org/nightly/nightly-rustc/tidy/rustdoc_json/index.html): Verify that `FORMAT_VERSION` is in sync with `rust-json-types`.
3436
## Using Tidy
35-
Tidy will automatically run every time `./x test` is used and as part of the CI on every PR. So, it's a good idea to run it locally first and catch any errors before the CI fails.
37+
38+
Tidy is used in a number of different ways.
39+
* Every time `./x test` is used tidy will run automatically.
40+
41+
* On every pull request, tidy will run automatically during CI checks.
42+
* Optionally, with the use of git-hooks, tidy can run locally on every push. This can be setup with `./x setup`. See the [rustc-dev-guide](https://rustc-dev-guide.rust-lang.org/building/suggested.html#installing-a-pre-push-hook) for more information.
3643

3744
You can run tidy manually with:
3845

@@ -49,16 +56,19 @@ Example usage:
4956
`./x test tidy --extra-checks=py,cpp,js,spellcheck`
5057

5158
All options for `--extra-checks`:
52-
* `cpp` `cpp:fmt`
53-
* `py` `py:lint` `py:fmt`
54-
* `js` `js:lint` `js:fmt` `js:typecheck`
55-
* `shell` `shell:lint`
59+
* `cpp`, `cpp:fmt`
60+
* `py`, `py:lint`, `py:fmt`
61+
* `js`, `js:lint`, `js:fmt`, `js:typecheck`
62+
* `shell`, `shell:lint`
5663
* `spellcheck`
5764

65+
Default values for tidy's `extra-checks` can be set in `bootstrap.toml`. For example, `build.tidy-extra-checks = "js,py"`.
66+
5867
Any argument without a suffix (eg. `py` or `js`) will include all possible checks. For example, `--extra-checks=js` is the same as `extra-checks=js:lint,js:fmt,js:typecheck`.
5968

6069
Any argument can be prefixed with `auto:` to only run if relevant files are modified (eg. `--extra-checks=auto:py`).
6170

71+
6272
`extra-checks` always runs in addition to the base tidy run. Additionally, you can pass in a specific file or directory to check only those files with an `extra-check`. For example:
6373

6474
`./x test tidy --extra-checks=py -- src/bootstrap` will check all `.py` files recursively within the `/src/bootstrap` directory.
@@ -69,7 +79,6 @@ Any argument can be prefixed with `auto:` to only run if relevant files are modi
6979

7080
Tidy directives are special comments that help tidy operate.
7181

72-
7382
Tidy directives can be used in the following types of comments:
7483
* `// `
7584
* `# `
@@ -91,7 +100,6 @@ You might find yourself needing to ignore a specific tidy style check and can do
91100
* `ignore-tidy-odd-backticks`
92101
* `ignore-tidy-todo`
93102

94-
95103
Some checks, like `alphabetical`, require a tidy directive to use:
96104
```
97105
// tidy-alphabetical-start

0 commit comments

Comments
 (0)