From f6eb600fb2abf02fbcc537745f3788efe36995fe Mon Sep 17 00:00:00 2001
From: Sebastian Eibl <sebastian.eibl@fau.de>
Date: Wed, 28 Aug 2019 10:35:28 +0200
Subject: [PATCH] [CLANG-TIDY] readability-const-return-type

---
 .clang-tidy                                   |  1 +
 .../math/equation_system/EquationSystem.cpp   |  4 ++--
 .../math/equation_system/EquationSystem.h     |  4 ++--
 src/executiontree/ExecutionTree.cpp           |  4 ++--
 src/executiontree/ExecutionTree.h             | 20 +++++++++----------
 src/mesa_pd/collision_detection/GJK.cpp       |  2 +-
 src/mesa_pd/collision_detection/GJK.h         |  2 +-
 src/pe/rigidbody/RigidBody.cpp                |  8 ++++----
 src/pe/rigidbody/RigidBody.h                  |  8 ++++----
 src/pe/rigidbody/Squirmer.cpp                 | 10 +++++-----
 src/pe/rigidbody/Squirmer.h                   | 10 +++++-----
 11 files changed, 37 insertions(+), 36 deletions(-)

diff --git a/.clang-tidy b/.clang-tidy
index b0da333be..d00e49d2e 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -32,6 +32,7 @@ performance-*,
 
 portability-*,
 
+readability-const-return-type,
 readability-container-size-empty,
 readability-misleading-indentation,
 readability-misplaced-array-index
diff --git a/src/core/math/equation_system/EquationSystem.cpp b/src/core/math/equation_system/EquationSystem.cpp
index 433a1283c..30a9394cf 100644
--- a/src/core/math/equation_system/EquationSystem.cpp
+++ b/src/core/math/equation_system/EquationSystem.cpp
@@ -171,7 +171,7 @@ size_t EquationSystem::getNumberOfEquations() const
    return eqMap_.size();
 }
 
-const std::string EquationSystem::writeEquations() const
+std::string EquationSystem::writeEquations() const
 {
    std::stringstream ss;
    ss << "Equations to solve:" << std::endl;
@@ -182,7 +182,7 @@ const std::string EquationSystem::writeEquations() const
    return ss.str();
 }
 
-const std::string EquationSystem::writeVariables() const
+std::string EquationSystem::writeVariables() const
 {
    std::stringstream ss;
    ss << "Solution for each variable:" << std::endl;
diff --git a/src/core/math/equation_system/EquationSystem.h b/src/core/math/equation_system/EquationSystem.h
index 56a15bf80..e78df0345 100644
--- a/src/core/math/equation_system/EquationSystem.h
+++ b/src/core/math/equation_system/EquationSystem.h
@@ -100,8 +100,8 @@ namespace math {
       //**Output functions*************************************************************************
       /*! \name Output functions */
       //@{
-      const std::string writeEquations() const;
-      const std::string writeVariables() const;
+      std::string writeEquations() const;
+      std::string writeVariables() const;
       friend std::ostream& operator<<( std::ostream& os, EquationSystem& es );
       //@}
       //****************************************************************************************************************
diff --git a/src/executiontree/ExecutionTree.cpp b/src/executiontree/ExecutionTree.cpp
index b27389707..346b089ec 100644
--- a/src/executiontree/ExecutionTree.cpp
+++ b/src/executiontree/ExecutionTree.cpp
@@ -125,7 +125,7 @@ void EveryNth::operator()()
    ++calls_;
 }
 
-const std::string EveryNth::getName() const
+std::string EveryNth::getName() const
 {
    std::stringstream ss;
    ss << "every " << interval_ << "th step:";
@@ -208,7 +208,7 @@ void Loop::synchronizedStop( bool stopVar )
    mpi::allReduceInplace( stop_, mpi::LOGICAL_OR );
 }
 
-const std::string Loop::getName() const
+std::string Loop::getName() const
 {
    std::stringstream ss;
    ss << "Loop [" << iterations_ << "]";
diff --git a/src/executiontree/ExecutionTree.h b/src/executiontree/ExecutionTree.h
index 99b3515a5..f9c838ec6 100644
--- a/src/executiontree/ExecutionTree.h
+++ b/src/executiontree/ExecutionTree.h
@@ -109,8 +109,8 @@ class IFunctionNode
 public:
    virtual ~IFunctionNode() {}
    virtual void operator()() = 0;
-   virtual const std::string getName() const = 0;
-   virtual const std::deque< shared_ptr< IFunctionNode > > getChildren() const { return {}; }
+   virtual std::string getName() const = 0;
+   virtual std::deque< shared_ptr< IFunctionNode > > getChildren() const { return {}; }
 };
 
 
@@ -122,7 +122,7 @@ public:
            const std::string &name,
            const TimingTreePtr & timingTree );
 
-   const std::string getName() const override { return name_ != "" ? name_ : "Functor"; };
+   std::string getName() const override { return name_ != "" ? name_ : "Functor"; };
    void operator() () override;
 
 private:
@@ -138,8 +138,8 @@ public:
    EveryNth( const IFunctionNodePtr &node, uint_t interval, bool onFirst = false, uint_t startValue = 0 );
 
    void operator()() override;
-   const std::string getName() const override;
-   const std::deque< shared_ptr< IFunctionNode > > getChildren() const override { return { wrapped_ }; }
+   std::string getName() const override;
+   std::deque< shared_ptr< IFunctionNode > > getChildren() const override { return { wrapped_ }; }
 
 private:
    IFunctionNodePtr wrapped_;
@@ -158,8 +158,8 @@ public:
 
    void push_back( const IFunctionNodePtr &fct ) { children_.push_back( fct ); }
    void push_front( const IFunctionNodePtr &fct ) { children_.push_front( fct ); }
-   const std::string getName() const override { return name_ != "" ? name_ : "Sequence"; };
-   const std::deque< IFunctionNodePtr > getChildren() const override { return children_; };
+   std::string getName() const override { return name_ != "" ? name_ : "Sequence"; };
+   std::deque< IFunctionNodePtr > getChildren() const override { return children_; };
 
 private:
    std::string name_;
@@ -185,8 +185,8 @@ public:
    uint_t getCurrentTimeStep() const override { return currentIteration_; }
    uint_t getNrOfTimeSteps() const override { return iterations_; }
 
-   const std::deque< shared_ptr< IFunctionNode > > getChildren() const override { return { body_ }; }
-   const std::string getName()  const override;
+   std::deque< shared_ptr< IFunctionNode > > getChildren() const override { return { body_ }; }
+   std::string getName()  const override;
 
 private:
    IFunctionNodePtr body_;
@@ -203,4 +203,4 @@ private:
 } // namespace walberla
 
 
-#include "ExecutionTree.impl.h"
\ No newline at end of file
+#include "ExecutionTree.impl.h"
diff --git a/src/mesa_pd/collision_detection/GJK.cpp b/src/mesa_pd/collision_detection/GJK.cpp
index 4732d365a..d111caccd 100644
--- a/src/mesa_pd/collision_detection/GJK.cpp
+++ b/src/mesa_pd/collision_detection/GJK.cpp
@@ -47,7 +47,7 @@ GJK::GJK()
  * \param dir The support point direction.
  * \param threshold Extension of the particle.
  */
-const Vec3 GJK::putSupport(const Support &geom1,
+Vec3 GJK::putSupport(const Support &geom1,
                            const Support &geom2,
                            const Vec3& dir,
                            const real_t margin,
diff --git a/src/mesa_pd/collision_detection/GJK.h b/src/mesa_pd/collision_detection/GJK.h
index 96d6d5be8..47b424731 100644
--- a/src/mesa_pd/collision_detection/GJK.h
+++ b/src/mesa_pd/collision_detection/GJK.h
@@ -81,7 +81,7 @@ private:
    inline bool zeroLengthVector( const Vec3& vec )                    const { return vec.sqrLength() < math::Limits<real_t>::fpuAccuracy(); }
    real_t calcDistance    ( Vec3& normal, Vec3& contactPoint );
 
-   inline const Vec3 putSupport(const Support &geom1,
+   inline Vec3 putSupport(const Support &geom1,
                                 const Support &geom2,
                                 const Vec3& dir,
                                 const real_t margin,
diff --git a/src/pe/rigidbody/RigidBody.cpp b/src/pe/rigidbody/RigidBody.cpp
index 78743f796..b58bcad56 100644
--- a/src/pe/rigidbody/RigidBody.cpp
+++ b/src/pe/rigidbody/RigidBody.cpp
@@ -196,7 +196,7 @@ bool RigidBody::checkInvariants()
  *
  * The function calculates the global velocity of a point relative to the body's center of mass.
  */
-const Vec3 RigidBody::velFromBF( real_t px, real_t py, real_t pz ) const
+Vec3 RigidBody::velFromBF( real_t px, real_t py, real_t pz ) const
 {
    return velFromBF( Vec3( px, py, pz ) );
 }
@@ -211,7 +211,7 @@ const Vec3 RigidBody::velFromBF( real_t px, real_t py, real_t pz ) const
  *
  * The function calculates the global velocity of a point relative to the body's center of mass.
  */
-const Vec3 RigidBody::velFromBF( const Vec3& rpos ) const
+Vec3 RigidBody::velFromBF( const Vec3& rpos ) const
 {
    if( !hasSuperBody() )
       return v_ + w_ % ( R_ * rpos );
@@ -230,7 +230,7 @@ const Vec3 RigidBody::velFromBF( const Vec3& rpos ) const
  *
  * The function calculates the global velocity of a point in global coordinates.
  */
-const Vec3 RigidBody::velFromWF( real_t px, real_t py, real_t pz ) const
+Vec3 RigidBody::velFromWF( real_t px, real_t py, real_t pz ) const
 {
    return velFromWF( Vec3( px, py, pz ) );
 }
@@ -245,7 +245,7 @@ const Vec3 RigidBody::velFromWF( real_t px, real_t py, real_t pz ) const
  *
  * The function calculates the global velocity of a point in global coordinates.
  */
-const Vec3 RigidBody::velFromWF( const Vec3& gpos ) const
+Vec3 RigidBody::velFromWF( const Vec3& gpos ) const
 {
    if( !hasSuperBody() )
       return v_ + w_ % ( gpos - gpos_ );
diff --git a/src/pe/rigidbody/RigidBody.h b/src/pe/rigidbody/RigidBody.h
index 1ac988c75..440abac64 100644
--- a/src/pe/rigidbody/RigidBody.h
+++ b/src/pe/rigidbody/RigidBody.h
@@ -125,14 +125,14 @@ public:
    inline const Vec3     vectorFromBFtoWF( const Vec3& v )             const;
    inline const Vec3     pointFromBFtoWF ( real_t px, real_t py, real_t pz ) const;
    inline const Vec3     pointFromBFtoWF ( const Vec3& rpos )          const;
-   virtual const Vec3    velFromBF       ( real_t px, real_t py, real_t pz ) const;
-   virtual const Vec3    velFromBF       ( const Vec3& rpos )          const;
+   virtual Vec3    velFromBF       ( real_t px, real_t py, real_t pz ) const;
+   virtual Vec3    velFromBF       ( const Vec3& rpos )          const;
    inline const Vec3     vectorFromWFtoBF( real_t vx, real_t vy, real_t vz ) const;
    inline const Vec3     vectorFromWFtoBF( const Vec3& v )             const;
    inline const Vec3     pointFromWFtoBF ( real_t px, real_t py, real_t pz ) const;
    inline const Vec3     pointFromWFtoBF ( const Vec3& gpos )          const;
-   virtual const Vec3    velFromWF       ( real_t px, real_t py, real_t pz ) const;
-   virtual const Vec3    velFromWF       ( const Vec3& gpos )          const;
+   virtual Vec3    velFromWF       ( real_t px, real_t py, real_t pz ) const;
+   virtual Vec3    velFromWF       ( const Vec3& gpos )          const;
    inline const Vec3     accFromWF       ( real_t px, real_t py, real_t pz ) const;
           const Vec3     accFromWF       ( const Vec3& gpos )          const;
 
diff --git a/src/pe/rigidbody/Squirmer.cpp b/src/pe/rigidbody/Squirmer.cpp
index e9d386c59..4a9f714b5 100644
--- a/src/pe/rigidbody/Squirmer.cpp
+++ b/src/pe/rigidbody/Squirmer.cpp
@@ -89,7 +89,7 @@ Squirmer::~Squirmer()
  *
  * The function calculates the global velocity of a point relative to the body's center of mass.
  */
-const Vec3 Squirmer::velFromBF( real_t px, real_t py, real_t pz ) const
+Vec3 Squirmer::velFromBF( real_t px, real_t py, real_t pz ) const
 {
    return velFromBF( Vec3( px, py, pz ) );
 }
@@ -104,7 +104,7 @@ const Vec3 Squirmer::velFromBF( real_t px, real_t py, real_t pz ) const
  *
  * The function calculates the global velocity of a point relative to the body's center of mass.
  */
-const Vec3 Squirmer::velFromBF( const Vec3& rpos ) const
+Vec3 Squirmer::velFromBF( const Vec3& rpos ) const
 {
    return Sphere::velFromBF( rpos ) + getSquirmerVelocity( getRotation() * rpos );
 }
@@ -120,7 +120,7 @@ const Vec3 Squirmer::velFromBF( const Vec3& rpos ) const
  *
  * The function calculates the global velocity of a point in global coordinates.
  */
-const Vec3 Squirmer::velFromWF( real_t px, real_t py, real_t pz ) const
+Vec3 Squirmer::velFromWF( real_t px, real_t py, real_t pz ) const
 {
    return velFromWF( Vec3( px, py, pz ) );
 }
@@ -133,7 +133,7 @@ const Vec3 Squirmer::velFromWF( real_t px, real_t py, real_t pz ) const
  * \param rpos The relative global coordinate.
  * \return The local surface velocity of the squirmer.
  */
-const Vec3 Squirmer::getSquirmerVelocity( const Vec3& rpos ) const
+Vec3 Squirmer::getSquirmerVelocity( const Vec3& rpos ) const
 {
    const auto rs = rpos.getNormalized();
    const auto e = getQuaternion().rotate(Vec3(0.0,0.0,1.0)).getNormalized();
@@ -152,7 +152,7 @@ const Vec3 Squirmer::getSquirmerVelocity( const Vec3& rpos ) const
  *
  * The function calculates the global velocity of a point in global coordinates.
  */
-const Vec3 Squirmer::velFromWF( const Vec3& gpos ) const
+Vec3 Squirmer::velFromWF( const Vec3& gpos ) const
 {
    return Sphere::velFromWF( gpos ) + getSquirmerVelocity( gpos - getPosition() );
 }
diff --git a/src/pe/rigidbody/Squirmer.h b/src/pe/rigidbody/Squirmer.h
index 0d9514324..688894cff 100644
--- a/src/pe/rigidbody/Squirmer.h
+++ b/src/pe/rigidbody/Squirmer.h
@@ -53,10 +53,10 @@ public:
    inline real_t getSquirmerVelocity() const;
    inline real_t getSquirmerBeta()     const;
 
-   inline const Vec3     velFromBF       ( real_t px, real_t py, real_t pz ) const WALBERLA_OVERRIDE;
-   inline const Vec3     velFromBF       ( const Vec3& rpos )                const WALBERLA_OVERRIDE;
-   inline const Vec3     velFromWF       ( real_t px, real_t py, real_t pz ) const WALBERLA_OVERRIDE;
-   inline const Vec3     velFromWF       ( const Vec3& gpos )                const WALBERLA_OVERRIDE;
+   inline Vec3     velFromBF       ( real_t px, real_t py, real_t pz ) const WALBERLA_OVERRIDE;
+   inline Vec3     velFromBF       ( const Vec3& rpos )                const WALBERLA_OVERRIDE;
+   inline Vec3     velFromWF       ( real_t px, real_t py, real_t pz ) const WALBERLA_OVERRIDE;
+   inline Vec3     velFromWF       ( const Vec3& gpos )                const WALBERLA_OVERRIDE;
 
    static inline id_t getStaticTypeID() WALBERLA_OVERRIDE;
    //@}
@@ -67,7 +67,7 @@ protected:
    //**Get functions*******************************************************************************
    /*!\name Get functions */
    //@{
-   const Vec3 getSquirmerVelocity( const Vec3& rpos ) const;
+   Vec3 getSquirmerVelocity( const Vec3& rpos ) const;
    //@}
 
    //**Member variables****************************************************************************
-- 
GitLab