Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clang-tidy CI test #56

Open
wants to merge 88 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 86 commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
8b9662f
initial work to add clang-tidy workflow
lucafedeli88 Aug 30, 2024
38a7c8f
add permission to run script
lucafedeli88 Aug 30, 2024
4f3339e
add missing dependencies
lucafedeli88 Aug 30, 2024
7f3336b
update clang-tidy config
lucafedeli88 Aug 30, 2024
757413c
start fixing issues with braces
lucafedeli88 Sep 5, 2024
63468bd
continue fixing issues with braces
lucafedeli88 Sep 5, 2024
61634f4
continue fixing issues with braces
lucafedeli88 Sep 5, 2024
43fda0b
fail if clang-tidy finds something wrong
lucafedeli88 Sep 5, 2024
b444f33
add more braces
lucafedeli88 Sep 5, 2024
2544c32
add more braces
lucafedeli88 Sep 5, 2024
fbf815e
fix an performance-type-promotion-in-math-fn issue
lucafedeli88 Sep 5, 2024
562fdd9
address modernize-concat-nested-namespaces issues
lucafedeli88 Oct 22, 2024
0bb7463
move to C++17
lucafedeli88 Oct 22, 2024
4ff832b
add [[nodiscard]] in picsar_array.hpp
lucafedeli88 Oct 22, 2024
beb9374
fix some bugprone-narrowing-conversions issues
lucafedeli88 Oct 22, 2024
c8d0252
add [[nodiscard]] in picsar_span.hpp
lucafedeli88 Oct 22, 2024
33a6353
fix modernize-use-equals-default issues
lucafedeli88 Oct 22, 2024
62ef7a6
fix readability-qualified-auto issue
lucafedeli88 Oct 22, 2024
1d161c0
fix readability-braces-around-statements issues
lucafedeli88 Oct 22, 2024
29ed073
fix readability-braces-around-statements issues
lucafedeli88 Oct 22, 2024
17f5ef0
fix readability-braces-around-statements issues
lucafedeli88 Oct 22, 2024
cf80b72
fix readability-braces-around-statements issues
lucafedeli88 Oct 22, 2024
c9c4914
add [[nodiscard]] in picsar_tables.hpp
lucafedeli88 Oct 22, 2024
3dc4545
fix bug
lucafedeli88 Oct 23, 2024
0242df9
fix modernize-use-auto issues
lucafedeli88 Oct 23, 2024
d848a6c
fix narrowing conversion issue
lucafedeli88 Oct 23, 2024
8acdb09
fix modernize-concat-nested-namespaces issue
lucafedeli88 Oct 23, 2024
22d421e
fix readability-avoid-const-params-in-decls issues
lucafedeli88 Oct 23, 2024
064d17a
fix performance-type-promotion-in-math-fn issues
lucafedeli88 Oct 23, 2024
2ab3507
fix const correctness
lucafedeli88 Oct 23, 2024
e44c96c
fix modernize-use-using issues
lucafedeli88 Oct 23, 2024
05389c5
add [[nodiscard]] in engine tables
lucafedeli88 Oct 23, 2024
800b486
fix bug
lucafedeli88 Oct 23, 2024
bf96619
fix readability-braces-around-statements issues
lucafedeli88 Oct 23, 2024
5a6532d
fix performance-unnecessary-value-param
lucafedeli88 Oct 23, 2024
121a0a1
fix cppcoreguidelines-prefer-member-initializer issue
lucafedeli88 Oct 23, 2024
2d7b9b8
add [[nodiscard]]
lucafedeli88 Oct 23, 2024
a247809
fix const correctness
lucafedeli88 Oct 23, 2024
2ebfa8b
fix bugprone-integer-division issue
lucafedeli88 Oct 23, 2024
63dc2e9
fix bug
lucafedeli88 Oct 23, 2024
e405629
fix performance-type-promotion-in-math-fn issue
lucafedeli88 Oct 23, 2024
2ef84da
fix bugprone-branch-clone issue
lucafedeli88 Oct 23, 2024
0c333d0
fix cppcoreguidelines-prefer-member-initializer issues
lucafedeli88 Oct 23, 2024
38605d8
fix cppcoreguidelines-prefer-member-initializer issue
lucafedeli88 Oct 23, 2024
2049502
fix modernize auto issue
lucafedeli88 Oct 23, 2024
18b0d3a
fix const correctness
lucafedeli88 Oct 23, 2024
782c6f6
fix misc-const-correctness issue
lucafedeli88 Oct 23, 2024
92af6f8
address readability-braces-around-statements issues
lucafedeli88 Oct 23, 2024
047336c
fix some const correctness issues
lucafedeli88 Oct 23, 2024
b03dc6d
fix bug
lucafedeli88 Oct 23, 2024
8eda0b9
fix bugprone-reserved-identifier issue
lucafedeli88 Oct 23, 2024
80783fd
fix modernize-use-nodiscard issues
lucafedeli88 Oct 23, 2024
8d90f97
fix const correctness issues
lucafedeli88 Oct 23, 2024
e02016e
replace PXRMP_CONSTEXPR_IF with if constexpr (we are moving to C++17)
lucafedeli88 Oct 23, 2024
e464303
address bugprone-exception-escape issue
lucafedeli88 Oct 24, 2024
da87781
address readability-avoid-const-params-in-decls issues
lucafedeli88 Oct 24, 2024
0193e77
fix bugprone-reserved-identifier issue
lucafedeli88 Oct 24, 2024
e974367
address readability-qualified-auto issues
lucafedeli88 Oct 24, 2024
332b759
address readability-string-compare issues
lucafedeli88 Oct 24, 2024
047037d
address readability-misleading-indentation issue
lucafedeli88 Oct 24, 2024
822a8a0
address modernize-use-using issues
lucafedeli88 Oct 24, 2024
dc1aa24
fix some cppcoreguidelines-prefer-member-initializer issues
lucafedeli88 Oct 24, 2024
c0ea38c
fix some modernize-pass-by-value issues
lucafedeli88 Oct 24, 2024
eada652
fix const correctness and bugprone-exception-escape issues
lucafedeli88 Oct 24, 2024
36bc599
fix more const correctness issues
lucafedeli88 Oct 24, 2024
af29d3a
address some cppcoreguidelines-prefer-member-initializer issues
lucafedeli88 Oct 24, 2024
1f03ad7
address readability-suspicious-call-argument issues
lucafedeli88 Oct 24, 2024
27e4bcf
fix cppcoreguidelines-prefer-member-initializer issues
lucafedeli88 Oct 24, 2024
06a6de6
address unused variable issue
lucafedeli88 Oct 24, 2024
934d507
try to address issue of function that may throw exception
lucafedeli88 Oct 24, 2024
7a76688
fix miscellaneous issues
lucafedeli88 Oct 29, 2024
ec9de63
fix readability-duplicate-include issue
lucafedeli88 Oct 29, 2024
6e69af6
fix performance-type-promotion-in-math-fn issue
lucafedeli88 Oct 29, 2024
aad87d8
address bugprone-integer-division issues
lucafedeli88 Oct 29, 2024
1c27c38
fix misc-unused-alias-decls issue
lucafedeli88 Oct 29, 2024
ee80a90
attempt to fix a performance-unnecessary-copy-initialization issue
lucafedeli88 Oct 29, 2024
285cd75
fix miscellaneous issues
lucafedeli88 Oct 29, 2024
dc5b557
fix miscellaneous issues
lucafedeli88 Oct 29, 2024
917b8c9
fix bugprone-narrowing-conversions issues
lucafedeli88 Oct 30, 2024
ccf4149
fix performance-unnecessary-value-param and bugprone-narrowing-conver…
lucafedeli88 Oct 30, 2024
f739cc1
fix miscellaneous issues
lucafedeli88 Oct 30, 2024
7185213
fix bugprone-exception-escape issues
lucafedeli88 Oct 30, 2024
6396287
fix bugs
lucafedeli88 Oct 30, 2024
4c4bee9
fix issue in doc
lucafedeli88 Oct 30, 2024
31cb60f
add space at the end of the file
lucafedeli88 Oct 30, 2024
271b874
add NOLINT
lucafedeli88 Oct 30, 2024
d810ea7
Update .github/workflows/clang_tidy.yml
lucafedeli88 Nov 22, 2024
7eddfc1
Update .github/workflows/dependencies/clang15.sh
lucafedeli88 Nov 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
Checks: '
-*,
bugprone-*,
-bugprone-easily-swappable-parameters,
-bugprone-implicit-widening-of-multiplication-result,
-bugprone-misplaced-widening-cast,
-bugprone-unchecked-optional-access,
cert-*,
-cert-err58-cpp,
clang-analyzer-*,
-clang-analyzer-optin.performance.Padding,
-clang-analyzer-optin.mpi.MPI-Checker,
-clang-analyzer-osx.*,
-clang-analyzer-optin.osx.*,
clang-diagnostic-*,
cppcoreguidelines-*,
-cppcoreguidelines-avoid-c-arrays,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-avoid-non-const-global-variables,
-cppcoreguidelines-init-variables,
-cppcoreguidelines-macro-usage,
-cppcoreguidelines-narrowing-conversions,
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-owning-memory,
-cppcoreguidelines-pro-*,
google-build-explicit-make-pair,
google-build-namespaces,
google-global-names-in-headers,
misc-*,
-misc-no-recursion,
-misc-non-private-member-variables-in-classes,
modernize-*,
-modernize-avoid-c-arrays,
-modernize-return-braced-init-list,
-modernize-use-trailing-return-type,
mpi-*,
performance-*,
portability-*,
readability-*,
-readability-convert-member-functions-to-static,
-readability-else-after-return,
-readability-function-cognitive-complexity,
-readability-identifier-length,
-readability-implicit-bool-conversion,
-readability-isolate-declaration,
-readability-magic-numbers,
-readability-named-parameter,
-readability-uppercase-literal-suffix
'

CheckOptions:
- key: bugprone-narrowing-conversions.WarnOnIntegerToFloatingPointNarrowingConversion
value: "false"
- key: misc-definitions-in-headers.HeaderFileExtensions
value: "H,"
- key: modernize-pass-by-value.ValuesOnly
value: "true"


HeaderFilterRegex: 'multi_physics[a-z_A-Z0-9\/]+\.hp?p?$'
46 changes: 46 additions & 0 deletions .github/workflows/clang_tidy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: 🧹 clang-tidy

on: [push, pull_request]

jobs:
run_clang_tidy:
name: clang-tidy
runs-on: ubuntu-22.04
env: {CXXFLAGS: "-Werror -Wshadow -Woverloaded-virtual -Wunreachable-code -fsanitize=address -fsanitize=undefined"}
steps:
- uses: actions/checkout@v4
- name: install dependencies
run: .github/workflows/dependencies/clang15.sh
- name: Build & run clang-tidy
run: |

export CXX=$(which clang++-15)
export CC=$(which clang-15)


# The following wrapper ensures that only source files
# in WarpX/Source/* are actually processed by clang-tidy
lucafedeli88 marked this conversation as resolved.
Show resolved Hide resolved
#_______________________________
cat > clang_tidy_wrapper << EOF
#!/bin/bash
REGEX="[a-z_A-Z0-9\/]*multi_physics\/[a-z_A-Z0-9\/]+.cpp"
if [[ \$4 =~ \$REGEX ]];then
clang-tidy-15 \$@
fi
EOF
chmod +x clang_tidy_wrapper
#_____________________________________

rm -rf build_clang_tidy

cmake -S multi_physics/QED \
-DCMAKE_CXX_CLANG_TIDY="$PWD/clang_tidy_wrapper;--system-headers=0;--config-file=$PWD/.clang-tidy" \
-B build_clang_tidy \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DPXRMP_QED_TEST=ON \
-DPXRMP_KOKKOS_EXAMPLE=ON \
-DKokkos_ENABLE_OPENMP=ON

cmake --build build_clang_tidy -j 4 2> build_clang_tidy/clang-tidy.log
cat build_clang_tidy/clang-tidy.log
if [[ $(wc -m <build_clang_tidy/clang-tidy.log) -gt 1 ]]; then exit 1; fi
30 changes: 30 additions & 0 deletions .github/workflows/dependencies/clang15.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
#
# Copyright 2023 The WarpX Community
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be BLAST instead of WarpX from now on?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right

lucafedeli88 marked this conversation as resolved.
Show resolved Hide resolved
#
# License: BSD-3-Clause-LBNL
# Authors: Luca Fedeli

set -eu -o pipefail

# `man apt.conf`:
# Number of retries to perform. If this is non-zero APT will retry
# failed files the given number of times.
echo 'Acquire::Retries "3";' | sudo tee /etc/apt/apt.conf.d/80-retries

sudo apt-get -qqq update
sudo apt-get install -y \
build-essential \
cmake \
clang-15 \
clang-tidy-15 \
libblas-dev \
libc++-15-dev \
libboost-dev \
libboost-math-dev \
libboost-test-dev \
libomp-15-dev \
python3-dev

python3 -m pip install -U pip
python3 -m pip install "pybind11[global]"
4 changes: 2 additions & 2 deletions multi_physics/QED/QED_table_generator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ set_target_properties(${name} PROPERTIES
configure_file(table_inspector.ipynb
${CMAKE_BINARY_DIR}/tools/table_inspector.ipynb COPYONLY)

# Require C++14 or newer
target_compile_features(${name} PUBLIC cxx_std_14)
# Require C++17 or newer
target_compile_features(${name} PUBLIC cxx_std_17)
set_target_properties(${name} PROPERTIES CXX_EXTENSIONS OFF)

# Enable warnings
Expand Down
Loading
Loading