Run clang-tidy against a compile_commands.json via ``clang-tool-chain-tidy``. Routes entirely through the ``clang-tool-chain`` wrapper (lazily validates and fetches its bundled toolchain on first use), so there is no ``apt-get install`` / system-package dependency. Replaces the legacy
(compile_db: Path, project_root: Path)
| 142 | |
| 143 | |
| 144 | def run_static_analysis_against_compile_db(compile_db: Path, project_root: Path) -> int: |
| 145 | """Run clang-tidy against a compile_commands.json via ``clang-tool-chain-tidy``. |
| 146 | |
| 147 | Routes entirely through the ``clang-tool-chain`` wrapper (lazily validates |
| 148 | and fetches its bundled toolchain on first use), so there is no |
| 149 | ``apt-get install`` / system-package dependency. Replaces the legacy |
| 150 | ``pio check`` pathway, which fails during CMake configure on |
| 151 | fbuild-compiled boards because PIO-side metadata (partition CSVs etc.) |
| 152 | isn't populated — see FastLED#2302 / #2303. |
| 153 | |
| 154 | Check selection is governed by the repo-root ``.clang-tidy`` file, which |
| 155 | already enables the cppcheck-equivalent families (``bugprone-*``, |
| 156 | ``clang-analyzer-*``, ``performance-*``, selected ``modernize-*`` / |
| 157 | ``readability-*``). No inline ``--checks`` override — the file is the |
| 158 | single source of truth. |
| 159 | """ |
| 160 | files = _load_src_files_from_compile_db(compile_db, project_root) |
| 161 | if not files: |
| 162 | print( |
| 163 | f"No src/ translation units found in {compile_db} — nothing to " |
| 164 | f"analyze. (Compile DB may cover only framework code for this " |
| 165 | f"board.)" |
| 166 | ) |
| 167 | return 0 |
| 168 | |
| 169 | print( |
| 170 | f"Running clang-tool-chain-tidy against {len(files)} src/ files using " |
| 171 | f"compile DB: {compile_db}" |
| 172 | ) |
| 173 | cmd = [ |
| 174 | "uv", |
| 175 | "run", |
| 176 | "clang-tool-chain-tidy", |
| 177 | "-p", |
| 178 | str(compile_db.parent), |
| 179 | *files, |
| 180 | ] |
| 181 | cp = subprocess.run(cmd) |
| 182 | return cp.returncode |
| 183 | |
| 184 | |
| 185 | def main() -> int: |
no test coverage detected