- Added a new `main.cpp` file with logic to parse dial rotations from a file and execute safe cracking based on the parsed data. - Introduced a `DialRotation` struct to represent the direction and distance of dial rotations. - Implemented `parseRotations` function to read and parse input from a specified file, returning a vector of `DialRotation` or an error message. - Created `executeSafeCrack` function to process the dial rotations and print the current state of the dial. - Added `.clang-format` and `.clang-tidy` configuration files for code formatting and linting. - Set up a Dockerfile for a development container with necessary tools and dependencies. - Configured VS Code settings and tasks for building, formatting, and running clang-tidy. - Added a script to run clang-tidy on the source files, ensuring code quality.
28 lines
831 B
Bash
28 lines
831 B
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
BUILD_DIR=build
|
|
if [ ! -f "${BUILD_DIR}/compile_commands.json" ]; then
|
|
echo "compile_commands.json not found; running cmake configure..."
|
|
cmake -S . -B "${BUILD_DIR}" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
|
fi
|
|
if ! command -v clang-tidy >/dev/null 2>&1; then
|
|
echo "clang-tidy not found in PATH"
|
|
exit 1
|
|
fi
|
|
|
|
# Prefer files tracked by git; fallback to find
|
|
if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
|
FILES=$(git ls-files '*.cpp' '*.cxx' '*.cc' '*.h' '*.hpp' || true)
|
|
else
|
|
FILES=$(find . -iname "*.cpp" -o -iname "*.cc" -o -iname "*.cxx" -o -iname "*.h" -o -iname "*.hpp")
|
|
fi
|
|
|
|
if [ -z "${FILES}" ]; then
|
|
echo "No source files found for clang-tidy"
|
|
exit 0
|
|
fi
|
|
|
|
for f in ${FILES}; do
|
|
echo "Running clang-tidy on ${f}"
|
|
clang-tidy "${f}" -p "${BUILD_DIR}" || true
|
|
done
|