Skip to content

Commit

Permalink
wip clang-tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
joto committed Jun 15, 2024
1 parent 2375c6a commit ead9974
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 1 deletion.
9 changes: 8 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
Checks: '*,-abseil-*,-altera-*,-android-cloexec-*,-bugprone-easily-swappable-parameters,-cert-err58-cpp,-cppcoreguidelines-avoid-magic-numbers,-cppcoreguidelines-avoid-non-const-global-variables,-cppcoreguidelines-owning-memory,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-cstyle-cast,-cppcoreguidelines-pro-type-reinterpret-cast,-cppcoreguidelines-pro-type-static-cast-downcast,-cppcoreguidelines-pro-type-vararg,-fuchsia-*,-google-readability-casting,-google-readability-todo,-hicpp-named-parameter,-hicpp-no-array-decay,-hicpp-vararg,-llvm-include-order,-llvm-header-guard,-llvmlibc-*,-misc-no-recursion,-modernize-use-nodiscard,-modernize-use-trailing-return-type,-readability-identifier-length,-readability-implicit-bool-conversion,-readability-named-parameter,-readability-magic-numbers'
Checks: '*,-abseil-*,-altera-*,-android-cloexec-*,-bugprone-easily-swappable-parameters,-cert-err58-cpp,-cppcoreguidelines-avoid-do-while,-cppcoreguidelines-avoid-magic-numbers,-cppcoreguidelines-avoid-non-const-global-variables,-cppcoreguidelines-owning-memory,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-cstyle-cast,-cppcoreguidelines-pro-type-reinterpret-cast,-cppcoreguidelines-pro-type-static-cast-downcast,-cppcoreguidelines-pro-type-vararg,-fuchsia-*,-google-readability-casting,-google-readability-todo,-hicpp-named-parameter,-hicpp-no-array-decay,-hicpp-vararg,-llvm-include-order,-llvm-header-guard,-llvmlibc-*,-misc-no-recursion,-misc-use-anonymous-namespace,-modernize-use-nodiscard,-modernize-use-trailing-return-type,-readability-identifier-length,-readability-implicit-bool-conversion,-readability-named-parameter,-readability-magic-numbers'
#
# cppcoreguidelines-pro-type-cstyle-cast
# google-build-using-namespace
Expand All @@ -26,6 +26,10 @@ Checks: '*,-abseil-*,-altera-*,-android-cloexec-*,-bugprone-easily-swappable-par
# There are many of these in the test code, most of them from the Catch
# framework. Difficult to avoid.
#
# cppcoreguidelines-avoid-do-while
# Its a good idea to avoid them when there are better alternatives, but
# sometimes they are the cleanest alternative.
#
# cppcoreguidelines-avoid-magic-numbers
# readability-magic-numbers
# We have a lot of these and should probably at least fix some. But remove
Expand Down Expand Up @@ -58,6 +62,9 @@ Checks: '*,-abseil-*,-altera-*,-android-cloexec-*,-bugprone-easily-swappable-par
# misc-no-recursion
# Nothing wrong with recursion
#
# misc-use-anonymous-namespace
# Matter of style
#
# modernize-use-nodiscard
# We have a lot of these. Remove it for the time being because there are
# too many to fix quickly. (TODO)
Expand Down
9 changes: 9 additions & 0 deletions .github/actions/clang-tidy/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Run clang-tidy

runs:
using: composite

steps:
- name: Run clang-tidy
run: run-clang-tidy-17 -q -p build
shell: bash
33 changes: 33 additions & 0 deletions .github/actions/linux-cmake/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CMake

runs:
using: composite

steps:
- name: create build directory
run: mkdir build
shell: bash

- name: configure
run: |
CMAKE_OPTIONS="-LA -DBUILD_TESTS=ON"
if [ -z "${LUA_VERSION}" ]; then
CMAKE_OPTIONS="$CMAKE_OPTIONS -DWITH_LUA=OFF"
else
CMAKE_OPTIONS="$CMAKE_OPTIONS -DWITH_LUAJIT=${LUAJIT_OPTION}"
fi
if [ -n "$WITH_PROJ" ]; then
CMAKE_OPTIONS="$CMAKE_OPTIONS -DWITH_PROJ=$WITH_PROJ"
fi
if [ -n "$CPP_VERSION" ]; then
CMAKE_OPTIONS="$CMAKE_OPTIONS -DCMAKE_CXX_STANDARD=$CPP_VERSION"
fi
if [ -n "$BUILD_TYPE" ]; then
CMAKE_OPTIONS="$CMAKE_OPTIONS -DCMAKE_BUILD_TYPE=$BUILD_TYPE"
fi
cmake $CMAKE_OPTIONS ..
shell: bash
working-directory: build
env:
CXXFLAGS: -pedantic -Wextra ${{ env.EXTRA_FLAGS }} -Werror

23 changes: 23 additions & 0 deletions .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: clang-tidy

on: [ push, pull_request ]

jobs:
clang-tidy:
runs-on: ubuntu-24.04

env:
CC: clang-18
CXX: clang++-18
LUA_VERSION: 5.4
LUAJIT_OPTION: OFF
POSTGRESQL_VERSION: 16
POSTGIS_VERSION: 3
BUILD_TYPE: Debug

steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/ubuntu-prerequisites
- uses: ./.github/actions/linux-cmake
- uses: ./.github/actions/clang-tidy

0 comments on commit ead9974

Please sign in to comment.