diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 00000000..df9a14e0 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,64 @@ +--- +Checks: > + # Modernize checks + modernize-* + # Avoid raw pointers + modernize-use-auto, + modernize-use-nullptr, + modernize-avoid-c-arrays, + modernize-make-unique, + modernize-make-shared, + modernize-smart-ptr, + modernize-use-override, + modernize-use-equals-default, + modernize-use-equals-delete, + modernize-use-bool-literals, + modernize-loop-convert, + modernize-use-emplace, + modernize-use-using, + modernize-deprecated-headers, + modernize-pass-by-value, + modernize-concat-nested-namespaces, + + # Core guidelines + cppcoreguidelines-*, + cppcoreguidelines-owning-memory, + cppcoreguidelines-pro-bounds-array-to-pointer-decay, + cppcoreguidelines-pro-bounds-constant-array-index, + cppcoreguidelines-pro-type-cstyle-cast, + cppcoreguidelines-pro-type-member-init, + cppcoreguidelines-no-malloc, + + # Performance and safety + performance-*, + readability-*, + hicpp-*, + bugprone-*, + misc-*, + + # Remove unnecessary code + readability-redundant-* + + # Optional - highly aggressive rules (uncomment if needed) + #clang-analyzer-*, + +WarningsAsErrors: '*' +HeaderFilterRegex: '.*' +AnalyzeTemporaryDtors: true +FormatStyle: file +CheckOptions: + - key: modernize-use-auto.MinTypeNameLength + value: '4' # Avoid auto for short types like int, bool + - key: cppcoreguidelines-pro-bounds-pointer-arithmetic.Strict + value: 'true' + - key: modernize-loop-convert.IgnoreUserDefined + value: 'false' + - key: readability-function-cognitive-complexity.Threshold + value: '25' + - key: modernize-use-emplace.Hint + value: 'false' + - key: cppcoreguidelines-init-variables.Suppress + value: 'false' + - key: modernize-avoid-c-arrays.StrictMode + value: 'true' + diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml new file mode 100644 index 00000000..8dbd0608 --- /dev/null +++ b/.github/workflows/linter.yml @@ -0,0 +1,32 @@ +name: Run Clang-tidy Check + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + clang-tidy-check: + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Install Clang-Tidy + run: | + sudo apt-get update + sudo apt-get install -y clang-tidy-14 + + - name: Configure with CMake + run: | + cmake -S . -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug + + - name: Run Clang-Tidy + run: | + clang-tidy --version # Verify installed version + clang-tidy -p build $(find ADOL-C/src/ -name '*.cpp' -o -name '*.c' -o -name '*.hpp' -o -name '*.h') + clang-tidy -p build $(find ADOL-C/include/ -name '*.cpp' -o -name '*.c' -o -name '*.hpp' -o -name '*.h') + clang-tidy -p build $(find ADOL-C/c_interface -name '*.cpp' -o -name '*.c' -o -name '*.hpp' -o -name '*.h') + +