diff --git a/.clang-format b/.clang-format index 468ceea..9b3aa8b 100644 --- a/.clang-format +++ b/.clang-format @@ -1 +1 @@ -BasedOnStyle: LLVM \ No newline at end of file +BasedOnStyle: LLVM diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 13dbce4..afbf59e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,3 +14,12 @@ jobs: enable-windows: true enable-macos: true warnings-as-errors: true + + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + - uses: pre-commit/action@v3.0.1 diff --git a/.gitignore b/.gitignore index 6ff7d0a..e4f13c0 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,4 @@ .vscode/ build/ cmake-build-* -CMakeUserPresets.json \ No newline at end of file +CMakeUserPresets.json diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..073eabc --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,16 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: check-json + - id: pretty-format-json + args: [--autofix, --no-sort-keys] + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: v19.1.7 + hooks: + - id: clang-format + types_or: [c++, c] diff --git a/CMakePresets.json b/CMakePresets.json index 653a92a..ac9dc1f 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -52,20 +52,54 @@ "name": "base", "hidden": true }, - { "name": "debug", "inherits": "base", "configurePreset": "debug" }, - { "name": "release", "inherits": "base", "configurePreset": "release" }, - { "name": "asan", "inherits": "base", "configurePreset": "asan" }, - { "name": "tsan", "inherits": "base", "configurePreset": "tsan" } + { + "name": "debug", + "inherits": "base", + "configurePreset": "debug" + }, + { + "name": "release", + "inherits": "base", + "configurePreset": "release" + }, + { + "name": "asan", + "inherits": "base", + "configurePreset": "asan" + }, + { + "name": "tsan", + "inherits": "base", + "configurePreset": "tsan" + } ], "testPresets": [ { "name": "base", "hidden": true, - "output": { "outputOnFailure": true } + "output": { + "outputOnFailure": true + } }, - { "name": "debug", "inherits": "base", "configurePreset": "debug" }, - { "name": "release", "inherits": "base", "configurePreset": "release" }, - { "name": "asan", "inherits": "base", "configurePreset": "asan" }, - { "name": "tsan", "inherits": "base", "configurePreset": "tsan" } + { + "name": "debug", + "inherits": "base", + "configurePreset": "debug" + }, + { + "name": "release", + "inherits": "base", + "configurePreset": "release" + }, + { + "name": "asan", + "inherits": "base", + "configurePreset": "asan" + }, + { + "name": "tsan", + "inherits": "base", + "configurePreset": "tsan" + } ] } diff --git a/LICENSE b/LICENSE index 9d46e4d..e59ef5f 100644 --- a/LICENSE +++ b/LICENSE @@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/include/rigtorp/HashMap.h b/include/rigtorp/HashMap.h index 6b9869e..48b3a3e 100644 --- a/include/rigtorp/HashMap.h +++ b/include/rigtorp/HashMap.h @@ -158,7 +158,7 @@ class HashMap { } template - std::pair emplace(Args &&... args) { + std::pair emplace(Args &&...args) { return emplace_impl(std::forward(args)...); } @@ -230,7 +230,7 @@ class HashMap { private: template - std::pair emplace_impl(const K &key, Args &&... args) { + std::pair emplace_impl(const K &key, Args &&...args) { assert(!key_equal()(empty_key_, key) && "empty key shouldn't be used"); reserve(size_ + 1); for (size_t idx = key_to_idx(key);; idx = probe_next(idx)) {