#!/usr/bin/env bash # lint.sh — Run all linters (clang-tidy + cppcheck + clang-format). # # Usage: # scripts/lint.sh # All 3 linters # scripts/lint.sh CLANG_FORMAT=clang-format-20 # Override formatter # scripts/lint.sh --ci # CI mode (skip clang-tidy) # # This script is the SINGLE source of truth for linting. set -euo pipefail ROOT="$(cd "$(dirname "$0")/.." && pwd)" cd "$ROOT" # shellcheck source=env.sh source "$ROOT/scripts/env.sh" # Check for --ci flag (skip clang-tidy for platforms without it) CI_ONLY=false MAKE_ARGS=() for arg in "$@"; do if [ "$arg" = "--ci" ]; then CI_ONLY=true else MAKE_ARGS+=("$arg") fi done print_env "lint.sh" # No-skips policy: every test must pass or fail. The only tolerable skip is a # genuinely platform-specific test (SKIP_PLATFORM / #ifdef). Runs in both modes. echo "=== no-skips policy (tests pass or fail) ===" bash "$ROOT/scripts/check-no-test-skips.sh" if $CI_ONLY; then echo "=== CI mode: cppcheck + clang-format ===" make -j2 -f Makefile.cbm lint-ci "${MAKE_ARGS[@]+"${MAKE_ARGS[@]}"}" echo "=== CI linters passed ===" else echo "=== Full lint: clang-tidy + cppcheck + clang-format ===" make -j3 -f Makefile.cbm lint "${MAKE_ARGS[@]+"${MAKE_ARGS[@]}"}" fi echo "=== All linters passed ==="