3 KiB
Check the Git hooks and C++ style rules
Run from the Telegram Desktop root. The Clang checks need ../stylecheck and matching LLVM and clang-tidy versions.
python3 -m pip install -r tools/rules/laws/requirements.txt
python3 ../stylecheck/run.py build --catalog tools/rules/laws/catalog.json
python3 tools/rules/laws/run.py
- Use
--quickto skip unavailable Clang checks,--engine pythonto run the Python checks, or pass case IDs. - Pass a custom
--catalogto both scripts. To use--plugin, keep its generatedLayoutConfig.hbeside the plugin.
Add a case
- Add
fixtures/<case-id>/before.cpporbefore.txtfor a commit subject. - Add expectations to the catalog. Use an empty array for a passing engine. Set
fixfor each diagnostic. Setmodefor edit and commit-message cases. - Add
after.cppfor a fix. Setfix_kindtosource-rewriteif the fix changes C++ tokens. - To test a staged diff, add
parent.cppand list the changed lines inchanged. Setcxxandheadersas needed for Clang. - Run the case by ID, then run the full catalog.
Sort includes
python3 tools/rules/cpp_layout.py --fix-includes Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp
Replay the installed hook
Install the hook and generate the compile database first. Set STYLECHECK_DB if it lives outside out/clang-tidy. Replay stages each commit against its first parent in a temporary index.
python3 tools/rules/laws/run.py --replay '6fe1a9f85f^..ac3274e465'
Check the Bend model
Use Bend 2.0.40 and lawcheck 0.4.1. For independent kernel verification, use Lean 4.34.0 or point BENDTT at the executable built from bendtt.lean. For offline lawcheck, point BENDLIB_BEND_SRC at the Bend source tree.
lawcheck tools/rules/laws/bend/LAWS.bend --size 3 --max-instances 150 --strict
bend tools/rules/laws/bend/PROOF.bend --verdict
python3 tools/rules/laws/bend/probe.py --verdict
Run lawcheck with the same flags on bend/legacy.bend to reproduce the counterexample.
Inspect or fix closing parentheses
python3 tools/rules/laws/closing_parenthesis.py < before.cpp
python3 tools/rules/laws/closing_parenthesis.py --line-ranges '[[4,4]]' < before.cpp
python3 tools/rules/laws/closing_parenthesis.py --fix < before.cpp > after.cpp
The findings schema uses zero-based, half-open byte ranges for edits and one-based, inclusive line ranges. Use --catalog to select layout parameters. Install the parser dependencies for the plugin's Python interpreter, or set STYLECHECK_PYTHON to the absolute path of an interpreter that has them.
Change the closing-parenthesis decision
Edit closer.bend, its laws, and the fixture expectations.
bend tools/rules/laws/bend/PROOF.bend --verdict
python3 tools/rules/laws/bend/generate_closer.py --write
python3 ../stylecheck/run.py build --catalog tools/rules/laws/catalog.json
python3 tools/rules/laws/run.py
Run the generator without --write to verify the catalog against Bend.