Skip to content

Commit

Permalink
Merge branch 'clang-tidy' into 'master'
Browse files Browse the repository at this point in the history
Code quality improvements

See merge request walberla/walberla!699
  • Loading branch information
modkin committed Dec 17, 2024
2 parents d37687b + bc2d4e6 commit f36fa0a
Show file tree
Hide file tree
Showing 146 changed files with 768 additions and 794 deletions.
31 changes: 26 additions & 5 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,30 @@ Checks: '
-*,
boost-*,
-boost-use-ranges,
bugprone-*,
-bugprone-branch-clone,
-bugprone-exception-escape,
-bugprone-easily-swappable-parameters,
-bugprone-crtp-constructor-accessibility,
-bugprone-implicit-widening-of-multiplication-result,
-bugprone-macro-parentheses,
-bugprone-narrowing-conversions,
-bugprone-switch-missing-default-case,
-bugprone-assignment-in-if-condition,
-bugprone-reserved-identifier,
misc-*,
-misc-misplaced-const,
-misc-const-correctness,
-misc-unused-parameters,
-misc-no-recursion,
-misc-non-private-member-variables-in-classes,
-misc-include-cleaner,
-misc-header-include-cycle,
-misc-use-internal-linkage,
-misc-use-anonymous-namespace,
modernize-*,
-modernize-use-auto,
Expand All @@ -23,12 +37,18 @@ modernize-*,
-modernize-use-using,
-modernize-avoid-bind,
-modernize-return-braced-init-list,
-modernize-min-max-use-initializer-list,
-modernize-use-transparent-functors,
-modernize-redundant-void-arg,
-modernize-use-trailing-return-type,
-modernize-use-default-member-init,
-modernize-use-equals-delete,
-modernize-macro-to-enum,
-modernize-avoid-c-arrays,
-modernize-concat-nested-namespaces,
-modernize-use-nodiscard,
-modernize-type-traits,
-modernize-make-shared,
mpi-*,
-mpi-type-mismatch,
Expand All @@ -38,25 +58,26 @@ openmp-*,
-openmp-use-default-none,
performance-*,
-performance-enum-size,
-performance-noexcept-swap,
-performance-move-const-arg,
-performance-unnecessary-value-param,
-performance-avoid-endl,
-performance-no-int-to-ptr,
portability-*,
readability-const-return-type,
readability-container-size-empty,
readability-delete-null-pointer,
readability-deleted-default,
readability-isolate-declaration,
readability-misleading-indentation,
readability-misplaced-array-index,
readability-non-const-parameter,
readability-redundant-access-specifiers,
readability-redundant-control-flow,
readability-redundant-declaration,
readability-redundant-function-ptr-dereference,
readability-redundant-preprocessor,
readability-redundant-smartptr-get,
readability-redundant-string-cstr,
readability-simplify-boolean-expr,
readability-simplify-subscript-expr,
readability-static-accessed-through-instance,
readability-static-definition-in-anonymous-namespace,
Expand Down
35 changes: 17 additions & 18 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2035,24 +2035,23 @@ doc:
## ##
###############################################################################

#clang-tidy:
# image: i10git.cs.fau.de:5005/walberla/buildenvs/clang-15
# script:
# - $CXX --version
# - clang-tidy -version
# - cmake --version
# - mkdir $CI_PROJECT_DIR/build
# - cd $CI_PROJECT_DIR/build
# - cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DWALBERLA_BUFFER_DEBUG=ON -DWALBERLA_BUILD_TESTS=ON -DWALBERLA_BUILD_BENCHMARKS=ON -DWALBERLA_BUILD_TUTORIALS=ON -DWALBERLA_BUILD_TOOLS=ON -DWALBERLA_BUILD_WITH_MPI=ON -DWALBERLA_BUILD_WITH_OPENMP=ON -DCMAKE_BUILD_TYPE=Debug -DWALBERLA_BUILD_WITH_METIS=ON -DWALBERLA_BUILD_WITH_PARMETIS=ON -DWALBERLA_BUILD_WITH_OPENMESH=ON -DWALBERLA_DOUBLE_ACCURACY=ON -DWALBERLA_LOGLEVEL=DETAIL
# - cmake . -LA
# - utilities/filterCompileCommands.py compile_commands.json
# - wget https://raw.githubusercontent.com/llvm/llvm-project/main/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
# - python3 run-clang-tidy.py -quiet | tee clang-tidy-output.txt
# artifacts:
# paths:
# - $CI_PROJECT_DIR/build/clang-tidy-output.txt
# tags:
# - docker
clang-tidy:
image: i10git.cs.fau.de:5005/walberla/buildenvs/clang-17
script:
- $CXX --version
- clang-tidy -version
- cmake --version
- mkdir $CI_PROJECT_DIR/build
- cd $CI_PROJECT_DIR/build
- cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DWALBERLA_BUFFER_DEBUG=ON -DWALBERLA_BUILD_TESTS=ON -DWALBERLA_BUILD_BENCHMARKS=ON -DWALBERLA_BUILD_TUTORIALS=ON -DWALBERLA_BUILD_TOOLS=ON -DWALBERLA_BUILD_WITH_MPI=ON -DWALBERLA_BUILD_WITH_OPENMP=ON -DCMAKE_BUILD_TYPE=Debug -DWALBERLA_BUILD_WITH_METIS=ON -DWALBERLA_BUILD_WITH_PARMETIS=ON -DWALBERLA_BUILD_WITH_OPENMESH=ON -DWALBERLA_DOUBLE_ACCURACY=ON -DWALBERLA_LOGLEVEL=DETAIL
- cmake . -LA
- utilities/filterCompileCommands.py --file compile_commands.json --exclude "*" --include src/core src/field src/stencil src/blockforest src/domain_decomposition src/communication src/gpu src/vtk src/fft --exclude extern tests
- run-clang-tidy -quiet | tee clang-tidy-output.txt
artifacts:
paths:
- $CI_PROJECT_DIR/build/clang-tidy-output.txt
tags:
- docker


cppcheck:
Expand Down
12 changes: 6 additions & 6 deletions apps/benchmarks/FluidParticleCouplingWithLoadBalancing/Utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ namespace amr {
* Result from the workload evaluation as described in
* Rettinger, Ruede - "Dynamic Load Balancing Techniques for Particulate Flow Simulations", 2019, Computation
*/
real_t fittedLBMWeightEvaluationFunction(const BlockInfo& blockInfo)
inline real_t fittedLBMWeightEvaluationFunction(const BlockInfo& blockInfo)
{
uint_t Ce = blockInfo.numberOfCells;
uint_t F = blockInfo.numberOfFluidCells;
real_t weight = real_t(7.597476065046571e-06) * real_c(Ce) + real_t(8.95723566283202e-05) * real_c(F) + real_t(-0.1526111388616016);
return std::max(weight,real_t(0));
}
real_t fittedBHWeightEvaluationFunction(const BlockInfo& blockInfo)
inline real_t fittedBHWeightEvaluationFunction(const BlockInfo& blockInfo)
{
uint_t Ce = blockInfo.numberOfCells;
uint_t NB = blockInfo.numberOfNearBoundaryCells;
real_t weight = real_t(1.3067711379655123e-07) * real_c(Ce) + real_t(0.0007289549127205142) * real_c(NB) + real_t(-0.1575698071795788);
return std::max(weight,real_t(0));
}
real_t fittedRPDWeightEvaluationFunction(const BlockInfo& blockInfo)
inline real_t fittedRPDWeightEvaluationFunction(const BlockInfo& blockInfo)
{
uint_t Pl = blockInfo.numberOfLocalParticles;
uint_t Pg = blockInfo.numberOfGhostParticles;
Expand All @@ -36,7 +36,7 @@ real_t fittedRPDWeightEvaluationFunction(const BlockInfo& blockInfo)
real_t weight = real_c(Sc) * ( cPlPg2 * real_c(Pl+Pg) * real_c(Pl+Pg) + cPl * real_c(Pl) + cPg * real_c(Pg) + c );
return std::max(weight,real_t(0));
}
real_t fittedCoup1WeightEvaluationFunction(const BlockInfo& blockInfo)
inline real_t fittedCoup1WeightEvaluationFunction(const BlockInfo& blockInfo)
{
uint_t Ce = blockInfo.numberOfCells;
uint_t F = blockInfo.numberOfFluidCells;
Expand All @@ -45,7 +45,7 @@ real_t fittedCoup1WeightEvaluationFunction(const BlockInfo& blockInfo)
real_t weight = real_t(5.610203409278647e-06) * real_c(Ce) + real_t(-7.257635845636656e-07) * real_c(F) + real_t(0.02049703546054693) * real_c(Pl) + real_t(0.04248208493809902) * real_c(Pg) + real_t(-0.26609470510074784);
return std::max(weight,real_t(0));
}
real_t fittedCoup2WeightEvaluationFunction(const BlockInfo& blockInfo)
inline real_t fittedCoup2WeightEvaluationFunction(const BlockInfo& blockInfo)
{
uint_t Ce = blockInfo.numberOfCells;
uint_t F = blockInfo.numberOfFluidCells;
Expand All @@ -54,7 +54,7 @@ real_t fittedCoup2WeightEvaluationFunction(const BlockInfo& blockInfo)
real_t weight = real_t(7.198479654682179e-06) * real_c(Ce) + real_t(1.178247475854302e-06) * real_c(F) + real_t(-0.0026401549115124628) * real_c(Pl) + real_t(0.008459646786179298) * real_c(Pg) + real_t(-0.001077320113275954);
return std::max(weight,real_t(0));
}
real_t fittedTotalWeightEvaluationFunction(const BlockInfo& blockInfo)
inline real_t fittedTotalWeightEvaluationFunction(const BlockInfo& blockInfo)
{
return fittedLBMWeightEvaluationFunction(blockInfo) + fittedBHWeightEvaluationFunction(blockInfo) +
fittedRPDWeightEvaluationFunction(blockInfo) + fittedCoup1WeightEvaluationFunction(blockInfo) +
Expand Down
2 changes: 1 addition & 1 deletion apps/benchmarks/GranularGas/check.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
namespace walberla {
namespace mesa_pd {

void check( data::ParticleStorage& ps, blockforest::BlockForest& forest, real_t spacing, const Vec3& shift )
inline void check( data::ParticleStorage& ps, blockforest::BlockForest& forest, real_t spacing, const Vec3& shift )
{
WALBERLA_LOG_INFO_ON_ROOT("*** CHECKING RESULT - START ***");
auto pIt = ps.begin();
Expand Down
2 changes: 1 addition & 1 deletion apps/showcases/HeatConduction/ThermalExpansion.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ThermalExpansion
std::vector<real_t> linearExpansionCoefficient_ {};
};

ThermalExpansion::ThermalExpansion(const uint_t numParticleTypes)
inline ThermalExpansion::ThermalExpansion(const uint_t numParticleTypes)
{
numParticleTypes_ = numParticleTypes;

Expand Down
Loading

0 comments on commit f36fa0a

Please sign in to comment.