This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Provide a default --target-variant for clang_tidy.
#45909
Merged
auto-submit
merged 9 commits into
flutter:main
from
matanlurey:clang-tidy-default-engine-build
Sep 18, 2023
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d9538e5
Update README, including an optimistic take on defaults.
matanlurey 287c855
Let clang_tidy have a better default build, and add tests.
matanlurey 6c9360e
Update tools.
matanlurey 904ed2b
Tweak further.
matanlurey 0c23d11
Merge branch 'main' into clang-tidy-default-engine-build
matanlurey fa612ed
Fix pinned path pubspec.
matanlurey 536f05d
Merge branch 'main' into clang-tidy-default-engine-build
matanlurey 055e91a
Merge remote-tracking branch 'upstream/main' into clang-tidy-default-…
matanlurey e2deffb
Update help/usage.
matanlurey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.