Skip to content

Commit

Permalink
Merge pull request #83 from TimSiebert1/add_linter
Browse files Browse the repository at this point in the history
Add clang-tidy workflow
  • Loading branch information
TimSiebert1 authored Nov 21, 2024
2 parents ef15a3b + fbd8948 commit 7d5b9fd
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 0 deletions.
64 changes: 64 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -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'

32 changes: 32 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -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')

0 comments on commit 7d5b9fd

Please sign in to comment.