diff --git a/src/Base/Axis.cpp b/src/Base/Axis.cpp index 45959d991b..8c0450906c 100644 --- a/src/Base/Axis.cpp +++ b/src/Base/Axis.cpp @@ -38,9 +38,9 @@ void Axis::reverse() Axis Axis::reversed() const { - Axis a(*this); - a.reverse(); - return a; + Axis axis(*this); + axis.reverse(); + return axis; } void Axis::move(const Vector3d& MovVec) @@ -58,16 +58,16 @@ bool Axis::operator!=(const Axis& that) const return !(*this == that); } -Axis& Axis::operator*=(const Placement& p) +Axis& Axis::operator*=(const Placement& plm) { - p.multVec(this->_base, this->_base); - p.getRotation().multVec(this->_dir, this->_dir); + plm.multVec(this->_base, this->_base); + plm.getRotation().multVec(this->_dir, this->_dir); return *this; } -Axis Axis::operator*(const Placement& p) const +Axis Axis::operator*(const Placement& plm) const { - Axis a(*this); - a *= p; - return a; + Axis axis(*this); + axis *= plm; + return axis; } diff --git a/src/Base/Axis.h b/src/Base/Axis.h index b0ef8b04b3..b7bac366e0 100644 --- a/src/Base/Axis.h +++ b/src/Base/Axis.h @@ -67,8 +67,8 @@ public: /** Operators. */ //@{ - Axis& operator*=(const Placement& p); - Axis operator*(const Placement& p) const; + Axis& operator*=(const Placement& plm); + Axis operator*(const Placement& plm) const; bool operator==(const Axis&) const; bool operator!=(const Axis&) const; Axis& operator=(const Axis&) = default; diff --git a/src/Base/BaseClass.h b/src/Base/BaseClass.h index 3de71239de..a7514848c3 100644 --- a/src/Base/BaseClass.h +++ b/src/Base/BaseClass.h @@ -191,10 +191,10 @@ public: * */ template -T* freecad_dynamic_cast(Base::BaseClass* t) +T* freecad_dynamic_cast(Base::BaseClass* type) { - if (t && t->isDerivedFrom(T::getClassTypeId())) { - return static_cast(t); + if (type && type->isDerivedFrom(T::getClassTypeId())) { + return static_cast(type); } else { return nullptr; @@ -207,10 +207,10 @@ T* freecad_dynamic_cast(Base::BaseClass* t) * */ template -const T* freecad_dynamic_cast(const Base::BaseClass* t) +const T* freecad_dynamic_cast(const Base::BaseClass* type) { - if (t && t->isDerivedFrom(T::getClassTypeId())) { - return static_cast(t); + if (type && type->isDerivedFrom(T::getClassTypeId())) { + return static_cast(type); } else { return nullptr; diff --git a/src/Base/Bitmask.h b/src/Base/Bitmask.h index 1c6c0792b9..cae10e6bee 100644 --- a/src/Base/Bitmask.h +++ b/src/Base/Bitmask.h @@ -44,6 +44,7 @@ @endcode */ +// NOLINTBEGIN // clang-format off // Based on https://stackoverflow.com/questions/1448396/how-to-use-enums-as-flags-in-c template struct enum_traits {}; @@ -130,5 +131,6 @@ public: }; } // clang-format on +// NOLINTEND #endif diff --git a/src/Base/Builder3D.h b/src/Base/Builder3D.h index d23ca95241..48a9e40f14 100644 --- a/src/Base/Builder3D.h +++ b/src/Base/Builder3D.h @@ -212,9 +212,9 @@ public: { return spaces; } - friend std::ostream& operator<<(std::ostream& os, Indentation m) + friend std::ostream& operator<<(std::ostream& os, Indentation ind) { - for (int i = 0; i < m.count(); i++) { + for (int i = 0; i < ind.count(); i++) { os << " "; } return os; diff --git a/src/Base/Console.cpp b/src/Base/Console.cpp index c161c25244..c25c24b042 100644 --- a/src/Base/Console.cpp +++ b/src/Base/Console.cpp @@ -176,9 +176,9 @@ ConsoleSingleton::~ConsoleSingleton() /** * sets the console in a special mode */ -void ConsoleSingleton::SetConsoleMode(ConsoleMode m) +void ConsoleSingleton::SetConsoleMode(ConsoleMode mode) { - if (m & Verbose) { + if (mode & Verbose) { _bVerbose = true; } } @@ -186,9 +186,9 @@ void ConsoleSingleton::SetConsoleMode(ConsoleMode m) /** * unsets the console from a special mode */ -void ConsoleSingleton::UnsetConsoleMode(ConsoleMode m) +void ConsoleSingleton::UnsetConsoleMode(ConsoleMode mode) { - if (m & Verbose) { + if (mode & Verbose) { _bVerbose = false; } } @@ -211,47 +211,47 @@ void ConsoleSingleton::UnsetConsoleMode(ConsoleMode m) * switches off warnings and error messages and restore the state before the modification. * If the observer \a sObs doesn't exist then nothing happens. */ -ConsoleMsgFlags ConsoleSingleton::SetEnabledMsgType(const char* sObs, ConsoleMsgFlags type, bool b) +ConsoleMsgFlags ConsoleSingleton::SetEnabledMsgType(const char* sObs, ConsoleMsgFlags type, bool on) { ILogger* pObs = Get(sObs); if (pObs) { ConsoleMsgFlags flags = 0; if (type & MsgType_Err) { - if (pObs->bErr != b) { + if (pObs->bErr != on) { flags |= MsgType_Err; } - pObs->bErr = b; + pObs->bErr = on; } if (type & MsgType_Wrn) { - if (pObs->bWrn != b) { + if (pObs->bWrn != on) { flags |= MsgType_Wrn; } - pObs->bWrn = b; + pObs->bWrn = on; } if (type & MsgType_Txt) { - if (pObs->bMsg != b) { + if (pObs->bMsg != on) { flags |= MsgType_Txt; } - pObs->bMsg = b; + pObs->bMsg = on; } if (type & MsgType_Log) { - if (pObs->bLog != b) { + if (pObs->bLog != on) { flags |= MsgType_Log; } - pObs->bLog = b; + pObs->bLog = on; } if (type & MsgType_Critical) { - if (pObs->bCritical != b) { + if (pObs->bCritical != on) { flags |= MsgType_Critical; } - pObs->bCritical = b; + pObs->bCritical = on; } if (type & MsgType_Notification) { - if (pObs->bNotification != b) { + if (pObs->bNotification != on) { flags |= MsgType_Notification; } - pObs->bNotification = b; + pObs->bNotification = on; } return flags; diff --git a/src/Base/Console.h b/src/Base/Console.h index 45fb9c9443..ad641d792a 100644 --- a/src/Base/Console.h +++ b/src/Base/Console.h @@ -487,12 +487,12 @@ namespace Base { #ifndef FC_LOG_NO_TIMING -inline FC_DURATION GetDuration(FC_TIME_POINT& t) +inline FC_DURATION GetDuration(FC_TIME_POINT& tp) { auto tnow = std::chrono::FC_TIME_CLOCK::now(); - auto d = std::chrono::duration_cast(tnow - t); - t = tnow; - return d; + auto dc = std::chrono::duration_cast(tnow - tp); + tp = tnow; + return dc; } #endif @@ -805,11 +805,11 @@ public: }; /// Change mode - void SetConsoleMode(ConsoleMode m); + void SetConsoleMode(ConsoleMode mode); /// Change mode - void UnsetConsoleMode(ConsoleMode m); + void UnsetConsoleMode(ConsoleMode mode); /// Enables or disables message types of a certain console observer - ConsoleMsgFlags SetEnabledMsgType(const char* sObs, ConsoleMsgFlags type, bool b); + ConsoleMsgFlags SetEnabledMsgType(const char* sObs, ConsoleMsgFlags type, bool on); /// Checks if message types of a certain console observer are enabled bool IsMsgTypeEnabled(const char* sObs, FreeCAD_ConsoleMsgType type) const; void SetConnectionMode(ConnectionMode mode); @@ -957,9 +957,9 @@ public: , refresh(refresh) {} - bool isEnabled(int l) + bool isEnabled(int lev) const { - return l <= level(); + return lev <= level(); } int level() const diff --git a/src/Base/ConsoleObserver.cpp b/src/Base/ConsoleObserver.cpp index 7ad627a239..2689e70243 100644 --- a/src/Base/ConsoleObserver.cpp +++ b/src/Base/ConsoleObserver.cpp @@ -248,12 +248,12 @@ RedirectStdOutput::RedirectStdOutput() buffer.reserve(80); } -int RedirectStdOutput::overflow(int c) +int RedirectStdOutput::overflow(int ch) { - if (c != EOF) { - buffer.push_back(static_cast(c)); + if (ch != EOF) { + buffer.push_back(static_cast(ch)); } - return c; + return ch; } int RedirectStdOutput::sync() @@ -271,12 +271,12 @@ RedirectStdLog::RedirectStdLog() buffer.reserve(80); } -int RedirectStdLog::overflow(int c) +int RedirectStdLog::overflow(int ch) { - if (c != EOF) { - buffer.push_back(static_cast(c)); + if (ch != EOF) { + buffer.push_back(static_cast(ch)); } - return c; + return ch; } int RedirectStdLog::sync() @@ -294,12 +294,12 @@ RedirectStdError::RedirectStdError() buffer.reserve(80); } -int RedirectStdError::overflow(int c) +int RedirectStdError::overflow(int ch) { - if (c != EOF) { - buffer.push_back(static_cast(c)); + if (ch != EOF) { + buffer.push_back(static_cast(ch)); } - return c; + return ch; } int RedirectStdError::sync() @@ -323,8 +323,8 @@ std::stringstream& LogLevel::prefix(std::stringstream& str, const char* src, int _FC_TIME_INIT(s_tstart); } auto tnow = std::chrono::FC_TIME_CLOCK::now(); - auto d = std::chrono::duration_cast(tnow - s_tstart); - str << d.count() << ' '; + auto dc = std::chrono::duration_cast(tnow - s_tstart); + str << dc.count() << ' '; } if (print_tag) { str << '<' << tag << "> "; diff --git a/src/Base/ConsoleObserver.h b/src/Base/ConsoleObserver.h index 74e9f45a27..3c69faccfd 100644 --- a/src/Base/ConsoleObserver.h +++ b/src/Base/ConsoleObserver.h @@ -148,7 +148,7 @@ public: RedirectStdOutput(); protected: - int overflow(int c = EOF) override; + int overflow(int ch = EOF) override; int sync() override; private: @@ -161,7 +161,7 @@ public: RedirectStdError(); protected: - int overflow(int c = EOF) override; + int overflow(int ch = EOF) override; int sync() override; private: @@ -174,7 +174,7 @@ public: RedirectStdLog(); protected: - int overflow(int c = EOF) override; + int overflow(int ch = EOF) override; int sync() override; private: diff --git a/src/Base/Converter.h b/src/Base/Converter.h index 2a7aa40a81..6443c38dab 100644 --- a/src/Base/Converter.h +++ b/src/Base/Converter.h @@ -42,8 +42,8 @@ struct vec_traits { using vec_type = Vector3f; using float_type = float; - vec_traits(const vec_type& v) - : v(v) + explicit vec_traits(const vec_type& vec) + : v(vec) {} inline std::tuple get() const { @@ -59,8 +59,8 @@ struct vec_traits { using vec_type = Vector3d; using float_type = double; - vec_traits(const vec_type& v) - : v(v) + explicit vec_traits(const vec_type& vec) + : v(vec) {} inline std::tuple get() const { @@ -76,8 +76,8 @@ struct vec_traits { using vec_type = Rotation; using float_type = double; - vec_traits(const vec_type& v) - : v(v) + explicit vec_traits(const vec_type& vec) + : v(vec) {} inline std::tuple get() const { @@ -92,34 +92,34 @@ private: // type with three floats template -_Vec make_vec(const std::tuple&& t) +_Vec make_vec(const std::tuple&& ft) { using traits_type = vec_traits<_Vec>; using float_traits_type = typename traits_type::float_type; - return _Vec(float_traits_type(std::get<0>(t)), - float_traits_type(std::get<1>(t)), - float_traits_type(std::get<2>(t))); + return _Vec(float_traits_type(std::get<0>(ft)), + float_traits_type(std::get<1>(ft)), + float_traits_type(std::get<2>(ft))); } // type with four floats template -_Vec make_vec(const std::tuple&& t) +_Vec make_vec(const std::tuple&& ft) { using traits_type = vec_traits<_Vec>; using float_traits_type = typename traits_type::float_type; - return _Vec(float_traits_type(std::get<0>(t)), - float_traits_type(std::get<1>(t)), - float_traits_type(std::get<2>(t)), - float_traits_type(std::get<3>(t))); + return _Vec(float_traits_type(std::get<0>(ft)), + float_traits_type(std::get<1>(ft)), + float_traits_type(std::get<2>(ft)), + float_traits_type(std::get<3>(ft))); } template -inline _Vec1 convertTo(const _Vec2& v) +inline _Vec1 convertTo(const _Vec2& vec) { using traits_type = vec_traits<_Vec2>; using float_type = typename traits_type::float_type; - traits_type t(v); - auto tuple = t.get(); + traits_type tt(vec); + auto tuple = tt.get(); return make_vec<_Vec1, float_type>(std::move(tuple)); } diff --git a/src/Base/CoordinateSystem.cpp b/src/Base/CoordinateSystem.cpp index 40fe56b1e7..8602a1e1e5 100644 --- a/src/Base/CoordinateSystem.cpp +++ b/src/Base/CoordinateSystem.cpp @@ -38,21 +38,21 @@ CoordinateSystem::CoordinateSystem() CoordinateSystem::~CoordinateSystem() = default; -void CoordinateSystem::setAxes(const Axis& v, const Vector3d& xd) +void CoordinateSystem::setAxes(const Axis& vec, const Vector3d& xd) { if (xd.Sqr() < Base::Vector3d::epsilon()) { throw Base::ValueError("Direction is null vector"); } - Vector3d yd = v.getDirection() % xd; + Vector3d yd = vec.getDirection() % xd; if (yd.Sqr() < Base::Vector3d::epsilon()) { throw Base::ValueError("Direction is parallel to Z direction"); } ydir = yd; ydir.Normalize(); - xdir = ydir % v.getDirection(); + xdir = ydir % vec.getDirection(); xdir.Normalize(); - axis.setBase(v.getBase()); - Base::Vector3d zdir = v.getDirection(); + axis.setBase(vec.getBase()); + Base::Vector3d zdir = vec.getDirection(); zdir.Normalize(); axis.setDirection(zdir); } @@ -75,9 +75,9 @@ void CoordinateSystem::setAxes(const Vector3d& n, const Vector3d& xd) axis.setDirection(zdir); } -void CoordinateSystem::setAxis(const Axis& v) +void CoordinateSystem::setAxis(const Axis& axis) { - setAxes(v, xdir); + setAxes(axis, xdir); } void CoordinateSystem::setXDirection(const Vector3d& dir) @@ -111,6 +111,7 @@ void CoordinateSystem::setZDirection(const Vector3d& dir) Placement CoordinateSystem::displacement(const CoordinateSystem& cs) const { + // NOLINTBEGIN const Base::Vector3d& a = axis.getBase(); const Base::Vector3d& zdir = axis.getDirection(); Base::Matrix4D At; @@ -148,36 +149,37 @@ Placement CoordinateSystem::displacement(const CoordinateSystem& cs) const Placement PB(B); Placement C = PB * PAt; return C; + // NOLINTEND } -void CoordinateSystem::transformTo(Vector3d& p) +void CoordinateSystem::transformTo(Vector3d& pnt) { - return p.TransformToCoordinateSystem(axis.getBase(), xdir, ydir); + return pnt.TransformToCoordinateSystem(axis.getBase(), xdir, ydir); } -void CoordinateSystem::transform(const Placement& p) +void CoordinateSystem::transform(const Placement& plm) { - axis *= p; - p.getRotation().multVec(this->xdir, this->xdir); - p.getRotation().multVec(this->ydir, this->ydir); + axis *= plm; + plm.getRotation().multVec(this->xdir, this->xdir); + plm.getRotation().multVec(this->ydir, this->ydir); } -void CoordinateSystem::transform(const Rotation& r) +void CoordinateSystem::transform(const Rotation& rot) { Vector3d zdir = axis.getDirection(); - r.multVec(zdir, zdir); + rot.multVec(zdir, zdir); axis.setDirection(zdir); - r.multVec(this->xdir, this->xdir); - r.multVec(this->ydir, this->ydir); + rot.multVec(this->xdir, this->xdir); + rot.multVec(this->ydir, this->ydir); } -void CoordinateSystem::setPlacement(const Placement& p) +void CoordinateSystem::setPlacement(const Placement& plm) { Vector3d zdir(0, 0, 1); - p.getRotation().multVec(zdir, zdir); - axis.setBase(p.getPosition()); + plm.getRotation().multVec(zdir, zdir); + axis.setBase(plm.getPosition()); axis.setDirection(zdir); - p.getRotation().multVec(Vector3d(1, 0, 0), this->xdir); - p.getRotation().multVec(Vector3d(0, 1, 0), this->ydir); + plm.getRotation().multVec(Vector3d(1, 0, 0), this->xdir); + plm.getRotation().multVec(Vector3d(0, 1, 0), this->ydir); } diff --git a/src/Base/CoordinateSystem.h b/src/Base/CoordinateSystem.h index 1757a47f14..ac4200c320 100644 --- a/src/Base/CoordinateSystem.h +++ b/src/Base/CoordinateSystem.h @@ -49,7 +49,7 @@ public: /** Sets the main axis. X and Y dir are adjusted accordingly. * The main axis \a v must not be parallel to the X axis */ - void setAxis(const Axis& v); + void setAxis(const Axis& axis); /** Sets the main axis. X and Y dir are adjusted accordingly. * The main axis must not be parallel to \a xd */ @@ -85,9 +85,9 @@ public: { return axis.getDirection(); } - inline void setPosition(const Vector3d& p) + inline void setPosition(const Vector3d& pos) { - axis.setBase(p); + axis.setBase(pos); } inline const Vector3d& getPosition() const { @@ -99,17 +99,17 @@ public: */ Placement displacement(const CoordinateSystem& cs) const; - /** Transform the point \a p to be in this coordinate system */ - void transformTo(Vector3d& p); + /** Transform the point \a pnt to be in this coordinate system */ + void transformTo(Vector3d& pnt); - /** Apply the placement \a p to the coordinate system. */ - void transform(const Placement& p); + /** Apply the placement \a plm to the coordinate system. */ + void transform(const Placement& plm); - /** Apply the rotation \a r to the coordinate system. */ - void transform(const Rotation& r); + /** Apply the rotation \a rot to the coordinate system. */ + void transform(const Rotation& rot); - /** Set the placement \a p to the coordinate system. */ - void setPlacement(const Placement& p); + /** Set the placement \a plm to the coordinate system. */ + void setPlacement(const Placement& plm); private: Axis axis; diff --git a/src/Base/CoordinateSystemPyImp.cpp b/src/Base/CoordinateSystemPyImp.cpp index 82cb6a53ba..7afd90484c 100644 --- a/src/Base/CoordinateSystemPyImp.cpp +++ b/src/Base/CoordinateSystemPyImp.cpp @@ -76,20 +76,20 @@ PyObject* CoordinateSystemPy::displacement(PyObject* args) if (!PyArg_ParseTuple(args, "O!", &(CoordinateSystemPy::Type), &cs)) { return nullptr; } - Placement p = getCoordinateSystemPtr()->displacement( + Placement plm = getCoordinateSystemPtr()->displacement( *static_cast(cs)->getCoordinateSystemPtr()); - return new PlacementPy(new Placement(p)); + return new PlacementPy(new Placement(plm)); } PyObject* CoordinateSystemPy::transformTo(PyObject* args) { - PyObject* vec {}; - if (!PyArg_ParseTuple(args, "O!", &(VectorPy::Type), &vec)) { + PyObject* vecpy {}; + if (!PyArg_ParseTuple(args, "O!", &(VectorPy::Type), &vecpy)) { return nullptr; } - Vector3d v = static_cast(vec)->value(); - getCoordinateSystemPtr()->transformTo(v); - return new VectorPy(new Vector3d(v)); + Vector3d vec = static_cast(vecpy)->value(); + getCoordinateSystemPtr()->transformTo(vec); + return new VectorPy(new Vector3d(vec)); } PyObject* CoordinateSystemPy::transform(PyObject* args) diff --git a/src/Base/DualNumber.h b/src/Base/DualNumber.h index 32bd6efa8a..0b5224a998 100644 --- a/src/Base/DualNumber.h +++ b/src/Base/DualNumber.h @@ -25,6 +25,7 @@ #include +// NOLINTBEGIN(readability-identifier-length) namespace Base { @@ -44,7 +45,7 @@ public: public: DualNumber() = default; - DualNumber(double re, double du = 0.0) + DualNumber(double re, double du = 0.0) // NOLINT : re(re) , du(du) {} @@ -107,6 +108,7 @@ inline DualNumber pow(DualNumber a, double pw) return {std::pow(a.re, pw), pw * std::pow(a.re, pw - 1.0) * a.du}; } } // namespace Base +// NOLINTEND(readability-identifier-length) #endif diff --git a/src/Base/DualQuaternion.cpp b/src/Base/DualQuaternion.cpp index 2dc144ad9d..e1b611e882 100644 --- a/src/Base/DualQuaternion.cpp +++ b/src/Base/DualQuaternion.cpp @@ -26,6 +26,7 @@ #include "DualQuaternion.h" +// NOLINTBEGIN(readability-identifier-length) Base::DualQuat Base::operator+(Base::DualQuat a, Base::DualQuat b) { return {a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w}; @@ -131,3 +132,4 @@ Base::DualQuat Base::DualQuat::pow(double t, bool shorten) const m * sin(theta / 2) + pitch / 2 * cos(theta / 2) * l + DualQuat(0, 0, 0, -pitch / 2 * sin(theta / 2))}; } +// NOLINTEND(readability-identifier-length) diff --git a/src/Base/DualQuaternion.h b/src/Base/DualQuaternion.h index 467c205b17..cef6394663 100644 --- a/src/Base/DualQuaternion.h +++ b/src/Base/DualQuaternion.h @@ -26,7 +26,7 @@ #include "DualNumber.h" #include - +// NOLINTBEGIN(readability-identifier-length) namespace Base { @@ -146,5 +146,6 @@ BaseExport DualQuat operator*(DualNumber a, DualQuat b); } // namespace Base +// NOLINTEND(readability-identifier-length) #endif diff --git a/src/Base/ExceptionFactory.h b/src/Base/ExceptionFactory.h index 77e83cfab9..76d12aa825 100644 --- a/src/Base/ExceptionFactory.h +++ b/src/Base/ExceptionFactory.h @@ -79,10 +79,10 @@ public: void raiseException(PyObject* pydict) const override { - CLASS c; - c.setPyObject(pydict); + CLASS cls; + cls.setPyObject(pydict); - throw c; + throw cls; } }; diff --git a/src/Base/FileInfo.cpp b/src/Base/FileInfo.cpp index e441b7789f..7be10cae87 100644 --- a/src/Base/FileInfo.cpp +++ b/src/Base/FileInfo.cpp @@ -218,13 +218,13 @@ boost::filesystem::path FileInfo::stringToPath(const std::string& str) return path; } -std::string FileInfo::pathToString(const boost::filesystem::path& p) +std::string FileInfo::pathToString(const boost::filesystem::path& path) { #if defined(FC_OS_WIN32) std::wstring_convert> converter; - return converter.to_bytes(p.wstring()); + return converter.to_bytes(path.wstring()); #else - return p.string(); + return path.string(); #endif } diff --git a/src/Base/FileInfo.h b/src/Base/FileInfo.h index 4cddf20617..6a9a41be5a 100644 --- a/src/Base/FileInfo.h +++ b/src/Base/FileInfo.h @@ -158,7 +158,7 @@ public: /// Get the path to the dir which is considered to temp files static const std::string& getTempPath(); /// Convert from filesystem path to string - static std::string pathToString(const boost::filesystem::path& p); + static std::string pathToString(const boost::filesystem::path& path); /// Convert from string to filesystem path static boost::filesystem::path stringToPath(const std::string& str); //@} diff --git a/src/Base/FutureWatcherProgress.cpp b/src/Base/FutureWatcherProgress.cpp index 0fbf90c05b..ab2de29e2e 100644 --- a/src/Base/FutureWatcherProgress.cpp +++ b/src/Base/FutureWatcherProgress.cpp @@ -35,12 +35,12 @@ FutureWatcherProgress::FutureWatcherProgress(const char* text, unsigned int step FutureWatcherProgress::~FutureWatcherProgress() = default; -void FutureWatcherProgress::progressValueChanged(int v) +void FutureWatcherProgress::progressValueChanged(int value) { if (steps == 0) { return; } - unsigned int step = (100 * static_cast(v)) / steps; + unsigned int step = (100 * static_cast(value)) / steps; if (step > current) { current = step; seq.next(); diff --git a/src/Base/GeometryPyCXX.cpp b/src/Base/GeometryPyCXX.cpp index 33738dafa5..d7acbb307f 100644 --- a/src/Base/GeometryPyCXX.cpp +++ b/src/Base/GeometryPyCXX.cpp @@ -30,6 +30,7 @@ #include "VectorPy.h" +// NOLINTBEGIN(readability-identifier-length) int Py::Vector::Vector_TypeCheck(PyObject* obj) { return PyObject_TypeCheck(obj, &(Base::VectorPy::Type)); @@ -47,15 +48,15 @@ bool Py::Vector::accepts(PyObject* obj) const return false; } -Py::Vector::Vector(const Base::Vector3d& v) +Py::Vector::Vector(const Base::Vector3d& vec) { - set(new Base::VectorPy(v), true); + set(new Base::VectorPy(vec), true); validate(); } -Py::Vector::Vector(const Base::Vector3f& v) +Py::Vector::Vector(const Base::Vector3f& vec) { - set(new Base::VectorPy(v), true); + set(new Base::VectorPy(vec), true); validate(); } @@ -68,15 +69,15 @@ Py::Vector& Py::Vector::operator=(PyObject* rhsp) return *this; } -Py::Vector& Py::Vector::operator=(const Base::Vector3d& v) +Py::Vector& Py::Vector::operator=(const Base::Vector3d& vec) { - set(new Base::VectorPy(v), true); + set(new Base::VectorPy(vec), true); return *this; } -Py::Vector& Py::Vector::operator=(const Base::Vector3f& v) +Py::Vector& Py::Vector::operator=(const Base::Vector3f& vec) { - set(new Base::VectorPy(v), true); + set(new Base::VectorPy(vec), true); return *this; } @@ -103,48 +104,48 @@ PyTypeObject* Vector2dPy::type_object() return Py::PythonClass::type_object(); } -bool Vector2dPy::check(PyObject* p) +bool Vector2dPy::check(PyObject* py) { - return Py::PythonClass::check(p); + return Py::PythonClass::check(py); } -Py::PythonClassObject Vector2dPy::create(const Vector2d& v) +Py::PythonClassObject Vector2dPy::create(const Vector2d& vec) { - return create(v.x, v.y); + return create(vec.x, vec.y); } -Py::PythonClassObject Vector2dPy::create(double x, double y) +Py::PythonClassObject Vector2dPy::create(double vx, double vy) { Py::Callable class_type(type()); Py::Tuple arg(2); - arg.setItem(0, Py::Float(x)); - arg.setItem(1, Py::Float(y)); - Py::PythonClassObject o = + arg.setItem(0, Py::Float(vx)); + arg.setItem(1, Py::Float(vy)); + Py::PythonClassObject py = Py::PythonClassObject(class_type.apply(arg, Py::Dict())); - return o; + return py; } Vector2dPy::Vector2dPy(Py::PythonClassInstance* self, Py::Tuple& args, Py::Dict& kwds) : Py::PythonClass::PythonClass(self, args, kwds) { - double x = 0, y = 0; - if (!PyArg_ParseTuple(args.ptr(), "|dd", &x, &y)) { + double vx = 0, vy = 0; + if (!PyArg_ParseTuple(args.ptr(), "|dd", &vx, &vy)) { throw Py::Exception(); } - v.x = x; - v.y = y; + v.x = vx; + v.y = vy; } Vector2dPy::~Vector2dPy() = default; Py::Object Vector2dPy::repr() { - Py::Float x(v.x); - Py::Float y(v.y); + Py::Float vx(v.x); + Py::Float vy(v.y); std::stringstream str; str << "Vector2 ("; - str << static_cast(x.repr()) << ", " << static_cast(y.repr()); + str << static_cast(vx.repr()) << ", " << static_cast(vy.repr()); str << ")"; return Py::String(str.str()); @@ -223,28 +224,28 @@ Py::Object Vector2dPy::number_float() Py::Object Vector2dPy::number_add(const Py::Object& py) { - Vector2d u(Py::toVector2d(py)); - u = v + u; - return create(u); + Vector2d vec(Py::toVector2d(py)); + vec = v + vec; + return create(vec); } Py::Object Vector2dPy::number_subtract(const Py::Object& py) { - Vector2d u(Py::toVector2d(py)); - u = v - u; - return create(u); + Vector2d vec(Py::toVector2d(py)); + vec = v - vec; + return create(vec); } Py::Object Vector2dPy::number_multiply(const Py::Object& py) { if (PyObject_TypeCheck(py.ptr(), Vector2dPy::type_object())) { - Vector2d u(Py::toVector2d(py)); - double d = v * u; - return Py::Float(d); + Vector2d vec(Py::toVector2d(py)); + double scalar = v * vec; + return Py::Float(scalar); } else if (py.isNumeric()) { - double d = static_cast(Py::Float(py)); - return create(v * d); + double scale = static_cast(Py::Float(py)); + return create(v * scale); } else { throw Py::TypeError("Argument must be Vector2d or Float"); @@ -321,16 +322,16 @@ PYCXX_VARARGS_METHOD_DECL(Vector2dPy, square) Py::Object Vector2dPy::scale(const Py::Tuple& args) { - double f = static_cast(Py::Float(args[0])); - v.Scale(f); + double value = static_cast(Py::Float(args[0])); + v.Scale(value); return Py::None(); } PYCXX_VARARGS_METHOD_DECL(Vector2dPy, scale) Py::Object Vector2dPy::rotate(const Py::Tuple& args) { - double f = static_cast(Py::Float(args[0])); - v.Rotate(f); + double value = static_cast(Py::Float(args[0])); + v.Rotate(value); return Py::None(); } PYCXX_VARARGS_METHOD_DECL(Vector2dPy, rotate) @@ -344,42 +345,43 @@ PYCXX_VARARGS_METHOD_DECL(Vector2dPy, normalize) Py::Object Vector2dPy::perpendicular(const Py::Tuple& args) { - bool f = static_cast(Py::Boolean(args[0])); - Base::Vector2d p = v.Perpendicular(f); - return create(p); + bool value = static_cast(Py::Boolean(args[0])); + Base::Vector2d pnt = v.Perpendicular(value); + return create(pnt); } PYCXX_VARARGS_METHOD_DECL(Vector2dPy, perpendicular) Py::Object Vector2dPy::distance(const Py::Tuple& args) { - Base::Vector2d p = Py::toVector2d(args[0]); - return Py::Float(p.Distance(v)); + Base::Vector2d pnt = Py::toVector2d(args[0]); + return Py::Float(pnt.Distance(v)); } PYCXX_VARARGS_METHOD_DECL(Vector2dPy, distance) Py::Object Vector2dPy::isEqual(const Py::Tuple& args) { - Base::Vector2d p = Py::toVector2d(args[0]); - double f = static_cast(Py::Float(args[1])); - return Py::Boolean(v.IsEqual(p, f)); + Base::Vector2d pnt = Py::toVector2d(args[0]); + double tol = static_cast(Py::Float(args[1])); + return Py::Boolean(v.IsEqual(pnt, tol)); } PYCXX_VARARGS_METHOD_DECL(Vector2dPy, isEqual) Py::Object Vector2dPy::getAngle(const Py::Tuple& args) { - Base::Vector2d p = Py::toVector2d(args[0]); - return Py::Float(v.GetAngle(p)); + Base::Vector2d vec = Py::toVector2d(args[0]); + return Py::Float(v.GetAngle(vec)); } PYCXX_VARARGS_METHOD_DECL(Vector2dPy, getAngle) Py::Object Vector2dPy::projectToLine(const Py::Tuple& args) { - Base::Vector2d p = Py::toVector2d(args[0]); - Base::Vector2d d = Py::toVector2d(args[1]); - v.ProjectToLine(p, d); + Base::Vector2d pnt1 = Py::toVector2d(args[0]); + Base::Vector2d pnt2 = Py::toVector2d(args[1]); + v.ProjectToLine(pnt1, pnt2); return Py::None(); } PYCXX_VARARGS_METHOD_DECL(Vector2dPy, projectToLine) +// NOLINTEND(readability-identifier-length) void Vector2dPy::init_type() { diff --git a/src/Base/GeometryPyCXX.h b/src/Base/GeometryPyCXX.h index 78602b70b3..2f075c6a99 100644 --- a/src/Base/GeometryPyCXX.h +++ b/src/Base/GeometryPyCXX.h @@ -40,18 +40,18 @@ namespace Base { template -inline Vector3 getVectorFromTuple(PyObject* o) +inline Vector3 getVectorFromTuple(PyObject* py) { - Py::Sequence tuple(o); + Py::Sequence tuple(py); if (tuple.size() != 3) { throw Py::ValueError("Expected sequence of size 3"); } - T x = static_cast(Py::Float(tuple[0])); - T y = static_cast(Py::Float(tuple[1])); - T z = static_cast(Py::Float(tuple[2])); + T vx = static_cast(Py::Float(tuple[0])); + T vy = static_cast(Py::Float(tuple[1])); + T vz = static_cast(Py::Float(tuple[2])); - return Vector3(x, y, z); + return Vector3(vx, vy, vz); } class BaseExport Vector2dPy: public Py::PythonClass // NOLINT @@ -59,10 +59,10 @@ class BaseExport Vector2dPy: public Py::PythonClass // NOLINT public: static Py::PythonType& behaviors(); static PyTypeObject* type_object(); - static bool check(PyObject* p); + static bool check(PyObject* py); static Py::PythonClassObject create(const Vector2d&); - static Py::PythonClassObject create(double x, double y); + static Py::PythonClassObject create(double vx, double vy); Vector2dPy(Py::PythonClassInstance* self, Py::Tuple& args, Py::Dict& kwds); ~Vector2dPy() override; @@ -78,10 +78,10 @@ public: { v = n; } - inline void setValue(double x, double y) + inline void setValue(double vx, double vy) { - v.x = x; - v.y = y; + v.x = vx; + v.y = vy; } /** @name methods for group handling */ @@ -220,9 +220,9 @@ public: set(new PyT(new T()), true); validate(); } - explicit GeometryT(const T& v) + explicit GeometryT(const T& val) { - set(new PyT(new T(v)), true); + set(new PyT(new T(val)), true); validate(); } GeometryT(const Object& other) @@ -246,9 +246,9 @@ public: set(rhsp, false); return *this; } - GeometryT& operator=(const T& v) + GeometryT& operator=(const T& val) { - set(new PyT(v), true); + set(new PyT(val), true); return *this; } const T& getValue() const @@ -256,8 +256,8 @@ public: // cast the PyObject pointer to the matching sub-class // and call then the defined member function PyT* py = static_cast(ptr()); - T* v = (py->*valuePtr)(); - return *v; + T* val = (py->*valuePtr)(); + return *val; } operator T() const { diff --git a/src/Base/Handle.h b/src/Base/Handle.h index a67754dfb4..fc8f6ccc25 100644 --- a/src/Base/Handle.h +++ b/src/Base/Handle.h @@ -52,8 +52,8 @@ public: : _toHandle(nullptr) {} - Reference(T* p) - : _toHandle(p) + Reference(T* pointer) + : _toHandle(pointer) { if (_toHandle) { _toHandle->ref(); @@ -61,8 +61,8 @@ public: } /** Copy constructor */ - Reference(const Reference& p) - : _toHandle(p._toHandle) + Reference(const Reference& ref) + : _toHandle(ref._toHandle) { if (_toHandle) { _toHandle->ref(); @@ -85,16 +85,16 @@ public: // operator implementation /** Assign operator from a pointer */ - Reference& operator=(T* p) + Reference& operator=(T* pointer) { // check if we want to reassign the same object - if (_toHandle == p) { + if (_toHandle == pointer) { return *this; } if (_toHandle) { _toHandle->unref(); } - _toHandle = p; + _toHandle = pointer; if (_toHandle) { _toHandle->ref(); } @@ -102,16 +102,16 @@ public: } /** Assign operator from a handle */ - Reference& operator=(const Reference& p) + Reference& operator=(const Reference& ref) { // check if we want to reassign the same object - if (_toHandle == p._toHandle) { + if (_toHandle == ref._toHandle) { return *this; } if (_toHandle) { _toHandle->unref(); } - _toHandle = p._toHandle; + _toHandle = ref._toHandle; if (_toHandle) { _toHandle->ref(); } diff --git a/src/Base/Interpreter.cpp b/src/Base/Interpreter.cpp index 7f788e847c..87e82f29b3 100644 --- a/src/Base/Interpreter.cpp +++ b/src/Base/Interpreter.cpp @@ -115,9 +115,9 @@ void PyException::raiseException() } if (_exceptionType == Base::PyExc_FC_FreeCADAbort) { - Base::AbortException e(_sErrMsg.c_str()); - e.setReported(_isReported); - throw e; + Base::AbortException exc(_sErrMsg.c_str()); + exc.setReported(_isReported); + throw exc; } throw *this; diff --git a/src/Base/ProgressIndicatorPy.cpp b/src/Base/ProgressIndicatorPy.cpp index 65346ca330..34fd911f1c 100644 --- a/src/Base/ProgressIndicatorPy.cpp +++ b/src/Base/ProgressIndicatorPy.cpp @@ -53,9 +53,9 @@ PyTypeObject* ProgressIndicatorPy::type_object() return Py::PythonExtension::type_object(); } -bool ProgressIndicatorPy::check(PyObject* p) +bool ProgressIndicatorPy::check(PyObject* py) { - return Py::PythonExtension::check(p); + return Py::PythonExtension::check(py); } PyObject* ProgressIndicatorPy::PyMake(struct _typeobject*, PyObject*, PyObject*) diff --git a/src/Base/ProgressIndicatorPy.h b/src/Base/ProgressIndicatorPy.h index 1b14ee8431..42c1491741 100644 --- a/src/Base/ProgressIndicatorPy.h +++ b/src/Base/ProgressIndicatorPy.h @@ -37,7 +37,7 @@ public: static void init_type(); // announce properties and methods static Py::PythonType& behaviors(); static PyTypeObject* type_object(); - static bool check(PyObject* p); + static bool check(PyObject* py); ProgressIndicatorPy(); ~ProgressIndicatorPy() override; diff --git a/src/Base/Sequencer.cpp b/src/Base/Sequencer.cpp index 15d140324f..f6cb224fa1 100644 --- a/src/Base/Sequencer.cpp +++ b/src/Base/Sequencer.cpp @@ -44,14 +44,14 @@ struct SequencerP /** Sets a global sequencer object. * Access to the last registered object is performed by @see Sequencer(). */ - static void appendInstance(SequencerBase* s) + static void appendInstance(SequencerBase* sb) { - _instances.push_back(s); + _instances.push_back(sb); } - static void removeInstance(SequencerBase* s) + static void removeInstance(SequencerBase* sb) { std::vector::iterator it; - it = std::find(_instances.begin(), _instances.end(), s); + it = std::find(_instances.begin(), _instances.end(), sb); _instances.erase(it); } static SequencerBase& getInstance() diff --git a/src/Base/SmartPtrPy.cpp b/src/Base/SmartPtrPy.cpp index a0ac89435e..5041d230e9 100644 --- a/src/Base/SmartPtrPy.cpp +++ b/src/Base/SmartPtrPy.cpp @@ -117,10 +117,10 @@ bool SmartPtr::isNull() const return p == nullptr; } -BaseExport PyObject* new_reference_to(const SmartPtr& g) +BaseExport PyObject* new_reference_to(const SmartPtr& ptr) { - PyObject* p = g.ptr(); - Py::_XINCREF(p); - return p; + PyObject* py = ptr.ptr(); + Py::_XINCREF(py); + return py; } } // namespace Py diff --git a/src/Base/TimeInfo.cpp b/src/Base/TimeInfo.cpp index 8b14da8bd2..b89e8d5c58 100644 --- a/src/Base/TimeInfo.cpp +++ b/src/Base/TimeInfo.cpp @@ -59,10 +59,10 @@ TimeInfo::~TimeInfo() = default; void TimeInfo::setCurrent() { #if defined(FC_OS_BSD) || defined(FC_OS_LINUX) || defined(__MINGW32__) - struct timeval t; - gettimeofday(&t, nullptr); - timebuffer.time = t.tv_sec; - timebuffer.millitm = t.tv_usec / 1000; + struct timeval tv; + gettimeofday(&tv, nullptr); + timebuffer.time = tv.tv_sec; + timebuffer.millitm = tv.tv_usec / 1000; #elif defined(FC_OS_WIN32) _ftime(&timebuffer); #else diff --git a/src/Base/Tools3D.cpp b/src/Base/Tools3D.cpp index eefc88f7be..3cf103e96a 100644 --- a/src/Base/Tools3D.cpp +++ b/src/Base/Tools3D.cpp @@ -160,9 +160,9 @@ size_t Polygon3::GetSize() const } template -void Polygon3::Add(const Vector3& p) +void Polygon3::Add(const Vector3& pnt) { - points.push_back(p); + points.push_back(pnt); } template diff --git a/src/Base/Tools3D.h b/src/Base/Tools3D.h index 13b8e1839b..5b8bd7f6c5 100644 --- a/src/Base/Tools3D.h +++ b/src/Base/Tools3D.h @@ -84,19 +84,19 @@ public: /*! * \brief Contains * Checks if the point \a p is part of the line segment. - * \param p + * \param pt * \return */ - bool Contains(const Vector3& p) const; + bool Contains(const Vector3& pt) const; /*! * \brief Contains * Checks if the distance of point \a p to the line segment is * less than \a eps - * \param p + * \param pt * \param eps * \return */ - bool Contains(const Vector3& p, float_type eps) const; + bool Contains(const Vector3& pt, float_type eps) const; Vector3 FromPos(float_type distance) const; }; @@ -118,7 +118,7 @@ public: Polygon3& operator=(Polygon3&& poly) = default; size_t GetSize() const; - void Add(const Vector3& p); + void Add(const Vector3& pnt); const Vector3& operator[](size_t pos) const; const Vector3& At(size_t pos) const; Vector3& operator[](size_t pos); diff --git a/src/Base/Translate.cpp b/src/Base/Translate.cpp index f900c0685b..de66aea3a2 100644 --- a/src/Base/Translate.cpp +++ b/src/Base/Translate.cpp @@ -85,12 +85,12 @@ Py::Object Translate::translate(const Py::Tuple& args) char* context = nullptr; char* source = nullptr; char* disambiguation = nullptr; - int n = -1; - if (!PyArg_ParseTuple(args.ptr(), "ss|zi", &context, &source, &disambiguation, &n)) { + int num = -1; + if (!PyArg_ParseTuple(args.ptr(), "ss|zi", &context, &source, &disambiguation, &num)) { throw Py::Exception(); } - QString str = QCoreApplication::translate(context, source, disambiguation, n); + QString str = QCoreApplication::translate(context, source, disambiguation, num); return Py::asObject(PyUnicode_FromString(str.toUtf8())); } diff --git a/src/Base/Type.cpp b/src/Base/Type.cpp index b5afda9055..d6bab97369 100644 --- a/src/Base/Type.cpp +++ b/src/Base/Type.cpp @@ -74,12 +74,12 @@ void* Type::createInstanceByName(const char* TypeName, bool bLoadModule) } // now the type should be in the type map - Type t = fromName(TypeName); - if (t == badType()) { + Type type = fromName(TypeName); + if (type == badType()) { return nullptr; } - return t.createInstance(); + return type.createInstance(); } void Type::importModule(const char* TypeName) diff --git a/src/Base/TypePyImp.cpp b/src/Base/TypePyImp.cpp index c957a5e281..3d4b6b397a 100644 --- a/src/Base/TypePyImp.cpp +++ b/src/Base/TypePyImp.cpp @@ -97,8 +97,8 @@ PyObject* TypePy::isBad(PyObject* args) return nullptr; } - bool v = getBaseTypePtr()->isBad(); - return PyBool_FromLong(v ? 1 : 0); + bool val = getBaseTypePtr()->isBad(); + return PyBool_FromLong(val ? 1 : 0); } PyObject* TypePy::isDerivedFrom(PyObject* args) @@ -113,9 +113,9 @@ PyObject* TypePy::isDerivedFrom(PyObject* args) } PyErr_Clear(); - PyObject* t {}; - if (PyArg_ParseTuple(args, "O!", &TypePy::Type, &t)) { - type = *static_cast(t)->getBaseTypePtr(); + PyObject* py {}; + if (PyArg_ParseTuple(args, "O!", &TypePy::Type, &py)) { + type = *static_cast(py)->getBaseTypePtr(); break; } @@ -123,8 +123,8 @@ PyObject* TypePy::isDerivedFrom(PyObject* args) return nullptr; } while (false); - bool v = (type != Base::Type::badType() && getBaseTypePtr()->isDerivedFrom(type)); - return PyBool_FromLong(v ? 1 : 0); + bool val = (type != Base::Type::badType() && getBaseTypePtr()->isDerivedFrom(type)); + return PyBool_FromLong(val ? 1 : 0); } PyObject* TypePy::getAllDerivedFrom(PyObject* args) @@ -139,9 +139,9 @@ PyObject* TypePy::getAllDerivedFrom(PyObject* args) } PyErr_Clear(); - PyObject* t {}; - if (PyArg_ParseTuple(args, "O!", &TypePy::Type, &t)) { - type = *static_cast(t)->getBaseTypePtr(); + PyObject* py {}; + if (PyArg_ParseTuple(args, "O!", &TypePy::Type, &py)) { + type = *static_cast(py)->getBaseTypePtr(); break; } diff --git a/src/Base/UnitsApiPy.cpp b/src/Base/UnitsApiPy.cpp index 99c41c426f..ab14bebada 100644 --- a/src/Base/UnitsApiPy.cpp +++ b/src/Base/UnitsApiPy.cpp @@ -158,14 +158,14 @@ PyObject* UnitsApi::sSetSchema(PyObject* /*self*/, PyObject* args) PyObject* UnitsApi::sSchemaTranslate(PyObject* /*self*/, PyObject* args) { - PyObject* q {}; + PyObject* py {}; int index {}; - if (!PyArg_ParseTuple(args, "O!i", &(QuantityPy::Type), &q, &index)) { + if (!PyArg_ParseTuple(args, "O!i", &(QuantityPy::Type), &py, &index)) { return nullptr; } Quantity quant; - quant = *static_cast(q)->getQuantityPtr(); + quant = *static_cast(py)->getQuantityPtr(); std::unique_ptr schema(createSchema(static_cast(index))); if (!schema.get()) { @@ -192,9 +192,9 @@ PyObject* UnitsApi::sToNumber(PyObject* /*self*/, PyObject* args) int decimals {}; do { - PyObject* q {}; - if (PyArg_ParseTuple(args, "O!|si", &(QuantityPy::Type), &q, &format, &decimals)) { - value = static_cast(q)->getQuantityPtr()->getValue(); + PyObject* py {}; + if (PyArg_ParseTuple(args, "O!|si", &(QuantityPy::Type), &py, &format, &decimals)) { + value = static_cast(py)->getQuantityPtr()->getValue(); break; } diff --git a/src/Base/ViewProj.cpp b/src/Base/ViewProj.cpp index ff71b5950b..defbe43455 100644 --- a/src/Base/ViewProj.cpp +++ b/src/Base/ViewProj.cpp @@ -120,11 +120,11 @@ void perspectiveTransform(const Base::Matrix4D& mat, Vec& pnt) double m31 = mat[3][1]; double m32 = mat[3][2]; double m33 = mat[3][3]; - double w = (static_cast(pnt.x) * m30 + static_cast(pnt.y) * m31 - + static_cast(pnt.z) * m32 + m33); + double ww = (static_cast(pnt.x) * m30 + static_cast(pnt.y) * m31 + + static_cast(pnt.z) * m32 + m33); mat.multVec(pnt, pnt); - pnt /= static_cast(w); + pnt /= static_cast(ww); } Vector3f ViewProjMatrix::operator()(const Vector3f& inp) const diff --git a/src/Base/Writer.cpp b/src/Base/Writer.cpp index 422b3ad6b9..b30926ab87 100644 --- a/src/Base/Writer.cpp +++ b/src/Base/Writer.cpp @@ -51,12 +51,12 @@ struct cdata_filter using category = boost::iostreams::output_filter_tag; template - inline bool put(Device& dev, char c) + inline bool put(Device& dev, char ch) { switch (state) { case 0: case 1: - if (c == ']') { + if (ch == ']') { ++state; } else { @@ -64,14 +64,14 @@ struct cdata_filter } break; case 2: - if (c == '>') { + if (ch == '>') { static const char escape[] = "]]>