diff --git a/lint-configs/lint-requirements.txt b/lint-configs/lint-requirements.txt new file mode 100644 index 0000000..c895bb9 --- /dev/null +++ b/lint-configs/lint-requirements.txt @@ -0,0 +1,4 @@ +# Lock to v18.x until we can upgrade our code to meet v19's formatting standards. +clang-format~=18.1 +clang-tidy>=19.1.0 +yamllint>=1.35.1 diff --git a/taskfiles/utils.yml b/taskfiles/utils.yml index 6e8e882..5b24747 100644 --- a/taskfiles/utils.yml +++ b/taskfiles/utils.yml @@ -103,3 +103,41 @@ tasks: . "{{.OUTPUT_DIR}}/bin/activate" pip3 install --upgrade pip pip3 install --upgrade -r "{{.REQUIREMENTS_FILE}}" + + # === + # C++ LINTING UTILS + # === + + # Runs clang-format on C++ files at the given paths. + # + # @param {string} FLAGS Any flags to pass to clang-format. + # @param {[]string} SRC_PATHS The paths on which to run clang-format. + # @param {string} VENV_DIR Python virtual environment where clang-format is installed. + clang-format: + internal: true + requires: + vars: ["FLAGS", "SRC_PATHS", "VENV_DIR"] + cmd: |- + . "{{.VENV_DIR}}/bin/activate" + find {{- range .SRC_PATHS}} "{{.}}" {{- end}} \ + -type f \ + \( -iname "*.cpp" -o -iname "*.h" -o -iname "*.hpp" \) \ + -print0 | \ + xargs -0 clang-format {{.FLAGS}} -Werror + + # Runs clang-tidy on C++ files at the given paths. + # + # @param {string} FLAGS Any flags to pass to clang-tidy. + # @param {[]string} SRC_PATHS The paths on which to run clang-tidy. + # @param {string} VENV_DIR Python virtual environment where clang-tidy is installed. + clang-tidy: + internal: true + requires: + vars: ["FLAGS", "SRC_PATHS", "VENV_DIR"] + cmd: |- + . "{{.VENV_DIR}}/bin/activate" + find {{- range .SRC_PATHS}} "{{.}}" {{- end}} \ + -type f \ + \( -iname "*.cpp" -o -iname "*.h" -o -iname "*.hpp" \) \ + -print0 | \ + xargs -0 clang-tidy {{.FLAGS}}