Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
# Broad families, minus the checks that fight the domain rather than help it.
# Each exclusion is deliberate:
#
# bugprone-branch-clone false positive on `if constexpr`
# bugprone-easily-swappable-parameters h(i, j), check_equal_size(a, b)
# bugprone-throwing-static-init* only fires on the test fixtures,
# the header itself has no globals
# misc-include-cleaner noisy for a single umbrella header
# modernize-use-nodiscard 57 sites; annotating the API with
# [[nodiscard]] is a decision to make
# on purpose, not a lint fix
# modernize-use-trailing-return-type style the project does not use
# portability-avoid-pragma-once #pragma once is a deliberate choice
# readability-function-cognitive-* binary()/ternary() are inherently so
# readability-identifier-length i, j, f, g, da, daa are the notation
# readability-magic-numbers the constants are the formulas
# readability-math-missing-parentheses precedence is the notation as well
# readability-named-parameter unused parameters in tag types
Checks: >
bugprone-*,
clang-analyzer-*,
misc-*,
modernize-*,
performance-*,
portability-*,
readability-*,
-bugprone-branch-clone,
-bugprone-easily-swappable-parameters,
-bugprone-throwing-static-initialization,
-misc-include-cleaner,
-modernize-use-nodiscard,
-modernize-use-trailing-return-type,
-portability-avoid-pragma-once,
-readability-function-cognitive-complexity,
-readability-identifier-length,
-readability-magic-numbers,
-readability-math-missing-parentheses,
-readability-named-parameter

# Only our own headers. Eigen, doctest and pybind11 are not ours to fix.
HeaderFilterRegex: 'include/hyperjet/.*\.h$'

FormatStyle: file
31 changes: 31 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Format all C++ sources in place
format:
uv run --only-group dev clang-format -i include/hyperjet/*.h python/src/*.h python/src/*.cpp test/src/*.cpp benchmark/src/*.cpp

# Generate the compilation database that clang-tidy needs
compile-db:
#!/usr/bin/env bash
set -euo pipefail
# The test build is the right entry point: it instantiates the templates, and
# an uninstantiated template is never analysed.
args=(-Stest -Bbuild/tidy -DCMAKE_BUILD_TYPE=Debug
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
-DCMAKE_POLICY_VERSION_MINIMUM=3.5)
# AppleClang knows the macOS SDK implicitly, the standalone clang-tidy does
# not, so the sysroot has to end up in the compilation database.
if [ "$(uname)" = Darwin ]; then
args+=("-DCMAKE_OSX_SYSROOT=$(xcrun --show-sdk-path)")
fi
cmake "${args[@]}" > /dev/null

# One invocation for all units rather than run-clang-tidy.py: with only two of
# them the parallel driver is no faster, and it reports every finding in the
# header once per unit instead of once.

# Run clang-tidy over the test translation units
tidy: compile-db
uv run --only-group tidy clang-tidy -p build/tidy --quiet test/src/*.cpp

# Same, applying the fixes clang-tidy can make itself
tidy-fix: compile-db
uv run --only-group tidy clang-tidy -p build/tidy --quiet --fix test/src/*.cpp
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ Repository = "https://github.com/oberbichler/HyperJet"

[dependency-groups]
dev = ["clang-format>=19.0", "ruff>=0.11"]
# Separate group: the clang-tidy wheel is ~44 MB against ~2 MB for
# clang-format, and the format CI job has no use for it.
tidy = ["clang-tidy>=19.0"]
test = ["pytest>=8.0"]

[tool.scikit-build]
Expand Down
23 changes: 23 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading