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
{{ message }}
Repository navigation
Commit e2522d2
Browse filesBrowse the repository at this point in the historyBrowse files
## Description
Adds clang-tidy static analysis for the core package's C/C++ sources.
Second step of #1271 (clangd setup landed in #1285). Rebased onto
`rne-rewrite`, so this is clang-tidy-only.
- `.clang-tidy` — a high-signal check set enabled group by group (one
commit each): `bugprone-*`, `performance-*`, `clang-analyzer-*`,
`cppcoreguidelines-*`, `google-*`, `llvm-*`, `misc-*`, `modernize-*`,
`readability-*`. Each group's narrow exclusion list (raw-buffer pointer
math, `reinterpret_cast`, `#pragma once`, JSI multiple-inheritance,
opinionated/noisy checks) is documented inline with rationale. Analyzes
only this package's own `cpp/` headers; third-party is `-isystem`.
- `scripts/clang-tidy.sh` + the `lint:cpp` package script — run
clang-tidy over `cpp/` using `compile_flags.txt` (the same database
clangd uses), failing on any finding.
- `.github/workflows/clang-tidy.yml` — CI gate, **dormant** behind the
`ENABLE_CLANG_TIDY` repo variable. It provisions headers through the
on-demand download flow (`download-libs.js`, #1283) rather than a stub,
since clang-tidy needs the ExecuTorch headers to parse the sources.
The fixes each group surfaced are split across the per-group commits
(scoped `DType` enum, member-init lists, `explicit` ctor,
`const`-correctness cleanup, `use-auto`/`emplace`/`cmp_*`
modernizations, `NOLINT`s for the intentional cases).
Depends on #1283 for `download-libs.js`; enable the workflow once that
has merged and a release carrying `headers.tar.gz` exists. The
provisioning step sets `RNET_HEADERS_ONLY=1` (clang-tidy needs only
headers) — see PR thread re: honoring that flag in `download-libs.js`.
Verified locally (Homebrew LLVM clang-tidy): `lint:cpp` is green on all
sources and exits non-zero on an injected finding.
### Introduces a breaking change?
- [ ] Yes
- [x] No
### Type of change
- [ ] Bug fix (change which fixes an issue)
- [ ] New feature (change which adds functionality)
- [ ] Documentation update (improves or adds clarity to existing
documentation)
- [x] Other (chores, tests, code style improvements etc.)
### Tested on
- [ ] iOS
- [ ] Android
### Testing instructions
1. Provision `packages/react-native-executorch/third-party/include` and
run `yarn install`.
2. From the repo root: `CLANG_TIDY=$(brew --prefix llvm)/bin/clang-tidy
yarn workspace react-native-executorch lint:cpp` — expect 0 findings.
3. Confirm the gate has teeth: introduce a bug in a `cpp/` file, e.g.
`double r = a / b;` (ints) for `bugprone-integer-division`, and re-run —
expect a non-zero exit. Revert afterwards.
### Related issues
#1271
### Checklist
- [x] I have performed a self-review of my code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have updated the documentation accordingly
- [x] My changes generate no new warnings
0 commit comments