forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using `engine_repo_tools`, provide a default `--target-variant` for the `clang_tidy` tool. Mostly test code added below, the major change is that `--target-variant` now has a default other than `host_debug` if we're running inside of an engine root (which we ~always are). I didn't make any other changes (i.e. to the pre-commit hook) to keep this change smallish. Also rewrote the `README.md` to represent the current state as best I could.
- Loading branch information
1 parent
21372b1
commit 6036024
Showing
8 changed files
with
356 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,94 @@ | ||
# clang_tidy | ||
|
||
This is a Dart program/library that runs clang_tidy over modified files in the Flutter engine repo. | ||
A wrapper library and program that runs `clang_tidy` on the Flutter engine repo. | ||
|
||
By default the linter runs on the repo files changed contained in `src/out/host_debug/compile_commands.json` command. | ||
To check files other than in `host_debug` use `--target-variant android_debug_unopt`, | ||
`--target-variant ios_debug_sim_unopt`, etc. | ||
```shell | ||
# Assuming you are in the `flutter` root of the engine repo. | ||
dart ./tools/clang_tidy/bin/main.dart | ||
``` | ||
|
||
By default, the linter runs over _modified_[^1] files in the _latest_[^2] build | ||
of the engine. | ||
|
||
Alternatively, use `--compile-commands` to specify a path to a `compile_commands.json` file. | ||
A subset of checks can also be fixed automatically by passing `--fix`: | ||
|
||
```shell | ||
dart ./tools/clang_tidy/bin/main.dart --fix | ||
``` | ||
$ bin/main.dart --target-variant <engine-variant> | ||
$ bin/main.dart --compile-commands <compile_commands.json-path> | ||
$ bin/main.dart --help | ||
|
||
To configure what lints are enabled, see [`.clang-tidy`](../../.clang-tidy). | ||
|
||
> **💡 TIP**: If you're looking for the git pre-commit hook configuration, see | ||
> [`githooks`](../githooks). | ||
## Advanced Usage | ||
|
||
Some common use cases are described below, or use `--help` to see all options. | ||
|
||
### Run with checks added or removed | ||
|
||
To run adding a check _not_ specified in `.clang-tidy`: | ||
|
||
```shell | ||
dart ./tools/clang_tidy/bin/main.dart --checks="<check-name-to-run>" | ||
``` | ||
|
||
It's possible also to use wildcards to add multiple checks: | ||
|
||
```shell | ||
dart ./tools/clang_tidy/bin/main.dart --checks="readability-*" | ||
``` | ||
|
||
To remove a specific check: | ||
|
||
```shell | ||
dart ./tools/clang_tidy/bin/main.dart --checks="-<check-name-to-remove>" | ||
``` | ||
|
||
To remove multiple checks: | ||
|
||
```shell | ||
dart ./tools/clang_tidy/bin/main.dart --checks="-readability-*" | ||
``` | ||
|
||
To remove _all_ checks (usually to add a specific check): | ||
|
||
```shell | ||
dart ./tools/clang_tidy/bin/main.dart --checks="-*,<only-check-to-run>" | ||
``` | ||
|
||
### Specify a specific build | ||
|
||
There are some rules that are only applicable to certain builds, or to check | ||
a difference in behavior between two builds. | ||
|
||
Use `--target-variant` to specify a build: | ||
|
||
```shell | ||
dart ./tools/clang_tidy/bin/main.dart --target-variant <engine-variant> | ||
``` | ||
|
||
For example, to check the `android_debug_unopt` build: | ||
|
||
```shell | ||
dart ./tools/clang_tidy/bin/main.dart --target-variant android_debug_unopt | ||
``` | ||
|
||
In rarer cases, for example comparing two different checkouts of the engine, | ||
use `--src-dir=<path/to/engine/src>`. | ||
|
||
### Lint entire repository | ||
|
||
When adding a new lint rule, or when checking lint rules that impact files that | ||
have not changed. | ||
|
||
Use `--lint-all` to lint all files in the repo: | ||
|
||
```shell | ||
dart ./tools/clang_tidy/bin/main.dart --lint-all | ||
``` | ||
|
||
> **⚠️ WARNING**: This will take a long time to run. | ||
[^1]: Modified files are determined by a `git diff` command compared to `HEAD`. | ||
[^2]: Latest build is the last updated directory in `src/out/`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.