Skip to content

Commit ce78515

Browse files
authored
[RNE Rewrite] docs(skills): add clang-tidy and check-cpp-warnings to verify-and-build skill (#1297)
## Description Updates .agents/skills/verify-and-build/SKILL.md to document the project's C++ static analysis checks: - lint:cpp (clang-tidy): Added steps to run static analysis using Homebrew LLVM. - check-cpp-warnings.sh : Documented how to run the compiler warning check manually. ### Introduces a breaking change? - [ ] Yes - [x] No ### Type of change - [ ] Bug fix (change which fixes an issue) - [ ] New feature (change which adds functionality) - [x] Documentation update (improves or adds clarity to existing documentation) - [ ] Other (chores, tests, code style improvements etc.) ### Tested on - [ ] iOS - [ ] Android ### Testing instructions N/A ### Screenshots <!-- Add screenshots here, if applicable --> ### Related issues <!-- Link related issues here using #issue-number --> ### Checklist - [ ] I have performed a self-review of my code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have updated the documentation accordingly - [ ] My changes generate no new warnings ### Additional notes <!-- Include any additional information, assumptions, or context that reviewers might need to understand this PR. -->
1 parent e2522d2 commit ce78515

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

.agents/skills/verify-and-build/SKILL.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,37 @@ yarn run android
6464

6565
---
6666

67+
## 🧹 C++ Static Analysis
68+
69+
Two complementary checks gate C++ quality. Always run both before committing.
70+
71+
### 1. `lint:cpp` — clang-tidy
72+
73+
Runs the project's `.clang-tidy` ruleset (bugprone / performance / clang-analyzer / llvm-include-order) over all `cpp/` sources.
74+
75+
```bash
76+
# clang-tidy must be installed from Homebrew LLVM — the Xcode bundled version is too old:
77+
CLANG_TIDY=$(brew --prefix llvm)/bin/clang-tidy yarn workspace react-native-executorch lint:cpp
78+
```
79+
80+
- Requires ExecuTorch headers provisioned under `third-party/include` and `yarn install` (for JSI headers).
81+
- Any finding fails the run (`--warnings-as-errors`). Suppress a deliberate, reviewed finding with `// NOLINTNEXTLINE(check-name)` rather than relaxing the shared config.
82+
83+
### 2. `check-cpp-warnings.sh` — clangd warning set
84+
85+
Compiles staged (or explicitly passed) `cpp/` sources with the same flags clangd uses in the editor (from `compile_flags.txt` + `-W` flags in `.clangd`), so the editor and CI stay in sync.
86+
87+
```bash
88+
# The script takes file paths as positional arguments and exits 0 immediately
89+
# with none — it has no built-in file discovery. Pass files explicitly:
90+
find cpp/ -name '*.cpp' -o -name '*.h' | \
91+
xargs ./scripts/check-cpp-warnings.sh
92+
```
93+
94+
The script skips gracefully (exit 0) when no compiler, `compile_flags.txt`, `.clangd`, or provisioned headers are found — it never blocks contributors who don't build the native code.
95+
96+
---
97+
6798
## 🔍 Debugging & Log Access
6899

69100
### 1. TypeScript & Worklet Logging
@@ -143,6 +174,7 @@ This project does **not** bundle local `.pte` model files inside the React Nativ
143174

144175
- **Do NOT run code without verification:** Do not test TypeScript changes in the app without first running `yarn typecheck` (verify types) and `yarn prepare` (build target bundles).
145176
- **Do NOT skip native rebuilds after C++ edits:** If any C++ files or config bindings are added/modified, do not attempt to run the app without executing `pod install` (for iOS) or letting Gradle sync (for Android).
177+
- **Do NOT run `lint:cpp` with the system `clang-tidy`**: Use the Homebrew LLVM binary: `CLANG_TIDY=$(brew --prefix llvm)/bin/clang-tidy yarn workspace react-native-executorch lint:cpp`.
146178
- **Do NOT log complex objects inside worklets:** Avoid passing complex circular objects directly to `console.log()` inside functions annotated with `'worklet';` as it can hang or crash the worklet runtime thread.
147179
- **Do NOT bundle local `.pte` files in the repository:** Do not commit heavy model binaries to the git repository. Always host them on Hugging Face and register their metadata in `src/models.ts`.
148180

@@ -155,6 +187,8 @@ When verifying or compiling your modifications, check that:
155187
- [ ] TypeScript typechecking passes without errors (`yarn typecheck`).
156188
- [ ] Bundles compile successfully (`yarn prepare`).
157189
- [ ] `pod install` has been run inside `apps/<domain-app>/ios/` after any native C++ edits.
190+
- [ ] `lint:cpp` passes cleanly: `CLANG_TIDY=$(brew --prefix llvm)/bin/clang-tidy yarn workspace react-native-executorch lint:cpp`.
191+
- [ ] `check-cpp-warnings.sh` passes cleanly (run via `find cpp/ -name '*.cpp' -o -name '*.h' | xargs ./scripts/check-cpp-warnings.sh` from the package root).
158192
- [ ] No `.pte` files are staged or added to git history.
159193
- [ ] Model configurations are registered inside the single `models` object registry in `src/models.ts`.
160194
- [ ] Native runtime issues have been investigated using Xcode Console or `adb logcat`.

.cspell-wordlist.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,3 +275,6 @@ pcre
275275
libkleidicv
276276
thresholding
277277
binarization
278+
bugprone
279+
NOLINTNEXTLINE
280+

0 commit comments

Comments
 (0)