fix bugprone-*
* bugprone-throw-keyword-missing * bugprone-unhandled-self-assignment * bugprone-suspicious-string-compare * bugprone-reserved-identifier * bugprone-narrowing-conversions * bugprone-macro-parentheses * bugprone-implicit-widening-of-multiplication-result * bugprone-exception-escape * bugprone-copy-constructor-init
This commit is contained in:
@@ -152,7 +152,7 @@ CheckOptions:
|
||||
- key: google-readability-braces-around-statements.ShortStatementLines
|
||||
value: '1'
|
||||
- key: bugprone-reserved-identifier.AllowedIdentifiers
|
||||
value: ''
|
||||
value: '_object;_Precision'
|
||||
- key: cppcoreguidelines-pro-type-member-init.IgnoreArrays
|
||||
value: 'false'
|
||||
- key: readability-else-after-return.WarnOnUnfixable
|
||||
|
||||
@@ -341,6 +341,7 @@ using PyMethodDef = struct PyMethodDef;
|
||||
*
|
||||
*/
|
||||
|
||||
// NOLINTBEGIN(bugprone-reserved-identifier,bugprone-macro-parentheses,cppcoreguidelines-macro-usage)
|
||||
#define FC_LOGLEVEL_DEFAULT -1
|
||||
#define FC_LOGLEVEL_ERR 0
|
||||
#define FC_LOGLEVEL_WARN 1
|
||||
@@ -479,6 +480,7 @@ using PyMethodDef = struct PyMethodDef;
|
||||
} while (0)
|
||||
|
||||
#endif // FC_LOG_NO_TIMING
|
||||
// NOLINTEND(bugprone-reserved-identifier,bugprone-macro-parentheses,cppcoreguidelines-macro-usage)
|
||||
|
||||
// TODO: Get rid of this typedef
|
||||
using ConsoleMsgFlags = unsigned int;
|
||||
|
||||
@@ -132,15 +132,20 @@ ILoggerBlocker::ILoggerBlocker(const char* co, ConsoleMsgFlags msgTypes)
|
||||
|
||||
ILoggerBlocker::~ILoggerBlocker()
|
||||
{
|
||||
try {
|
||||
#ifdef FC_DEBUG
|
||||
auto debug = Console().SetEnabledMsgType(conObs, msgTypesBlocked, true);
|
||||
if (debug != msgTypesBlocked) {
|
||||
Console().Warning("Enabled message types have been changed while ILoggerBlocker was set\n");
|
||||
Console().Warning(
|
||||
"Enabled message types have been changed while ILoggerBlocker was set\n");
|
||||
}
|
||||
#else
|
||||
Console().SetEnabledMsgType(conObs, msgTypesBlocked, true);
|
||||
#endif
|
||||
}
|
||||
catch (...) {
|
||||
}
|
||||
}
|
||||
|
||||
class BaseExport RedirectStdOutput: public std::streambuf
|
||||
{
|
||||
|
||||
@@ -94,36 +94,36 @@ private:
|
||||
};
|
||||
|
||||
// type with three floats
|
||||
template<class _Vec, typename float_type>
|
||||
_Vec make_vec(const std::tuple<float_type, float_type, float_type>&& ft)
|
||||
template<class Vec, typename float_type>
|
||||
Vec make_vec(const std::tuple<float_type, float_type, float_type>&& ft)
|
||||
{
|
||||
using traits_type = vec_traits<_Vec>;
|
||||
using traits_type = vec_traits<Vec>;
|
||||
using float_traits_type = typename traits_type::float_type;
|
||||
return _Vec(float_traits_type(std::get<0>(ft)),
|
||||
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<class _Vec, typename float_type>
|
||||
_Vec make_vec(const std::tuple<float_type, float_type, float_type, float_type>&& ft)
|
||||
template<class Vec, typename float_type>
|
||||
Vec make_vec(const std::tuple<float_type, float_type, float_type, float_type>&& ft)
|
||||
{
|
||||
using traits_type = vec_traits<_Vec>;
|
||||
using traits_type = vec_traits<Vec>;
|
||||
using float_traits_type = typename traits_type::float_type;
|
||||
return _Vec(float_traits_type(std::get<0>(ft)),
|
||||
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<class _Vec1, class _Vec2>
|
||||
inline _Vec1 convertTo(const _Vec2& vec)
|
||||
template<class Vec1, class Vec2>
|
||||
inline Vec1 convertTo(const Vec2& vec)
|
||||
{
|
||||
using traits_type = vec_traits<_Vec2>;
|
||||
using traits_type = vec_traits<Vec2>;
|
||||
using float_type = typename traits_type::float_type;
|
||||
traits_type tt(vec);
|
||||
auto tuple = tt.get();
|
||||
return make_vec<_Vec1, float_type>(std::move(tuple));
|
||||
return make_vec<Vec1, float_type>(std::move(tuple));
|
||||
}
|
||||
|
||||
} // namespace Base
|
||||
|
||||
@@ -47,6 +47,7 @@ using PyObject = struct _object;
|
||||
/// have provided one) at that time it gets translated (e.g. in the UI before showing the message of
|
||||
/// the exception).
|
||||
|
||||
// NOLINTBEGIN
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#define THROW(exception) \
|
||||
@@ -185,6 +186,7 @@ using PyObject = struct _object;
|
||||
ss << _msg; \
|
||||
THROWM(_exception, ss.str().c_str()); \
|
||||
} while (0)
|
||||
// NOLINTEND
|
||||
|
||||
namespace Base
|
||||
{
|
||||
|
||||
@@ -33,7 +33,7 @@ ExceptionFactory* ExceptionFactory::_pcSingleton = nullptr; // NOLINT
|
||||
ExceptionFactory& ExceptionFactory::Instance()
|
||||
{
|
||||
if (!_pcSingleton) {
|
||||
_pcSingleton = new ExceptionFactory;
|
||||
_pcSingleton = new ExceptionFactory; // NOLINT
|
||||
}
|
||||
return *_pcSingleton;
|
||||
}
|
||||
|
||||
@@ -93,14 +93,14 @@ std::wstring ConvertToWideString(const std::string& string)
|
||||
// FileInfo
|
||||
|
||||
|
||||
FileInfo::FileInfo(const char* _FileName)
|
||||
FileInfo::FileInfo(const char* fileName)
|
||||
{
|
||||
setFile(_FileName);
|
||||
setFile(fileName);
|
||||
}
|
||||
|
||||
FileInfo::FileInfo(const std::string& _FileName)
|
||||
FileInfo::FileInfo(const std::string& fileName)
|
||||
{
|
||||
setFile(_FileName.c_str());
|
||||
setFile(fileName.c_str());
|
||||
}
|
||||
|
||||
const std::string& FileInfo::getTempPath()
|
||||
|
||||
@@ -59,8 +59,8 @@ public:
|
||||
};
|
||||
|
||||
/// Construction
|
||||
FileInfo(const char* _FileName = "");
|
||||
FileInfo(const std::string& _FileName);
|
||||
FileInfo(const char* fileName = "");
|
||||
FileInfo(const std::string& fileName);
|
||||
/// Set a new file name
|
||||
void setFile(const char* name);
|
||||
/// Set a new file name
|
||||
|
||||
@@ -152,7 +152,7 @@ public:
|
||||
}
|
||||
|
||||
Vector(const Vector& ob)
|
||||
: Object(*ob)
|
||||
: Object(ob)
|
||||
{
|
||||
validate();
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
#include "Exception.h"
|
||||
|
||||
|
||||
// NOLINTBEGIN
|
||||
/** Helper macro to obtain callable from an object
|
||||
*
|
||||
* @param _pyobj: PyObject pointer
|
||||
@@ -79,6 +80,7 @@
|
||||
if (PyObject_HasAttrString(_pyobj, _name)) \
|
||||
_var = Py::asObject(PyObject_GetAttrString(_pyobj, _name)); \
|
||||
} while (0)
|
||||
// NOLINTEND
|
||||
|
||||
|
||||
namespace Base
|
||||
|
||||
@@ -1026,9 +1026,9 @@ std::array<Matrix4D, 4> Matrix4D::decompose() const
|
||||
scaleMatrix.dMtrx4D[1][1] = yScale;
|
||||
scaleMatrix.dMtrx4D[2][2] = zScale;
|
||||
// The remaining shear
|
||||
residualMatrix.scale(xScale ? 1.0 / xScale : 1.0,
|
||||
yScale ? 1.0 / yScale : 1.0,
|
||||
zScale ? 1.0 / zScale : 1.0);
|
||||
residualMatrix.scale(xScale != 0 ? 1.0 / xScale : 1.0,
|
||||
yScale != 0 ? 1.0 / yScale : 1.0,
|
||||
zScale != 0 ? 1.0 / zScale : 1.0);
|
||||
// Restore trace in shear matrix
|
||||
residualMatrix.setDiagonal(Vector3d(1.0, 1.0, 1.0));
|
||||
// Remove values close to zero
|
||||
|
||||
@@ -320,6 +320,10 @@ inline Matrix4D Matrix4D::operator*(const Matrix4D& mat) const
|
||||
|
||||
inline Matrix4D& Matrix4D::operator=(const Matrix4D& mat)
|
||||
{
|
||||
if (this == &mat) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
for (int iz = 0; iz < 4; iz++) {
|
||||
for (int is = 0; is < 4; is++) {
|
||||
dMtrx4D[iz][is] = mat.dMtrx4D[iz][is];
|
||||
|
||||
@@ -46,7 +46,7 @@ class Subject;
|
||||
* Attach itself to the observed object.
|
||||
* @see FCSubject
|
||||
*/
|
||||
template<class _MessageType>
|
||||
template<class MsgType>
|
||||
class Observer
|
||||
{
|
||||
public:
|
||||
@@ -69,14 +69,14 @@ public:
|
||||
* @param rcReason
|
||||
* \todo undocumented parameter 2
|
||||
*/
|
||||
virtual void OnChange(Subject<_MessageType>& rCaller, _MessageType rcReason) = 0;
|
||||
virtual void OnChange(Subject<MsgType>& rCaller, MsgType rcReason) = 0;
|
||||
|
||||
/**
|
||||
* This method need to be reimplemented from the concrete Observer
|
||||
* and get called by the observed class
|
||||
* @param rCaller a reference to the calling object
|
||||
*/
|
||||
virtual void OnDestroy(Subject<_MessageType>& rCaller)
|
||||
virtual void OnDestroy(Subject<MsgType>& rCaller)
|
||||
{
|
||||
(void)rCaller;
|
||||
}
|
||||
@@ -99,13 +99,13 @@ public:
|
||||
* Attach itself to the observed object.
|
||||
* @see FCObserver
|
||||
*/
|
||||
template<class _MessageType>
|
||||
template<class MsgType>
|
||||
class Subject
|
||||
{
|
||||
public:
|
||||
using ObserverType = Observer<_MessageType>;
|
||||
using MessageType = _MessageType;
|
||||
using SubjectType = Subject<_MessageType>;
|
||||
using ObserverType = Observer<MsgType>;
|
||||
using MessageType = MsgType;
|
||||
using SubjectType = Subject<MsgType>;
|
||||
|
||||
/**
|
||||
* A constructor.
|
||||
@@ -131,7 +131,7 @@ public:
|
||||
* @param ToObserv A pointer to a concrete Observer
|
||||
* @see Notify
|
||||
*/
|
||||
void Attach(Observer<_MessageType>* ToObserv)
|
||||
void Attach(Observer<MsgType>* ToObserv)
|
||||
{
|
||||
#ifdef FC_DEBUG
|
||||
size_t count = _ObserverSet.size();
|
||||
@@ -152,7 +152,7 @@ public:
|
||||
* @param ToObserv A pointer to a concrete Observer
|
||||
* @see Notify
|
||||
*/
|
||||
void Detach(Observer<_MessageType>* ToObserv)
|
||||
void Detach(Observer<MsgType>* ToObserv)
|
||||
{
|
||||
#ifdef FC_DEBUG
|
||||
size_t count = _ObserverSet.size();
|
||||
@@ -173,9 +173,9 @@ public:
|
||||
* Oberserver and Subject.
|
||||
* @see Notify
|
||||
*/
|
||||
void Notify(_MessageType rcReason)
|
||||
void Notify(MsgType rcReason)
|
||||
{
|
||||
for (typename std::set<Observer<_MessageType>*>::iterator Iter = _ObserverSet.begin();
|
||||
for (typename std::set<Observer<MsgType>*>::iterator Iter = _ObserverSet.begin();
|
||||
Iter != _ObserverSet.end();
|
||||
++Iter) {
|
||||
try {
|
||||
@@ -202,10 +202,10 @@ public:
|
||||
* Get a observer by name if the observer reimplements the Name() mthode.
|
||||
* @see Observer
|
||||
*/
|
||||
Observer<_MessageType>* Get(const char* Name)
|
||||
Observer<MsgType>* Get(const char* Name)
|
||||
{
|
||||
const char* OName = nullptr;
|
||||
for (typename std::set<Observer<_MessageType>*>::iterator Iter = _ObserverSet.begin();
|
||||
for (typename std::set<Observer<MsgType>*>::iterator Iter = _ObserverSet.begin();
|
||||
Iter != _ObserverSet.end();
|
||||
++Iter) {
|
||||
OName = (*Iter)->Name(); // get the name
|
||||
@@ -228,7 +228,7 @@ public:
|
||||
|
||||
protected:
|
||||
/// Vector of attached observers
|
||||
std::set<Observer<_MessageType>*> _ObserverSet;
|
||||
std::set<Observer<MsgType>*> _ObserverSet;
|
||||
};
|
||||
|
||||
// Workaround for MSVC
|
||||
|
||||
@@ -754,7 +754,7 @@ std::vector<bool> ParameterGrp::GetBools(const char* sFilter) const
|
||||
Name = StrX(pcTemp->getAttribute(XStr("Name").unicodeForm())).c_str();
|
||||
// check on filter condition
|
||||
if (!sFilter || Name.find(sFilter) != std::string::npos) {
|
||||
if (strcmp(StrX(pcTemp->getAttribute(XStr("Value").unicodeForm())).c_str(), "1")) {
|
||||
if (strcmp(StrX(pcTemp->getAttribute(XStr("Value").unicodeForm())).c_str(), "1") != 0) {
|
||||
vrValues.push_back(false);
|
||||
}
|
||||
else {
|
||||
@@ -781,7 +781,7 @@ std::vector<std::pair<std::string, bool>> ParameterGrp::GetBoolMap(const char* s
|
||||
Name = StrX(pcTemp->getAttribute(XStr("Name").unicodeForm())).c_str();
|
||||
// check on filter condition
|
||||
if (!sFilter || Name.find(sFilter) != std::string::npos) {
|
||||
if (strcmp(StrX(pcTemp->getAttribute(XStr("Value").unicodeForm())).c_str(), "1")) {
|
||||
if (strcmp(StrX(pcTemp->getAttribute(XStr("Value").unicodeForm())).c_str(), "1") != 0) {
|
||||
vrValues.emplace_back(Name, false);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
* 3rd party Xerces-C++ XML parser is used to parse and write the XML.
|
||||
*/
|
||||
|
||||
#ifndef BASE__PARAMETER_H
|
||||
#define BASE__PARAMETER_H
|
||||
#ifndef BASE_PARAMETER_H
|
||||
#define BASE_PARAMETER_H
|
||||
|
||||
// Python stuff
|
||||
using PyObject = struct _object;
|
||||
@@ -454,4 +454,4 @@ private:
|
||||
BaseExport PyObject* GetPyObject(const Base::Reference<ParameterGrp>& hcParamGrp);
|
||||
|
||||
|
||||
#endif // BASE__PARAMETER_H
|
||||
#endif // BASE_PARAMETER_H
|
||||
|
||||
@@ -251,6 +251,7 @@ ParameterGrpPy::ParameterGrpPy(const Base::Reference<ParameterGrp>& rcParamGrp)
|
||||
|
||||
ParameterGrpPy::~ParameterGrpPy()
|
||||
{
|
||||
try {
|
||||
for (ParameterGrpObserver* obs : _observers) {
|
||||
if (!obs->_target) {
|
||||
_cParamGrp->Detach(obs);
|
||||
@@ -258,6 +259,9 @@ ParameterGrpPy::~ParameterGrpPy()
|
||||
delete obs;
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
}
|
||||
}
|
||||
|
||||
Py::Object ParameterGrpPy::repr()
|
||||
{
|
||||
|
||||
@@ -187,7 +187,7 @@ public:
|
||||
* \param R
|
||||
* \return
|
||||
*/
|
||||
static double IsInfinite(const double R)
|
||||
static bool IsInfinite(const double R)
|
||||
{
|
||||
return std::fabs(R) >= (0.5 * Precision::Infinite());
|
||||
}
|
||||
@@ -198,7 +198,7 @@ public:
|
||||
* \param R
|
||||
* \return
|
||||
*/
|
||||
static double IsPositiveInfinite(const double R)
|
||||
static bool IsPositiveInfinite(const double R)
|
||||
{
|
||||
return R >= (0.5 * Precision::Infinite());
|
||||
}
|
||||
|
||||
@@ -95,8 +95,12 @@ Rotation::Rotation(const Rotation& rot)
|
||||
this->_angle = rot._angle;
|
||||
}
|
||||
|
||||
void Rotation::operator=(const Rotation& rot)
|
||||
Rotation& Rotation::operator=(const Rotation& rot)
|
||||
{
|
||||
if (this == &rot) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
this->quat[0] = rot.quat[0];
|
||||
this->quat[1] = rot.quat[1];
|
||||
this->quat[2] = rot.quat[2];
|
||||
@@ -106,6 +110,8 @@ void Rotation::operator=(const Rotation& rot)
|
||||
this->_axis[1] = rot._axis[1];
|
||||
this->_axis[2] = rot._axis[2];
|
||||
this->_angle = rot._angle;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
const double* Rotation::getValue() const
|
||||
|
||||
@@ -141,7 +141,7 @@ public:
|
||||
{
|
||||
return quat[usIndex];
|
||||
}
|
||||
void operator=(const Rotation&);
|
||||
Rotation& operator=(const Rotation&);
|
||||
|
||||
Rotation& multRight(const Base::Rotation& q);
|
||||
Rotation& multLeft(const Base::Rotation& q);
|
||||
|
||||
@@ -674,7 +674,7 @@ PyObject* RotationPy::number_power_handler(PyObject* self, PyObject* other, PyOb
|
||||
double rfAngle {};
|
||||
|
||||
a.getRawValue(axis, rfAngle);
|
||||
rfAngle *= b;
|
||||
rfAngle *= double(b);
|
||||
a.setValue(axis, rfAngle);
|
||||
|
||||
return new RotationPy(a);
|
||||
|
||||
@@ -602,6 +602,7 @@ PyStreambuf::int_type PyStreambuf::underflow()
|
||||
return traits_type::eof();
|
||||
}
|
||||
|
||||
// Check: bugprone-not-null-terminated-result
|
||||
std::memcpy(start, c.data(), c.size());
|
||||
}
|
||||
catch (Py::Exception& e) {
|
||||
|
||||
@@ -258,18 +258,18 @@ BoundBox2d Polygon2d::CalcBoundBox() const
|
||||
return clBB;
|
||||
}
|
||||
|
||||
static short _CalcTorsion(const double* pfLine, double fX, double fY)
|
||||
static short CalcTorsion(const std::array<double, 4>& pfLine, double fX, double fY)
|
||||
{
|
||||
std::array<int, 2> sQuad;
|
||||
std::array<int, 2> sQuad {};
|
||||
double fResX = 0.0;
|
||||
|
||||
// Classification of both polygon points into quadrants
|
||||
for (int i = 0; i < 2; i++) {
|
||||
if (pfLine[i * 2] <= fX) {
|
||||
sQuad[i] = (pfLine[i * 2 + 1] > fY) ? 0 : 3;
|
||||
for (std::size_t i = 0; i < 2; i++) {
|
||||
if (pfLine.at(i * 2) <= fX) {
|
||||
sQuad[i] = (pfLine.at(i * 2 + 1) > fY) ? 0 : 3;
|
||||
}
|
||||
else {
|
||||
sQuad[i] = (pfLine[i * 2 + 1] > fY) ? 1 : 2;
|
||||
sQuad[i] = (pfLine.at(i * 2 + 1) > fY) ? 1 : 2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,7 +302,7 @@ bool Polygon2d::Contains(const Vector2d& rclV) const
|
||||
// Using the number of turns method, determines
|
||||
// whether a point is contained within a polygon.
|
||||
// The sum of all turns indicates whether yes or no.
|
||||
double pfTmp[4];
|
||||
std::array<double, 4> pfTmp;
|
||||
unsigned long i = 0;
|
||||
short sTorsion = 0;
|
||||
|
||||
@@ -330,7 +330,7 @@ bool Polygon2d::Contains(const Vector2d& rclV) const
|
||||
}
|
||||
|
||||
// Carry out a cut test and calculate the turn counter
|
||||
sTorsion += _CalcTorsion(pfTmp, rclV.x, rclV.y);
|
||||
sTorsion += CalcTorsion(pfTmp, rclV.x, rclV.y);
|
||||
}
|
||||
|
||||
// Evaluate turn counter
|
||||
|
||||
@@ -276,10 +276,10 @@ inline Vector3<_Precision> operator*(_Precision fFac, const Vector3<_Precision>&
|
||||
return Vector3<_Precision>(rcVct.x * fFac, rcVct.y * fFac, rcVct.z * fFac);
|
||||
}
|
||||
|
||||
template<class _Pr1, class _Pr2>
|
||||
inline Vector3<_Pr1> toVector(const Vector3<_Pr2>& v)
|
||||
template<class Pr1, class Pr2>
|
||||
inline Vector3<Pr1> toVector(const Vector3<Pr2>& v)
|
||||
{
|
||||
return Vector3<_Pr1>(static_cast<_Pr1>(v.x), static_cast<_Pr1>(v.y), static_cast<_Pr1>(v.z));
|
||||
return Vector3<Pr1>(static_cast<Pr1>(v.x), static_cast<Pr1>(v.y), static_cast<Pr1>(v.z));
|
||||
}
|
||||
|
||||
using Vector3f = Vector3<float>;
|
||||
|
||||
Reference in New Issue
Block a user