From e377ce463ddf5094372969ea6a9d0642cc7733cf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jean-No=C3=ABl=20Grad?= <jgrad@icp.uni-stuttgart.de>
Date: Wed, 20 Nov 2024 14:02:10 +0100
Subject: [PATCH] Fix various Clang-Tidy diagnostics

Address most occurrences of:
bugprone-unused-local-non-trivial-variable
bugprone-unhandled-self-assignment
bugprone-misplaced-widening-cast
bugprone-sizeof-expression
performance-for-range-copy
performance-faster-string-find
performance-inefficient-vector-operation
performance-noexcept-swap
misc-unused-using-decls
misc-header-include-cycle
misc-include-cleaner
readability-delete-null-pointer
readability-container-size-empty
readability-redundant-smartptr-get
readability-else-after-return
---
 .clang-tidy                                   | 30 +++++++++++++++---
 .../templates/CpuPackInfo.tmpl.cpp            |  6 ++--
 .../templates/GpuPackInfo.tmpl.cpp            |  7 +++++
 .../templates/GpuPackInfo.tmpl.h              |  1 -
 .../communication/NonUniformBufferedScheme.h  |  4 +--
 src/core/Array.h                              |  4 +--
 src/core/Set.h                                |  2 +-
 src/core/StringUtility.impl.h                 |  2 --
 src/core/cell/CellInterval.h                  |  1 +
 src/core/debug/PrintStacktrace.cpp            |  7 +++--
 src/core/math/Matrix2.h                       |  4 +--
 src/core/math/extern/exprtk.h                 | 21 +++++++------
 src/core/mpi/BufferSystem.impl.h              | 31 ++++++++++---------
 src/core/mpi/RecvBuffer.h                     |  4 +--
 src/core/mpi/SendBuffer.h                     |  2 +-
 src/core/timing/TimingNode.h                  |  7 +++--
 src/core/timing/TimingTree.h                  |  7 +++--
 src/core/uid/UIDGenerators.h                  |  6 ++--
 src/core/waLBerlaBuildInfo.in.cpp             |  1 +
 src/domain_decomposition/IBlock.h             | 12 ++++---
 src/field/adaptors/GhostLayerFieldAdaptor.h   |  4 +--
 src/field/vtk/FlagFieldMapping.h              |  4 +--
 src/field/vtk/VTKWriter.h                     |  9 ++----
 src/gather/CellGatherPackInfo.impl.h          |  2 +-
 src/gather/CurveGatherPackInfo.impl.h         |  2 +-
 .../BoundarySetterFlagFieldSpecialization.h   |  4 +--
 .../initializer/ScalarFieldFromBody.impl.h    |  4 ++-
 src/gpu/DeviceWrapper.h                       |  2 ++
 src/lbm/boundary/ParserUBB.h                  |  6 ++--
 .../FreeSurfaceBoundaryHandling.impl.h        |  2 ++
 .../surface_geometry/CurvatureSweep.impl.h    |  4 +--
 src/lbm/vtk/QCriterion.h                      |  2 +-
 .../overlapping/shapes/BoxWithOverlap.h       |  2 ++
 .../shapes/CylindricalBoundaryWithOverlap.h   |  2 ++
 .../overlapping/shapes/EllipsoidWithOverlap.h |  2 ++
 .../overlapping/shapes/HalfSpaceWithOverlap.h |  2 ++
 .../overlapping/shapes/SphereWithOverlap.h    |  2 ++
 src/mesa_pd/vtk/ParticleVtkOutput.cpp         |  1 +
 src/pe/Types.h                                |  1 +
 src/pe/raytracing/Raytracer.h                 |  2 +-
 src/pe/rigidbody/RigidBodyCastIterator.h      |  4 +--
 src/python_coupling/export/FieldExport.impl.h |  2 ++
 src/stencil/Directions.h                      |  4 +--
 src/vtk/Base64Writer.h                        |  2 +-
 src/vtk/VTKOutput.cpp                         |  2 +-
 tests/field/FieldOfCustomTypesTest.cpp        |  6 ----
 tests/field/FlagFieldTest.cpp                 | 10 ++----
 tests/lbm/evaluations/PermeabilityTest.cpp    |  2 --
 tests/pe/MinMaxRefinement.cpp                 | 18 +++++------
 tests/pe/Refinement.cpp                       |  4 +--
 tests/pe/SyncEquivalence.cpp                  |  2 +-
 tests/postprocessing/SphereTriangulate.cpp    | 10 ++----
 tests/simd/SIMD_Equivalence.cpp               |  2 +-
 tests/stencil/StencilTest.cpp                 |  3 --
 54 files changed, 163 insertions(+), 126 deletions(-)

diff --git a/.clang-tidy b/.clang-tidy
index f0e5933ad..74d1c6cf5 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -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,
@@ -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,
@@ -38,25 +58,25 @@ openmp-*,
 -openmp-use-default-none,
 
 performance-*,
+-performance-enum-size,
+-performance-noexcept-swap,
+-performance-move-const-arg,
+-performance-unnecessary-value-param,
+-performance-avoid-endl,
 
 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,
diff --git a/python/pystencils_walberla/templates/CpuPackInfo.tmpl.cpp b/python/pystencils_walberla/templates/CpuPackInfo.tmpl.cpp
index 0191994f3..15c5d7bef 100644
--- a/python/pystencils_walberla/templates/CpuPackInfo.tmpl.cpp
+++ b/python/pystencils_walberla/templates/CpuPackInfo.tmpl.cpp
@@ -117,7 +117,7 @@ uint_t {{class_name}}::size(stencil::Direction dir, const IBlock * block) const
     CellInterval ci;
     {{field_name}}->getGhostRegion(dir, ci, 1, false);
 
-    uint_t elementsPerCell = 0;
+    uint_t elementsPerCell = uint_t{ 0u };
 
     switch( dir )
     {
@@ -125,11 +125,11 @@ uint_t {{class_name}}::size(stencil::Direction dir, const IBlock * block) const
         {%- for dir in direction_set %}
         case stencil::{{dir}}:
         {%- endfor %}
-            elementsPerCell = {{elements}};
+            elementsPerCell = uint_t{ {{elements}}u };
             break;
         {% endfor %}
         default:
-            elementsPerCell = 0;
+            elementsPerCell = uint_t{ 0u };
     }
     return ci.numCells() * elementsPerCell * sizeof( {{dtype}} );
 }
diff --git a/python/pystencils_walberla/templates/GpuPackInfo.tmpl.cpp b/python/pystencils_walberla/templates/GpuPackInfo.tmpl.cpp
index 48440b5b4..6a385fa85 100644
--- a/python/pystencils_walberla/templates/GpuPackInfo.tmpl.cpp
+++ b/python/pystencils_walberla/templates/GpuPackInfo.tmpl.cpp
@@ -17,6 +17,13 @@
 //! \\author pystencils
 //======================================================================================================================
 
+#include "core/DataTypes.h"
+#include "core/cell/CellInterval.h"
+
+#include "domain_decomposition/IBlock.h"
+
+#include "stencil/Directions.h"
+
 #include "{{class_name}}.h"
 
 {% if target is equalto 'cpu' -%}
diff --git a/python/pystencils_walberla/templates/GpuPackInfo.tmpl.h b/python/pystencils_walberla/templates/GpuPackInfo.tmpl.h
index fd8fbd90f..820c6b8be 100644
--- a/python/pystencils_walberla/templates/GpuPackInfo.tmpl.h
+++ b/python/pystencils_walberla/templates/GpuPackInfo.tmpl.h
@@ -20,7 +20,6 @@
 #pragma once
 
 #include "core/DataTypes.h"
-#include "core/cell/CellInterval.h"
 
 #include "domain_decomposition/IBlock.h"
 
diff --git a/src/blockforest/communication/NonUniformBufferedScheme.h b/src/blockforest/communication/NonUniformBufferedScheme.h
index ff1d3ba3b..0a6a453ab 100644
--- a/src/blockforest/communication/NonUniformBufferedScheme.h
+++ b/src/blockforest/communication/NonUniformBufferedScheme.h
@@ -851,7 +851,7 @@ void NonUniformBufferedScheme<Stencil>::startCommunicationCoarseToFine( const ui
 
       resetBufferSystem( bufferSystem );
 
-      for( auto sender : sendFunctions )
+      for( auto const &sender : sendFunctions )
          bufferSystem->addSendingFunction( int_c(sender.first), std::bind(  NonUniformBufferedScheme<Stencil>::send, std::placeholders::_1, sender.second ) );
 
       for(auto receiver : ranksToReceiveFrom)
@@ -996,7 +996,7 @@ void NonUniformBufferedScheme<Stencil>::startCommunicationFineToCoarse( const ui
 
       resetBufferSystem( bufferSystem );
 
-      for( auto sender : sendFunctions )
+      for( auto const &sender : sendFunctions )
          bufferSystem->addSendingFunction( int_c(sender.first), std::bind(  NonUniformBufferedScheme<Stencil>::send, std::placeholders::_1, sender.second ) );
 
       for(auto receiver : ranksToReceiveFrom)
diff --git a/src/core/Array.h b/src/core/Array.h
index c047542d7..dcb69e89b 100644
--- a/src/core/Array.h
+++ b/src/core/Array.h
@@ -46,7 +46,7 @@ public:
    inline Array( const std::vector<T>& vector );
    inline Array( const Array& array );
 
-   ~Array() { if( array_ != nullptr ) delete[] array_; }
+   ~Array() { delete[] array_; }
 
    uint_t size() const { return size_; }
    bool  empty() const { return size_ == 0; }
@@ -89,7 +89,7 @@ inline Array<T>::Array( const uint_t n, const T& t ) : array_( n == 0 ? nullptr
 template< typename T >
 inline Array<T>::Array( const std::vector<T>& vector ) :
 
-   array_( vector.size() == 0 ? nullptr : new T[ vector.size() ] ), size_( vector.size() )
+   array_( vector.empty() ? nullptr : new T[ vector.size() ] ), size_( vector.size() )
 {
    for( uint_t i = 0; i != size_; ++i )
       array_[i] = vector[i];
diff --git a/src/core/Set.h b/src/core/Set.h
index cbc0d5c11..de9ca7841 100644
--- a/src/core/Set.h
+++ b/src/core/Set.h
@@ -130,7 +130,7 @@ public:
 
    inline size_t size() const { return set_.size(); }
 
-   inline void swap( Set<T>& set ) { set_.swap( set.set_ ); }
+   inline void swap( Set<T>& set ) noexcept { set_.swap( set.set_ ); }
 
           void        toStream( std::ostream& os ) const;
    inline std::string toString() const;
diff --git a/src/core/StringUtility.impl.h b/src/core/StringUtility.impl.h
index 02b5f3937..ac3b29887 100644
--- a/src/core/StringUtility.impl.h
+++ b/src/core/StringUtility.impl.h
@@ -21,8 +21,6 @@
 
 #pragma once
 
-#include "core/StringUtility.h"
-
 #include <algorithm>
 #include <cctype>
 #include <string>
diff --git a/src/core/cell/CellInterval.h b/src/core/cell/CellInterval.h
index 7b766fa37..6019ac71c 100644
--- a/src/core/cell/CellInterval.h
+++ b/src/core/cell/CellInterval.h
@@ -236,6 +236,7 @@ inline bool CellInterval::overlaps( const CellInterval& other ) const
    if( empty() || other.empty() )
       return false;
 
+   // NOLINTNEXTLINE(readability-simplify-boolean-expr)
    return !(other.min_.x() > max_.x() || other.min_.y() > max_.y() || other.min_.z() > max_.z() ||
        other.max_.x() < min_.x() || other.max_.y() < min_.y() || other.max_.z() < min_.z());
 }
diff --git a/src/core/debug/PrintStacktrace.cpp b/src/core/debug/PrintStacktrace.cpp
index 94f2aa89b..6e0a4fef0 100644
--- a/src/core/debug/PrintStacktrace.cpp
+++ b/src/core/debug/PrintStacktrace.cpp
@@ -42,6 +42,7 @@ void printStacktrace()
 #include WALBERLA_BACKTRACE_HEADER
 #include <cstdlib>
 #include <string>
+#include <utility>
 
 namespace walberla {
 namespace debug {
@@ -92,12 +93,12 @@ namespace debug {
 
          string appName     = line.substr( 0, leftBracket );
          string bracketPart = line.substr( leftBracket+1, rightBracket - leftBracket -1 );
-         string rest        = line.substr( rightBracket +1 );
+         std::ignore        = line.substr( rightBracket +1 ); /*rest*/
 
          // split the bracketPart on plus sign
          size_t plusPos = bracketPart.find_first_of('+');
          string functionName = bracketPart.substr(0, plusPos );
-         string offset       = bracketPart.substr( plusPos+1 );
+         std::ignore = bracketPart.substr( plusPos+1 ); /*offset*/
 #endif
 
          // try to demangle -> no return code if successful
@@ -109,7 +110,7 @@ namespace debug {
 
          os << "\t" << appName << " \t " << demangled << endl;
       }
-      free (strings);
+      free (reinterpret_cast<void*>(strings));
    }
 
 
diff --git a/src/core/math/Matrix2.h b/src/core/math/Matrix2.h
index 308108649..3827333a4 100644
--- a/src/core/math/Matrix2.h
+++ b/src/core/math/Matrix2.h
@@ -323,7 +323,7 @@ inline Matrix2<Type>& Matrix2<Type>::operator=( Type set )
 // Explicit definition of a copy assignment operator for performance reasons.
 */
 template< typename Type >
-inline Matrix2<Type>& Matrix2<Type>::operator=( const Matrix2& set )
+inline Matrix2<Type>& Matrix2<Type>::operator=( const Matrix2& set ) // NOLINT(bugprone-unhandled-self-assignment)
 {
    // This implementation is faster than the synthesized default copy assignment operator and
    // faster than an implementation with the C library function 'memcpy' in combination with a
@@ -347,7 +347,7 @@ inline Matrix2<Type>& Matrix2<Type>::operator=( const Matrix2& set )
 */
 template< typename Type >
 template< typename Other >
-inline Matrix2<Type>& Matrix2<Type>::operator=( const Matrix2<Other>& set )
+inline Matrix2<Type>& Matrix2<Type>::operator=( const Matrix2<Other>& set ) // NOLINT(bugprone-unhandled-self-assignment)
 {
    // This implementation is faster than the synthesized default copy assignment operator and
    // faster than an implementation with the C library function 'memcpy' in combination with a
diff --git a/src/core/math/extern/exprtk.h b/src/core/math/extern/exprtk.h
index b415b4ba6..aab5062ba 100644
--- a/src/core/math/extern/exprtk.h
+++ b/src/core/math/extern/exprtk.h
@@ -5209,7 +5209,7 @@ namespace exprtk
             return std::numeric_limits<T>::quiet_NaN();
          }
 
-         inline virtual expression_node<T>* branch(const std::size_t& index = 0) const
+         inline virtual expression_node<T>* branch([[maybe_unused]] const std::size_t& index = 0) const
          {
             return reinterpret_cast<expression_ptr>(index * 0);
          }
@@ -14889,6 +14889,8 @@ namespace exprtk
       {
       public:
 
+         ~T0oT1oT2oT3_sf4() override = default;
+
          typedef typename details::functor_t<T> functor_t;
          typedef typename functor_t::qfunc_t      qfunc_t;
          typedef T value_type;
@@ -18085,7 +18087,7 @@ namespace exprtk
             return false;
          else if (symbol_exists(vector_name))
             return false;
-         else if (0 == v.size())
+         else if (v.empty())
             return false;
          else
             return local_data().vector_store.add(vector_name,v);
@@ -18099,7 +18101,7 @@ namespace exprtk
             return false;
          else if (symbol_exists(vector_name))
             return false;
-         else if (0 == v.size())
+         else if (v.empty())
             return false;
          else
             return local_data().vector_store.add(vector_name,v);
@@ -18585,10 +18587,7 @@ namespace exprtk
                }
             }
 
-            if (results)
-            {
-               delete results;
-            }
+            delete results;
          }
 
          static inline control_block* create(expression_ptr e)
@@ -21419,7 +21418,9 @@ namespace exprtk
 
                end_token = current_token();
 
+               #ifdef exprtk_enable_debugging
                const std::string sub_expr = construct_subexpr(begin_token, end_token);
+               #endif
 
                exprtk_debug(("parse_corpus(%02d) Subexpr: %s\n",
                              static_cast<int>(arg_list.size() - 1),
@@ -24456,7 +24457,7 @@ namespace exprtk
 
             for (std::size_t i = 0; i < function_definition_list_.size(); ++i)
             {
-               if (std::string::npos != function_definition_list_[i].param_seq.find("Z"))
+               if (std::string::npos != function_definition_list_[i].param_seq.find('Z'))
                {
                   return true;
                }
@@ -38550,7 +38551,7 @@ namespace exprtk
 
          std::memcpy(reinterpret_cast<char*>(&fd),
                      reinterpret_cast<const char*>(&v),
-                     sizeof(fd));
+                     sizeof(void*));
          return fd;
       }
 
@@ -38611,7 +38612,7 @@ namespace exprtk
 
             std::memcpy(reinterpret_cast<char*>(&t ),
                         reinterpret_cast<char*>(&fd),
-                        sizeof(fd));
+                        sizeof(void*));
             return t;
          }
          else
diff --git a/src/core/mpi/BufferSystem.impl.h b/src/core/mpi/BufferSystem.impl.h
index 3715a7ea9..b927d242d 100644
--- a/src/core/mpi/BufferSystem.impl.h
+++ b/src/core/mpi/BufferSystem.impl.h
@@ -165,21 +165,24 @@ GenericBufferSystem<Rb, Sb> & GenericBufferSystem<Rb, Sb>::operator=( const Gene
 {
    WALBERLA_ASSERT( !communicationRunning_, "Can't copy GenericBufferSystem while communication is running" )
 
-   sizeChangesEverytime_ = other.sizeChangesEverytime_;
-   communicationRunning_ = other.communicationRunning_;
-   recvInfos_ = other.recvInfos_;
-   sendInfos_ = other.sendInfos_;
+   if (&other != this)
+   {
+      sizeChangesEverytime_ = other.sizeChangesEverytime_;
+      communicationRunning_ = other.communicationRunning_;
+      recvInfos_ = other.recvInfos_;
+      sendInfos_ = other.sendInfos_;
 
-   if( other.currentComm_ == &other.knownSizeComm_ )
-      currentComm_ = &knownSizeComm_;
-   else if ( other.currentComm_ == &other.unknownSizeComm_ )
-      currentComm_ = &unknownSizeComm_;
-   else if ( other.currentComm_ == &other.unknownSizeCommIProbe_ )
-      currentComm_ = &unknownSizeCommIProbe_;
-   else if ( other.currentComm_ == &other.noMPIComm_ )
-      currentComm_ = &noMPIComm_;
-   else
-      currentComm_ = nullptr; // receiver information not yet set
+      if( other.currentComm_ == &other.knownSizeComm_ )
+         currentComm_ = &knownSizeComm_;
+      else if ( other.currentComm_ == &other.unknownSizeComm_ )
+         currentComm_ = &unknownSizeComm_;
+      else if ( other.currentComm_ == &other.unknownSizeCommIProbe_ )
+         currentComm_ = &unknownSizeCommIProbe_;
+      else if ( other.currentComm_ == &other.noMPIComm_ )
+         currentComm_ = &noMPIComm_;
+      else
+         currentComm_ = nullptr; // receiver information not yet set
+   }
 
    return *this;
 }
diff --git a/src/core/mpi/RecvBuffer.h b/src/core/mpi/RecvBuffer.h
index 0b3df4abf..69c0a26d2 100644
--- a/src/core/mpi/RecvBuffer.h
+++ b/src/core/mpi/RecvBuffer.h
@@ -400,11 +400,11 @@ GenericRecvBuffer<T>::get( V& value )
 
 
    // Checking the validity of the read operation
-   WALBERLA_ASSERT_LESS_EQUAL( cur_ + (sizeof(V) / sizeof(T)), end_ );
+   WALBERLA_ASSERT_LESS_EQUAL( cur_ + (sizeof(V) / sizeof(T)), end_ ); // NOLINT(bugprone-sizeof-expression)
 
    // Extracting the data value
    std::memcpy( &value, cur_, sizeof(V) );
-   cur_ += sizeof(V) / sizeof(T);
+   cur_ += sizeof(V) / sizeof(T); // NOLINT(bugprone-sizeof-expression)
 
    // Invariants check
    WALBERLA_ASSERT_LESS_EQUAL( cur_, end_);
diff --git a/src/core/mpi/SendBuffer.h b/src/core/mpi/SendBuffer.h
index 3fac958a7..f167a4459 100644
--- a/src/core/mpi/SendBuffer.h
+++ b/src/core/mpi/SendBuffer.h
@@ -449,7 +449,7 @@ GenericSendBuffer<T,G>::put( V value )
    static_assert( sizeof(V) >= sizeof(T), "Type that is stored has to be bigger than T" );
    static_assert( sizeof(V)  % sizeof(T) == 0, "V has to be divisible by T ");
 
-   size_t count =  sizeof(V) / sizeof(T) ;
+   size_t count =  sizeof(V) / sizeof(T); // NOLINT(bugprone-sizeof-expression)
    const size_t rest = numeric_cast< size_t >( end_ - cur_ );
 
    // Checking the size of the remaining memory
diff --git a/src/core/timing/TimingNode.h b/src/core/timing/TimingNode.h
index 0b6326e71..404feb7d5 100644
--- a/src/core/timing/TimingNode.h
+++ b/src/core/timing/TimingNode.h
@@ -97,8 +97,11 @@ TimingNode<TP>::TimingNode(const TimingNode<TP>& tn)
 template< typename TP >  // Timing policy
 TimingNode<TP>& TimingNode<TP>::operator=(const TimingNode<TP>& tn)
 {
-   TimingNode<TP> tmp (tn);
-   tmp.swap(*this);
+   if (&tn != this)
+   {
+      TimingNode<TP> tmp (tn);
+      tmp.swap(*this);
+   }
    return *this;
 }
 
diff --git a/src/core/timing/TimingTree.h b/src/core/timing/TimingTree.h
index 5cf06167e..5584b2be3 100644
--- a/src/core/timing/TimingTree.h
+++ b/src/core/timing/TimingTree.h
@@ -128,8 +128,11 @@ TimingTree<TP>::TimingTree(const TimingTree<TP>& tt)
 template< typename TP >  // Timing policy
 TimingTree<TP>& TimingTree<TP>::operator=(const TimingTree<TP>& tt)
 {
-   TimingTree<TP> tmp (tt);
-   tmp.swap(*this);
+   if (&tt != this)
+   {
+      TimingTree<TP> tmp (tt);
+      tmp.swap(*this);
+   }
    return *this;
 }
 
diff --git a/src/core/uid/UIDGenerators.h b/src/core/uid/UIDGenerators.h
index 265beeaac..3d715c9de 100644
--- a/src/core/uid/UIDGenerators.h
+++ b/src/core/uid/UIDGenerators.h
@@ -275,11 +275,11 @@ public:
 
    static uint_type firstUID() { return 1; }
 
-   static uint_type nextUID( const uint_type /*uid*/ ) { WALBERLA_ASSERT( false ); return 1; }
+   static uint_type nextUID( [[maybe_unused]] const uint_type uid ) { WALBERLA_ASSERT( false ); return 1; }
 
-   static uint_type toIndex( const uint_type uid ) { WALBERLA_ASSERT_EQUAL( uid, 1 ); return 0; }
+   static uint_type toIndex( [[maybe_unused]] const uint_type uid ) { WALBERLA_ASSERT_EQUAL( uid, 1 ); return 0; }
 
-   static uint_type toBitMask( const uint_type uid ) { WALBERLA_ASSERT_EQUAL( uid, 1 ); return 1; }
+   static uint_type toBitMask( [[maybe_unused]] const uint_type uid ) { WALBERLA_ASSERT_EQUAL( uid, 1 ); return 1; }
 
    static const char* getType() { static const char* const type = "singleton generator"; return type; }
 
diff --git a/src/core/waLBerlaBuildInfo.in.cpp b/src/core/waLBerlaBuildInfo.in.cpp
index 65fa8887d..29efeaa8f 100644
--- a/src/core/waLBerlaBuildInfo.in.cpp
+++ b/src/core/waLBerlaBuildInfo.in.cpp
@@ -5,6 +5,7 @@
  */
 //======================================================================================================================
 
+#include "core/waLBerlaBuildInfo.h"
 
 namespace walberla {
 namespace core {
diff --git a/src/domain_decomposition/IBlock.h b/src/domain_decomposition/IBlock.h
index 42f73cd4a..a1641d5a5 100644
--- a/src/domain_decomposition/IBlock.h
+++ b/src/domain_decomposition/IBlock.h
@@ -100,8 +100,8 @@ public:
    template< typename U >
    const U* get() const {
       try { thr_(ptr_); }
-      catch ( U* ptr ) { return ptr; }
-      catch (...) {}
+      catch ( U* ptr ) { return ptr; } // NOLINT(misc-throw-by-value-catch-by-reference)
+      catch (...) {} // NOLINT(bugprone-empty-catch)
 #ifndef NDEBUG
       WALBERLA_ABORT( "BlockData access type violation! (The block data you added is of a different type than the block data you are trying to access!)"
                       "\nThe original data type was:       " << debug::demangle( typeInfo_ ) <<
@@ -135,8 +135,8 @@ public:
    template< typename U >
    bool isClassOrSubclassOf() const {
       try { thr_(ptr_); }
-      catch ( U* ) { return true; }
-      catch (...) {}
+      catch ( U* ) { return true; } // NOLINT(misc-throw-by-value-catch-by-reference)
+      catch (...) {} // NOLINT(bugprone-empty-catch)
       return false;
    }
 
@@ -156,7 +156,9 @@ private:
 #  pragma warning( disable : 4670 )
 #  pragma warning( disable : 4673 )
 #endif //_MSC_VER
-   template< typename T > static void thrower( void* ptr ) { throw static_cast< T* >( ptr ); }
+   template< typename T > static void thrower( void* ptr ) {
+      throw static_cast< T* >( ptr ); // NOLINT(misc-throw-by-value-catch-by-reference)
+   }
 #ifdef _MSC_VER
 #  pragma warning(pop)
 #endif //_MSC_VER
diff --git a/src/field/adaptors/GhostLayerFieldAdaptor.h b/src/field/adaptors/GhostLayerFieldAdaptor.h
index 13ac8f0e2..e7e4d630a 100644
--- a/src/field/adaptors/GhostLayerFieldAdaptor.h
+++ b/src/field/adaptors/GhostLayerFieldAdaptor.h
@@ -302,7 +302,7 @@ typename GhostLayerFieldAdaptor<Functor,glD>::const_iterator GhostLayerFieldAdap
 
 template< typename Functor, uint_t glD >
 typename GhostLayerFieldAdaptor<Functor,glD>::const_iterator GhostLayerFieldAdaptor<Functor,glD>::beginGhostLayerOnlyXYZ(
-         stencil::Direction dir, cell_idx_t f ) const
+         stencil::Direction dir, cell_idx_t /*f*/ ) const
 {
    CellInterval ci;
    getGhostRegion(dir,ci);
@@ -326,7 +326,7 @@ typename GhostLayerFieldAdaptor<Functor,glD>::const_iterator GhostLayerFieldAdap
 
 template< typename Functor, uint_t glD >
 typename GhostLayerFieldAdaptor<Functor,glD>::const_iterator GhostLayerFieldAdaptor<Functor,glD>::beginSliceBeforeGhostLayerXYZ(
-         stencil::Direction dir, cell_idx_t width, cell_idx_t f) const
+         stencil::Direction dir, cell_idx_t width, cell_idx_t /*f*/) const
 {
    CellInterval ci;
    getSliceBeforeGhostLayer(dir,ci,width);
diff --git a/src/field/vtk/FlagFieldMapping.h b/src/field/vtk/FlagFieldMapping.h
index 267cee26a..e9bfe963b 100644
--- a/src/field/vtk/FlagFieldMapping.h
+++ b/src/field/vtk/FlagFieldMapping.h
@@ -94,12 +94,12 @@ public:
 
 protected:
 
-   void configure()  {
+   void configure() override {
       WALBERLA_ASSERT_NOT_NULLPTR( this->block_ );
       field_ = this->block_->template getData< FieldType >( fieldID_ );
    }
 
-   TargetType evaluate( const cell_idx_t x, const cell_idx_t y, const cell_idx_t z, const cell_idx_t /*f*/ )
+   TargetType evaluate( const cell_idx_t x, const cell_idx_t y, const cell_idx_t z, const cell_idx_t /*f*/ ) override
    {
       WALBERLA_ASSERT_NOT_NULLPTR( field_ );
       if (field_->get(x,y,z) & mask_) {
diff --git a/src/field/vtk/VTKWriter.h b/src/field/vtk/VTKWriter.h
index 9b2232908..c9852b7f8 100644
--- a/src/field/vtk/VTKWriter.h
+++ b/src/field/vtk/VTKWriter.h
@@ -126,13 +126,10 @@ protected:
          // common case that can be handled faster
          return numeric_cast<OutputType>( OutputTrait::get( field_->get(x,y,z,0), uint_c(f) )  );
       }
-      else
-      {
-         const cell_idx_t fField = f / cell_idx_c( OutputTrait::F_SIZE );
-         const cell_idx_t fType  = f % cell_idx_c( OutputTrait::F_SIZE );
+      const cell_idx_t fField = f / cell_idx_c( OutputTrait::F_SIZE );
+      const cell_idx_t fType  = f % cell_idx_c( OutputTrait::F_SIZE );
 
-         return numeric_cast<OutputType>( OutputTrait::get( field_->get(x,y,z,fField), uint_c(fType) )  );
-      }
+      return numeric_cast<OutputType>( OutputTrait::get( field_->get(x,y,z,fField), uint_c(fType) )  );
    }
 
    const ConstBlockDataID bdid_;
diff --git a/src/gather/CellGatherPackInfo.impl.h b/src/gather/CellGatherPackInfo.impl.h
index 0ff0f32ea..1dc7e14c1 100644
--- a/src/gather/CellGatherPackInfo.impl.h
+++ b/src/gather/CellGatherPackInfo.impl.h
@@ -100,7 +100,7 @@ void CellGatherPackInfo<Field_T,CC>::unpackData( mpi::RecvBuffer & buffer )
    for( size_t i=0; i< nrPoints; ++i )
    {
       receivedData.emplace_back(std::vector<real_t>(fieldSize+1)); //+1 because we also store t value as first entry
-      std::vector<real_t> & pointVec = receivedData[receivedData.size()-1];
+      std::vector<real_t> & pointVec = receivedData.back();
 
       uint_t t;
       real_t val;
diff --git a/src/gather/CurveGatherPackInfo.impl.h b/src/gather/CurveGatherPackInfo.impl.h
index 10d480015..5c61a9070 100644
--- a/src/gather/CurveGatherPackInfo.impl.h
+++ b/src/gather/CurveGatherPackInfo.impl.h
@@ -186,7 +186,7 @@ void CurveGatherPackInfo<GlF,IP>::unpackData( mpi::RecvBuffer & buffer )
    for( size_t i=0; i< nrPoints; ++i )
    {
       receivedData.emplace_back(std::vector<real_t>(fieldSize+1)); //+1 because we also store t value as first entry
-      std::vector<real_t> & pointVec = receivedData[receivedData.size()-1];
+      std::vector<real_t> & pointVec = receivedData.back();
 
       real_t t;
       real_t val;
diff --git a/src/geometry/initializer/BoundarySetterFlagFieldSpecialization.h b/src/geometry/initializer/BoundarySetterFlagFieldSpecialization.h
index e154678f0..dd5a376ee 100644
--- a/src/geometry/initializer/BoundarySetterFlagFieldSpecialization.h
+++ b/src/geometry/initializer/BoundarySetterFlagFieldSpecialization.h
@@ -109,13 +109,13 @@ namespace initializer {
    }
 
    template<typename Flag_T>
-   void BoundarySetter<FlagField<Flag_T> >::setBoundaryConfigBlock( const BoundaryUID & boundaryUID, const Config::BlockHandle & blockHandle )
+   void BoundarySetter<FlagField<Flag_T> >::setBoundaryConfigBlock( [[maybe_unused]] const BoundaryUID & boundaryUID, [[maybe_unused]] const Config::BlockHandle & blockHandle )
    {
       WALBERLA_ABORT("Passed boundary information to an initializer that sets up a pure flag field only");
    }
 
    template<typename Flag_T>
-   void BoundarySetter<FlagField<Flag_T>>::setBoundaryConfig( const BoundaryUID & boundaryUID, const shared_ptr<BoundaryConfiguration> & conf )
+   void BoundarySetter<FlagField<Flag_T>>::setBoundaryConfig( [[maybe_unused]] const BoundaryUID & boundaryUID, [[maybe_unused]] const shared_ptr<BoundaryConfiguration> & conf )
    {
       WALBERLA_ABORT("Passed boundary information to an initializer that sets up a pure flag field only");
    }
diff --git a/src/geometry/initializer/ScalarFieldFromBody.impl.h b/src/geometry/initializer/ScalarFieldFromBody.impl.h
index 7c96eea77..95ade01e0 100644
--- a/src/geometry/initializer/ScalarFieldFromBody.impl.h
+++ b/src/geometry/initializer/ScalarFieldFromBody.impl.h
@@ -32,6 +32,8 @@
 #include "core/mpi/Reduce.h"
 #include "core/stringToNum.h"
 
+#include <utility>
+
 
 namespace walberla {
 namespace geometry {
@@ -60,7 +62,7 @@ namespace initializer {
          addOrSet = false;
       
       auto        id         = subBlock.getParameter< std::vector<BlockDataID>::size_type > ( "id", 0 );
-      std::string shape      = subBlock.getParameter< std::string >                         ( "shape" );
+      std::ignore            = subBlock.getParameter< std::string >                         ( "shape" );
       std::string expression = subBlock.getParameter< std::string >                         ( "value" );
       
       try
diff --git a/src/gpu/DeviceWrapper.h b/src/gpu/DeviceWrapper.h
index 3bdf1be00..b5270a57c 100644
--- a/src/gpu/DeviceWrapper.h
+++ b/src/gpu/DeviceWrapper.h
@@ -66,10 +66,12 @@ namespace gpustubs {
                   "available and shouldn't be called!");
 
 #ifndef __CUDACC__
+   //NOLINTBEGIN(bugprone-reserved-identifier)
    #define __device__
    #define __global__
    #define __host__
    #define __forceinline__
+   //NOLINTEND(bugprone-reserved-identifier)
 #endif
 
 using gpuError_t = int;
diff --git a/src/lbm/boundary/ParserUBB.h b/src/lbm/boundary/ParserUBB.h
index 2a4d8e087..8559af959 100644
--- a/src/lbm/boundary/ParserUBB.h
+++ b/src/lbm/boundary/ParserUBB.h
@@ -220,19 +220,19 @@ template< typename LatticeModel_T, typename flag_t, bool AdaptVelocityToExternal
 inline ParserUBB<LatticeModel_T, flag_t, AdaptVelocityToExternalForce, StoreForce>::Parser::Parser( const std::array< std::string, 3 > & equations )
 : parsers_(), equations_( equations ), timeDependent_( false )
 {
-   if( equations_[0].length() > 0 )
+   if( not equations_[0].empty() )
    {
       parsers_[0].parse( equations_[0] );
       if( parsers_[0].symbolExists( "t" ) )
          timeDependent_ = true;
    }
-   if( equations_[1].length() > 0 )
+   if( not equations_[1].empty() )
    {
       parsers_[1].parse( equations_[1] );
       if( parsers_[1].symbolExists( "t" ) )
          timeDependent_ = true;
    }
-   if( equations_[2].length() > 0 )
+   if( not equations_[2].empty() )
    {
       parsers_[2].parse( equations_[2] );
       if( parsers_[2].symbolExists( "t" ) )
diff --git a/src/lbm/free_surface/boundary/FreeSurfaceBoundaryHandling.impl.h b/src/lbm/free_surface/boundary/FreeSurfaceBoundaryHandling.impl.h
index 7a498511e..d9bd6420e 100644
--- a/src/lbm/free_surface/boundary/FreeSurfaceBoundaryHandling.impl.h
+++ b/src/lbm/free_surface/boundary/FreeSurfaceBoundaryHandling.impl.h
@@ -59,6 +59,8 @@ class BoundaryBlockDataHandling
       : boundary_(boundary)
    {}
 
+   ~BoundaryBlockDataHandling() override = default;
+
    // initialize standard waLBerla boundary handling
    BoundaryHandling_T* initialize(IBlock* const block) override
    {
diff --git a/src/lbm/free_surface/surface_geometry/CurvatureSweep.impl.h b/src/lbm/free_surface/surface_geometry/CurvatureSweep.impl.h
index f6d46d103..1e279596b 100644
--- a/src/lbm/free_surface/surface_geometry/CurvatureSweep.impl.h
+++ b/src/lbm/free_surface/surface_geometry/CurvatureSweep.impl.h
@@ -327,8 +327,8 @@ void CurvatureSweepLocalTriangulation< Stencil_T, FlagField_T, ScalarField_T, Ve
                {
                   const real_t diff = nIt1->dist2 - nIt2->dist2;
 
-                  if (diff < real_c(1e-4)) { nIt1->valid = nIt1->wall ? true : false; }
-                  if (diff > real_c(-1e-4)) { nIt2->valid = nIt2->wall ? true : false; }
+                  if (diff < real_c(1e-4)) { nIt1->valid = nIt1->wall; }
+                  if (diff > real_c(-1e-4)) { nIt2->valid = nIt2->wall; }
                }
             }
          }
diff --git a/src/lbm/vtk/QCriterion.h b/src/lbm/vtk/QCriterion.h
index 946f8f7e0..5675c65db 100644
--- a/src/lbm/vtk/QCriterion.h
+++ b/src/lbm/vtk/QCriterion.h
@@ -38,7 +38,7 @@ class QCriterionVTKWriter : public vtk::BlockCellDataWriter< OutputType, 1 >
 public:
    QCriterionVTKWriter(const shared_ptr<StructuredBlockStorage> blockStorage, Filter_T & filter,
                    const ConstBlockDataID & velocityFieldId, const std::string & id ) :
-         vtk::BlockCellDataWriter< OutputType, 1 >(id), blockStorage_(blockStorage), filter_(filter), velocityFieldId_(velocityFieldId), velocityField_(NULL) {}
+         vtk::BlockCellDataWriter< OutputType, 1 >(id), blockStorage_(blockStorage), filter_(filter), velocityFieldId_(velocityFieldId), velocityField_(nullptr) {}
 
 protected:
 
diff --git a/src/lbm_mesapd_coupling/overlapping/shapes/BoxWithOverlap.h b/src/lbm_mesapd_coupling/overlapping/shapes/BoxWithOverlap.h
index 9f6e52359..8ad69fcee 100644
--- a/src/lbm_mesapd_coupling/overlapping/shapes/BoxWithOverlap.h
+++ b/src/lbm_mesapd_coupling/overlapping/shapes/BoxWithOverlap.h
@@ -46,6 +46,8 @@ class BoxWithOverlap : public geometry::AbstractBody
       : idx_(idx), ac_(ac), box_(box)
    {}
 
+   ~BoxWithOverlap() override = default;
+
    bool contains(const Vector3< real_t >& point) const override
    {
       return mesa_pd::isPointInsideBoxBF(mesa_pd::transformPositionFromWFtoBF(idx_, ac_, point), box_.getEdgeLength());
diff --git a/src/lbm_mesapd_coupling/overlapping/shapes/CylindricalBoundaryWithOverlap.h b/src/lbm_mesapd_coupling/overlapping/shapes/CylindricalBoundaryWithOverlap.h
index de42d0050..f6f5d597c 100644
--- a/src/lbm_mesapd_coupling/overlapping/shapes/CylindricalBoundaryWithOverlap.h
+++ b/src/lbm_mesapd_coupling/overlapping/shapes/CylindricalBoundaryWithOverlap.h
@@ -47,6 +47,8 @@ class CylindricalBoundaryWithOverlap : public geometry::AbstractBody
       : idx_(idx), ac_(ac), cylindricalBoundary_(cylindricalBoundary)
    {}
 
+   ~CylindricalBoundaryWithOverlap() override = default;
+
    bool contains(const Vector3< real_t >& point) const override
    {
       return mesa_pd::isPointInsideCylindricalBoundary(point, ac_->getPosition(idx_), cylindricalBoundary_.getRadius(),
diff --git a/src/lbm_mesapd_coupling/overlapping/shapes/EllipsoidWithOverlap.h b/src/lbm_mesapd_coupling/overlapping/shapes/EllipsoidWithOverlap.h
index 0430419ab..295021fe0 100644
--- a/src/lbm_mesapd_coupling/overlapping/shapes/EllipsoidWithOverlap.h
+++ b/src/lbm_mesapd_coupling/overlapping/shapes/EllipsoidWithOverlap.h
@@ -46,6 +46,8 @@ class EllipsoidWithOverlap : public geometry::AbstractBody
       : idx_(idx), ac_(ac), ellipsoid_(ellipsoid)
    {}
 
+   ~EllipsoidWithOverlap() override = default;
+
    bool contains(const Vector3< real_t >& point) const override
    {
       return mesa_pd::isPointInsideEllipsoidBF(mesa_pd::transformPositionFromWFtoBF(idx_, ac_, point),
diff --git a/src/lbm_mesapd_coupling/overlapping/shapes/HalfSpaceWithOverlap.h b/src/lbm_mesapd_coupling/overlapping/shapes/HalfSpaceWithOverlap.h
index 3cc6ce13d..555e51599 100644
--- a/src/lbm_mesapd_coupling/overlapping/shapes/HalfSpaceWithOverlap.h
+++ b/src/lbm_mesapd_coupling/overlapping/shapes/HalfSpaceWithOverlap.h
@@ -46,6 +46,8 @@ class HalfSpaceWithOverlap : public geometry::AbstractBody
       : idx_(idx), ac_(ac), halfSpace_(halfSpace)
    {}
 
+   ~HalfSpaceWithOverlap() override = default;
+
    bool contains(const Vector3< real_t >& point) const override
    {
       return mesa_pd::isPointInsideHalfSpace(point, ac_->getPosition(idx_), halfSpace_.getNormal());
diff --git a/src/lbm_mesapd_coupling/overlapping/shapes/SphereWithOverlap.h b/src/lbm_mesapd_coupling/overlapping/shapes/SphereWithOverlap.h
index 84a0db6f0..ad80bdc00 100644
--- a/src/lbm_mesapd_coupling/overlapping/shapes/SphereWithOverlap.h
+++ b/src/lbm_mesapd_coupling/overlapping/shapes/SphereWithOverlap.h
@@ -45,6 +45,8 @@ class SphereWithOverlap : public geometry::AbstractBody
       : idx_(idx), ac_(ac), sphere_(sphere)
    {}
 
+   ~SphereWithOverlap() override = default;
+
    bool contains(const Vector3< real_t >& point) const override
    {
       return mesa_pd::isPointInsideSphere(point, ac_->getPosition(idx_), sphere_.getRadius());
diff --git a/src/mesa_pd/vtk/ParticleVtkOutput.cpp b/src/mesa_pd/vtk/ParticleVtkOutput.cpp
index 6093eeb30..9731e1e68 100644
--- a/src/mesa_pd/vtk/ParticleVtkOutput.cpp
+++ b/src/mesa_pd/vtk/ParticleVtkOutput.cpp
@@ -27,6 +27,7 @@ namespace vtk {
 std::vector< ParticleVtkOutput::Attributes > ParticleVtkOutput::getAttributes() const
 {
    std::vector< Attributes > attributes;
+   attributes.reserve(selectors_.size());
    for (const auto& s : selectors_)
    {
       attributes.emplace_back( s.second->type_string, s.first, s.second->components );
diff --git a/src/pe/Types.h b/src/pe/Types.h
index 463aab788..7e45fff69 100644
--- a/src/pe/Types.h
+++ b/src/pe/Types.h
@@ -27,6 +27,7 @@
 
 #include <array>
 #include <memory>
+#include <utility>
 #include <vector>
 
 namespace walberla{
diff --git a/src/pe/raytracing/Raytracer.h b/src/pe/raytracing/Raytracer.h
index ed4c6c864..ad26fb238 100644
--- a/src/pe/raytracing/Raytracer.h
+++ b/src/pe/raytracing/Raytracer.h
@@ -614,7 +614,7 @@ void Raytracer::generateImage(const size_t timestep, WcTimingTree* tt) {
          WALBERLA_LOG_WARNING(pixelErrors << " pixel errors found!");
          
          std::stringstream ss;
-         for (auto it: correctToIncorrectBodyIDsMap) {
+         for (auto const &it: correctToIncorrectBodyIDsMap) {
             const BodyID correctBody = it.first;
             if (it.first != nullptr) {
                ss << " correct body: " << correctBody->getID() << "(" << correctBody->getHash() << ")";
diff --git a/src/pe/rigidbody/RigidBodyCastIterator.h b/src/pe/rigidbody/RigidBodyCastIterator.h
index 3486472b4..6f3bda568 100644
--- a/src/pe/rigidbody/RigidBodyCastIterator.h
+++ b/src/pe/rigidbody/RigidBodyCastIterator.h
@@ -80,7 +80,7 @@ public:
    //**Access operators****************************************************************************
    /*!\name Access operators */
    //@{
-   inline reference operator*()   {return static_cast<reference>( *(cur_->get()) );}
+   inline reference operator*()   {return static_cast<reference>( **cur_ );}
    inline pointer   operator->()  {return static_cast<pointer>(     cur_->get()  );}
    //@}
    //**********************************************************************************************
@@ -228,7 +228,7 @@ public:
    //**Access operators****************************************************************************
    /*!\name Access operators */
    //@{
-   inline reference operator*()   {return static_cast<reference>( *(cur_->get()) );}
+   inline reference operator*()   {return static_cast<reference>( **cur_ );}
    inline pointer   operator->()  {return static_cast<pointer>(     cur_->get()  );}
    //@}
    //**********************************************************************************************
diff --git a/src/python_coupling/export/FieldExport.impl.h b/src/python_coupling/export/FieldExport.impl.h
index 3cff65b03..6d9916c71 100644
--- a/src/python_coupling/export/FieldExport.impl.h
+++ b/src/python_coupling/export/FieldExport.impl.h
@@ -129,6 +129,8 @@ class GhostLayerFieldDataHandling : public field::BlockDataHandling< GhostLayerF
         alignment_(alignment)
    {}
 
+   ~GhostLayerFieldDataHandling() override = default;
+
    GhostLayerField_T* allocate(IBlock* const block) override
    {
       auto blocks = blocks_.lock();
diff --git a/src/stencil/Directions.h b/src/stencil/Directions.h
index 5be0d7222..9071405a2 100644
--- a/src/stencil/Directions.h
+++ b/src/stencil/Directions.h
@@ -317,7 +317,7 @@ namespace stencil {
       else if ( axis==1 && !minOrMax ) return N;
       else if ( axis==2 &&  minOrMax ) return B;
       else if ( axis==2 && !minOrMax ) return T;
-      else                             return INVALID_DIR;
+      return INVALID_DIR;
    }
 
    /// Maps (direction,axis) pair to direction
@@ -333,7 +333,7 @@ namespace stencil {
       else if ( axis==1 && !minOrMax ) return N;
       else if ( axis==2 &&  minOrMax ) return B;
       else if ( axis==2 && !minOrMax ) return T;
-      else                             return INVALID_DIR;
+      return INVALID_DIR;
    }
 
 
diff --git a/src/vtk/Base64Writer.h b/src/vtk/Base64Writer.h
index 43631d2a9..c9af5528e 100644
--- a/src/vtk/Base64Writer.h
+++ b/src/vtk/Base64Writer.h
@@ -75,7 +75,7 @@ public:
 
 private:
 
-   void encodeblock( unsigned char in[3], unsigned char out[4], int len )
+   void encodeblock( unsigned char const in[3], unsigned char out[4], int len )
    {
       static const unsigned char cb64[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
 
diff --git a/src/vtk/VTKOutput.cpp b/src/vtk/VTKOutput.cpp
index eb66d3970..1039abe54 100644
--- a/src/vtk/VTKOutput.cpp
+++ b/src/vtk/VTKOutput.cpp
@@ -1882,7 +1882,7 @@ void VTKOutput::writeVTHBSeries()
    {
       for( std::string line; std::getline(ofs, line); )
       {
-         if( line.find("]") != std::string::npos )
+         if( line.find(']') != std::string::npos )
          {
             WALBERLA_ASSERT_GREATER( ofs.tellg(), 0 );
             pvdEnd_ = ofs.tellg();
diff --git a/tests/field/FieldOfCustomTypesTest.cpp b/tests/field/FieldOfCustomTypesTest.cpp
index 883d79510..4a7144a47 100644
--- a/tests/field/FieldOfCustomTypesTest.cpp
+++ b/tests/field/FieldOfCustomTypesTest.cpp
@@ -31,12 +31,6 @@
 using namespace walberla;
 
 
-using std::cout;
-using std::endl;
-
-
-
-
 struct MyClass
 {
    MyClass() {
diff --git a/tests/field/FlagFieldTest.cpp b/tests/field/FlagFieldTest.cpp
index 97b9d382e..4e91c68b1 100644
--- a/tests/field/FlagFieldTest.cpp
+++ b/tests/field/FlagFieldTest.cpp
@@ -33,10 +33,6 @@
 using namespace walberla;
 namespace wlb = walberla;
 
-using std::vector;
-using std::string;
-using std::cout;
-using std::endl;
 
 void registerTest()
 {
@@ -64,7 +60,7 @@ void registerTest()
    }
    WALBERLA_CHECK(overFlow);
 
-   vector<string> names;
+   std::vector<std::string> names;
    names.emplace_back("Flag1");
    names.emplace_back("Flag2");
    names.emplace_back("Flag3");
@@ -82,7 +78,7 @@ void registerTest()
       WALBERLA_CHECK_EQUAL( ff.getFlagUID( numeric_cast<FlagField<walberla::uint8_t>::flag_t>( 1 << i ) ), FlagUID(names[i]) );
    }
 
-   //ff.printRegistered(cout);
+   //ff.printRegistered(std::cout);
 }
 
 void accessTest()
@@ -167,7 +163,7 @@ void printingTest()
    ff.addFlag(0,1,0,ob);
    ff.addFlag(1,0,0,ob);
 
-   //printSlice( cout,ff, 2,0 );
+   //printSlice( std::cout,ff, 2,0 );
 }
 
 void neighborhoodTest()
diff --git a/tests/lbm/evaluations/PermeabilityTest.cpp b/tests/lbm/evaluations/PermeabilityTest.cpp
index 2cc1fffaf..887c524f3 100644
--- a/tests/lbm/evaluations/PermeabilityTest.cpp
+++ b/tests/lbm/evaluations/PermeabilityTest.cpp
@@ -284,8 +284,6 @@ int main( int argc, char ** argv )
    else
       WALBERLA_ABORT( "This app can only be executed with 1, 4, or 8 processes! Aborting ..." );
 
-   std::string collisionModel( "TRT" );
-
    try {
       if( std::strcmp( setup.collisionModel.c_str(), "SRT" ) == 0 )
          return setupAndExecute< lbm::D3Q19< lbm::collision_model::SRT          , false > >( setup );
diff --git a/tests/pe/MinMaxRefinement.cpp b/tests/pe/MinMaxRefinement.cpp
index 6cd56cb09..35c75825b 100644
--- a/tests/pe/MinMaxRefinement.cpp
+++ b/tests/pe/MinMaxRefinement.cpp
@@ -109,14 +109,14 @@ int main( int argc, char ** argv )
    blockforest.setRefreshPhantomBlockMigrationPreparationFunction(
             blockforest::DynamicCurveBalance< blockforest::WeightAssignmentFunctor::PhantomBlockWeight >( false, true, false ) );
 
-   createSphere(*globalStorage.get(), forest->getBlockStorage(), storageID, 0, Vec3(1,1,1), 1);
-   createSphere(*globalStorage.get(), forest->getBlockStorage(), storageID, 0, Vec3(1,1,3), 1);
-   createSphere(*globalStorage.get(), forest->getBlockStorage(), storageID, 0, Vec3(1,3,1), 1);
-   createSphere(*globalStorage.get(), forest->getBlockStorage(), storageID, 0, Vec3(1,3,3), 1);
-   createSphere(*globalStorage.get(), forest->getBlockStorage(), storageID, 0, Vec3(3,1,1), 1);
-   createSphere(*globalStorage.get(), forest->getBlockStorage(), storageID, 0, Vec3(3,1,3), 1);
-   createSphere(*globalStorage.get(), forest->getBlockStorage(), storageID, 0, Vec3(3,3,1), 1);
-   createSphere(*globalStorage.get(), forest->getBlockStorage(), storageID, 0, Vec3(3,3,3), 1);
+   createSphere(*globalStorage, forest->getBlockStorage(), storageID, 0, Vec3(1,1,1), 1);
+   createSphere(*globalStorage, forest->getBlockStorage(), storageID, 0, Vec3(1,1,3), 1);
+   createSphere(*globalStorage, forest->getBlockStorage(), storageID, 0, Vec3(1,3,1), 1);
+   createSphere(*globalStorage, forest->getBlockStorage(), storageID, 0, Vec3(1,3,3), 1);
+   createSphere(*globalStorage, forest->getBlockStorage(), storageID, 0, Vec3(3,1,1), 1);
+   createSphere(*globalStorage, forest->getBlockStorage(), storageID, 0, Vec3(3,1,3), 1);
+   createSphere(*globalStorage, forest->getBlockStorage(), storageID, 0, Vec3(3,3,1), 1);
+   createSphere(*globalStorage, forest->getBlockStorage(), storageID, 0, Vec3(3,3,3), 1);
 
    WALBERLA_MPI_BARRIER();
    WALBERLA_LOG_DEVEL_ON_ROOT( "Refinement 1" );
@@ -152,7 +152,7 @@ int main( int argc, char ** argv )
 
    for (unsigned int i = 0; i < 30; ++i)
    {
-      createSphere(*globalStorage.get(), forest->getBlockStorage(), storageID, 0, Vec3(real_t(2.1), real_t(2.1), real_t(2.1)), 1);
+      createSphere(*globalStorage, forest->getBlockStorage(), storageID, 0, Vec3(real_t(2.1), real_t(2.1), real_t(2.1)), 1);
    }
 
    WALBERLA_MPI_BARRIER();
diff --git a/tests/pe/Refinement.cpp b/tests/pe/Refinement.cpp
index 96900a625..5a8ab40ad 100644
--- a/tests/pe/Refinement.cpp
+++ b/tests/pe/Refinement.cpp
@@ -164,8 +164,8 @@ int main( int argc, char ** argv )
 
    blockforest.setRefreshPhantomBlockMigrationPreparationFunction( simpleLB );
 
-   createSphere(*globalStorage.get(), forest->getBlockStorage(), storageID, 0, Vec3(5,5,5), 1);
-   createSphere(*globalStorage.get(), forest->getBlockStorage(), storageID, 0, Vec3(15,6,6), 1);
+   createSphere(*globalStorage, forest->getBlockStorage(), storageID, 0, Vec3(5,5,5), 1);
+   createSphere(*globalStorage, forest->getBlockStorage(), storageID, 0, Vec3(15,6,6), 1);
 
    SweepTimeloop timeloop( forest->getBlockStorage(), 1 );
    timeloop.addFuncBeforeTimeStep( simpleLB, "refreshFunctorName" );
diff --git a/tests/pe/SyncEquivalence.cpp b/tests/pe/SyncEquivalence.cpp
index 6c0318018..1ad70b832 100644
--- a/tests/pe/SyncEquivalence.cpp
+++ b/tests/pe/SyncEquivalence.cpp
@@ -122,7 +122,7 @@ void createSimulation(math::AABB& simulationDomain,
         IBlock & currentBlock = *blkIt;
         for (auto it = grid_generator::HCPIterator(currentBlock.getAABB(), Vector3<real_t>(-5,-5,-5), spacing); it != grid_generator::HCPIterator(); ++it)
         {
-            SphereID sp = pe::createSphere( *(info.globalBodyStorage.get()), info.forest->getBlockStorage(), info.storageID, static_cast<walberla::id_t>(mpi::MPIManager::instance()->worldRank() * 1000000 + numParticles), *it, radius);
+            SphereID sp = pe::createSphere( *info.globalBodyStorage, info.forest->getBlockStorage(), info.storageID, static_cast<walberla::id_t>(mpi::MPIManager::instance()->worldRank()) * 1000000u + static_cast<walberla::id_t>(numParticles), *it, radius);
             Vec3 rndVel(math::realRandom<real_t>(-vMax, vMax, generator), math::realRandom<real_t>(-vMax, vMax, generator), math::realRandom<real_t>(-vMax, vMax, generator));
             if (sp != nullptr) sp->setLinearVel(rndVel);
             if (sp != nullptr) ++numParticles;
diff --git a/tests/postprocessing/SphereTriangulate.cpp b/tests/postprocessing/SphereTriangulate.cpp
index 325f0ad44..b74985465 100644
--- a/tests/postprocessing/SphereTriangulate.cpp
+++ b/tests/postprocessing/SphereTriangulate.cpp
@@ -38,10 +38,6 @@ using namespace postprocessing;
 
 using geometry::TriangleMesh;
 
-using std::cout;
-using std::endl;
-using std::ofstream;
-
 typedef GhostLayerField<real_t,1> ScalarField;
 
 
@@ -106,7 +102,7 @@ void singleField()
 
    TriangleMesh m;
    generateIsoSurface(f,0.5,m);
-   //ofstream file ("out.obj");
+   //std::ofstream file ("out.obj");
    //writeMeshObj(file,m);
 }
 
@@ -143,11 +139,11 @@ void multipleFields()
       generateIsoSurface( **i, real_c(0.5), m, Vector3<real_t>(real_t(1)), uint_t(0), offset );
    }
 
-   //ofstream file1("meshWithDoubles.obj");
+   //std::ofstream file1("meshWithDoubles.obj");
    //writeMeshObj(file1,m);
    size_t verticesRemoved =  m.removeDuplicateVertices();
    WALBERLA_CHECK_EQUAL(verticesRemoved, expectedDoubles);
-   //ofstream file2("meshWithoutDoubles.obj");
+   //std::ofstream file2("meshWithoutDoubles.obj");
    //writeMeshObj(file2,m);
 }
 
diff --git a/tests/simd/SIMD_Equivalence.cpp b/tests/simd/SIMD_Equivalence.cpp
index f90c69f4f..9a86ae0de 100644
--- a/tests/simd/SIMD_Equivalence.cpp
+++ b/tests/simd/SIMD_Equivalence.cpp
@@ -166,7 +166,7 @@ void print1( const is1::double4_t& vec)
 
 void checkVecEqual ( is0::double4_t a, is1::double4_t b, const std::string & description = "" )
 {
-   if ( description.size() > 0) 
+   if ( not description.empty() )
    {
       double meanError = std::abs( is0::getComponent(a, 0 )- is1::getComponent(b,0 ) ) +
 			 std::abs( is0::getComponent(a, 1 )- is1::getComponent(b,1 ) ) +
diff --git a/tests/stencil/StencilTest.cpp b/tests/stencil/StencilTest.cpp
index 2e282ac62..3ddee03e3 100644
--- a/tests/stencil/StencilTest.cpp
+++ b/tests/stencil/StencilTest.cpp
@@ -19,9 +19,6 @@
 using namespace walberla;
 using namespace stencil;
 
-using std::cout;
-using std::endl;
-
 
 template <typename S>
 void stencilIteration()
-- 
GitLab