forked from Exawind/amr-wind
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add clang-tidy to CMake and CI (Exawind#294)
Co-authored-by: Shreyas Ananthan <[email protected]>
- Loading branch information
1 parent
29a7089
commit 04453b8
Showing
8 changed files
with
135 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--- | ||
#Checks: '*,-cppcoreguidelines-avoid-magic-numbers,-readability-magic-numbers,-readability-braces-around-statements,-fuchsia-default-arguments,-fuchsia-default-arguments-calls,-fuchsia-overloaded-operator,-fuchsia-statically-constructed-objects,-google-runtime-references,-hicpp-no-assembler,-llvm-include-order,-llvmlibc-callee-namespace,-llvmlibc-implementation-in-namespace,-llvmlibc-restrict-system-libc-headers' | ||
Checks: 'clang-diagnostic-*,clang-analyzer-*,corecppguidelines-*,modernize-*,readability-*' | ||
WarningsAsErrors: '' | ||
#HeaderFilterRegex: '^.*/(AMReX)/.*\.H$' | ||
HeaderFilterRegex: '^((?!/amrex/Src/|/googletest/).)*$' | ||
AnalyzeTemporaryDtors: false | ||
FormatStyle: none | ||
User: user | ||
CheckOptions: | ||
- key: cert-dcl16-c.NewSuffixes | ||
value: 'L;LL;LU;LLU' | ||
- key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField | ||
value: '0' | ||
- key: cert-str34-c.DiagnoseSignedUnsignedCharComparisons | ||
value: '0' | ||
- key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors | ||
value: '1' | ||
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic | ||
value: '1' | ||
- key: google-readability-braces-around-statements.ShortStatementLines | ||
value: '1' | ||
- key: google-readability-function-size.StatementThreshold | ||
value: '800' | ||
- key: google-readability-namespace-comments.ShortNamespaceLines | ||
value: '10' | ||
- key: google-readability-namespace-comments.SpacesBeforeComments | ||
value: '2' | ||
- key: llvm-else-after-return.WarnOnConditionVariables | ||
value: '0' | ||
- key: llvm-else-after-return.WarnOnUnfixable | ||
value: '0' | ||
- key: llvm-qualified-auto.AddConstToQualified | ||
value: '0' | ||
- key: modernize-loop-convert.MaxCopySize | ||
value: '16' | ||
- key: modernize-loop-convert.MinConfidence | ||
value: reasonable | ||
- key: modernize-loop-convert.NamingStyle | ||
value: CamelCase | ||
- key: modernize-pass-by-value.IncludeStyle | ||
value: llvm | ||
- key: modernize-replace-auto-ptr.IncludeStyle | ||
value: llvm | ||
- key: modernize-use-nullptr.NullMacros | ||
value: 'NULL' | ||
- { key: readability-identifier-naming.NamespaceCase, value: lower_case } | ||
- { key: readability-identifier-naming.ClassCase, value: CamelCase } | ||
- { key: readability-identifier-naming.PrivateMemberPrefix, value: m_ } | ||
- { key: readability-identifier-naming.ProtectedMemberPrefix, value: m_ } | ||
- { key: readability-identifier-naming.StructCase, value: CamelCase } | ||
- { key: readability-identifier-naming.FunctionCase, value: lower_case } | ||
- { key: readability-identifier-naming.VariableCase, value: lower_case } | ||
- { key: readability-identifier-naming.GlobalConstantCase, value: UPPER_CASE } | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ on: | |
- '.github/workflows/ci.yml' | ||
|
||
jobs: | ||
build: | ||
Build: | ||
runs-on: ${{matrix.os}} | ||
strategy: | ||
matrix: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ on: | |
- '.github/workflows/lint.yml' | ||
|
||
jobs: | ||
Lint: | ||
cppcheck: | ||
runs-on: macos-latest | ||
steps: | ||
- name: Cancel previous runs | ||
|
@@ -39,15 +39,15 @@ jobs: | |
run: | | ||
echo "NPROCS=$(sysctl -n hw.ncpu)" >> $GITHUB_ENV | ||
cmake \ | ||
-Bbuild-lint \ | ||
-Bbuild-cppcheck \ | ||
-DAMR_WIND_ENABLE_MPI:BOOL=OFF \ | ||
-DAMR_WIND_ENABLE_TESTS:BOOL=ON \ | ||
-DAMR_WIND_TEST_WITH_FCOMPARE:BOOL=OFF \ | ||
-DAMR_WIND_ENABLE_MASA:BOOL=OFF \ | ||
-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON \ | ||
${{github.workspace}} | ||
- name: Check | ||
working-directory: build-lint | ||
working-directory: build-cppcheck | ||
run: | | ||
# Using a working directory for cppcheck makes analysis faster | ||
mkdir cppcheck-wd | ||
|
@@ -61,15 +61,56 @@ jobs: | |
# Warnings in header files are unavoidable, so we filter out submodule headers after analysis | ||
# Might be wrong to assume cppcheck always reports issues using 3 lines | ||
awk -v nlines=2 '/submods\/amrex/ || /submods\/googletest/ {for (i=0; i<nlines; i++) {getline}; next} 1' \ | ||
< cppcheck.txt > amr-wind-static-analysis.txt | ||
- name: Report | ||
working-directory: build-lint | ||
< cppcheck.txt > cppcheck-warnings.txt | ||
- name: Short report | ||
working-directory: build-cppcheck | ||
run: | | ||
cat cppcheck-warnings.txt | egrep 'error:|performance:|portability:|style:|warning:' | sort | \ | ||
awk 'BEGIN{i=0}{print $0}{i++}END{print "Warnings: "i}' | ||
- name: Full report | ||
working-directory: build-cppcheck | ||
run: | | ||
echo "::add-matcher::.github/problem-matchers/gcc.json" | ||
# Might be wrong to assume cppcheck always reports issues using 3 lines | ||
WARNINGS_TMP=$(wc -l < amr-wind-static-analysis.txt | xargs echo -n) | ||
WARNINGS=$(bc <<< "$WARNINGS_TMP/3") | ||
printf "%s warnings\n" "${WARNINGS}" >> amr-wind-static-analysis.txt | ||
cat amr-wind-static-analysis.txt | ||
# Just report for now and don't fail | ||
#exit ${WARNINGS} | ||
cat cppcheck-warnings.txt | ||
clang-tidy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Cancel previous runs | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{github.token}} | ||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: true | ||
- name: Dependencies | ||
run: | | ||
sudo apt-get install -y clang-tidy-9 | ||
sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-9 100 | ||
- name: Configure | ||
run: | | ||
echo "NPROCS=$(nproc)" >> $GITHUB_ENV | ||
cmake \ | ||
-Bbuild-clang-tidy \ | ||
-DCMAKE_CXX_COMPILER:STRING=clang++ \ | ||
-DCMAKE_C_COMPILER:STRING=clang \ | ||
-DAMR_WIND_ENABLE_MPI:BOOL=OFF \ | ||
-DAMR_WIND_ENABLE_TESTS:BOOL=ON \ | ||
-DAMR_WIND_TEST_WITH_FCOMPARE:BOOL=OFF \ | ||
-DAMR_WIND_ENABLE_MASA:BOOL=OFF \ | ||
-DAMR_WIND_ENABLE_ALL_WARNINGS:BOOL=OFF \ | ||
-DAMR_WIND_ENABLE_CLANG_TIDY:BOOL=ON \ | ||
-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON \ | ||
${{github.workspace}} | ||
- name: Check | ||
working-directory: build-clang-tidy | ||
run: cmake --build . -- -j ${{env.NPROCS}} 2> clang-tidy-warnings.txt | ||
- name: Short report | ||
working-directory: build-clang-tidy | ||
run: | | ||
cat clang-tidy-warnings.txt | grep "warning:" | sort | \ | ||
awk 'BEGIN{i=0}{print $0}{i++}END{print "Warnings: "i}' | ||
- name: Full report | ||
working-directory: build-clang-tidy | ||
run: | | ||
#echo "::add-matcher::.github/problem-matchers/gcc.json" | ||
cat clang-tidy-warnings.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters