You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/tools/tidy/Readme.md
+16-8Lines changed: 16 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,13 +4,14 @@ Tidy is the Rust project's custom internal linter and a crucial part of our test
4
4
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.
5
5
## Tidy Checks
6
6
### 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.
8
8
*[`alphabetical`](https://doc.rust-lang.org/nightly/nightly-rustc/tidy/alphabetical/index.html): Checks that lists are sorted alphabetically
9
9
*[`style`](https://doc.rust-lang.org/nightly/nightly-rustc/tidy/style/index.html): Check to enforce various stylistic guidelines on the Rust codebase.
10
10
*[`filenames`](https://doc.rust-lang.org/nightly/nightly-rustc/tidy/filenames/index.html): Check to prevent invalid characters in file names.
11
11
*[`pal`](https://doc.rust-lang.org/nightly/nightly-rustc/tidy/pal/index.html): Check to enforce rules about platform-specific code in std.
12
12
*[`target_policy`](https://doc.rust-lang.org/nightly/nightly-rustc/tidy/target_policy/index.html): Check for target tier policy compliance.
13
13
*[`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
+
14
15
### Infrastructure
15
16
These checks focus on the integrity of the project's dependencies, internal tools, and documentation.
16
17
*[`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
19
20
*[`gcc_submodule`](https://doc.rust-lang.org/nightly/nightly-rustc/tidy/gcc_submodule/index.html): Check that the `src/gcc` submodule version is valid.
20
21
*[`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.
21
22
*[`x_version`](https://doc.rust-lang.org/nightly/nightly-rustc/tidy/x_version/index.html): Validates the current version of the `x` tool.
23
+
22
24
*[`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.
23
25
*[`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.
24
26
*[`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
32
34
*[`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
33
35
*[`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`.
34
36
## 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.
36
43
37
44
You can run tidy manually with:
38
45
@@ -49,16 +56,19 @@ Example usage:
49
56
`./x test tidy --extra-checks=py,cpp,js,spellcheck`
50
57
51
58
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`
56
63
*`spellcheck`
57
64
65
+
Default values for tidy's `extra-checks` can be set in `bootstrap.toml`. For example, `build.tidy-extra-checks = "js,py"`.
66
+
58
67
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`.
59
68
60
69
Any argument can be prefixed with `auto:` to only run if relevant files are modified (eg. `--extra-checks=auto:py`).
61
70
71
+
62
72
`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:
63
73
64
74
`./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
69
79
70
80
Tidy directives are special comments that help tidy operate.
71
81
72
-
73
82
Tidy directives can be used in the following types of comments:
74
83
*`// `
75
84
*`# `
@@ -91,7 +100,6 @@ You might find yourself needing to ignore a specific tidy style check and can do
91
100
*`ignore-tidy-odd-backticks`
92
101
*`ignore-tidy-todo`
93
102
94
-
95
103
Some checks, like `alphabetical`, require a tidy directive to use:
0 commit comments