diff --git a/src/Base/Builder3D.cpp b/src/Base/Builder3D.cpp index d840ecc7c2..bd461b60ee 100644 --- a/src/Base/Builder3D.cpp +++ b/src/Base/Builder3D.cpp @@ -313,8 +313,8 @@ void InventorFieldWriter::write(const char* fieldName, // ----------------------------------------------------------------------------- -LabelItem::LabelItem(const std::string& text) - : text(text) +LabelItem::LabelItem(std::string text) + : text(std::move(text)) {} void LabelItem::write(InventorOutput& out) const @@ -326,8 +326,8 @@ void LabelItem::write(InventorOutput& out) const // ----------------------------------------------------------------------------- -InfoItem::InfoItem(const std::string& text) - : text(text) +InfoItem::InfoItem(std::string text) + : text(std::move(text)) {} void InfoItem::write(InventorOutput& out) const @@ -403,10 +403,8 @@ void LineItem::write(InventorOutput& out) const // ----------------------------------------------------------------------------- -MultiLineItem::MultiLineItem(const std::vector& points, - DrawStyle drawStyle, - const ColorRGB& rgb) - : points {points} +MultiLineItem::MultiLineItem(std::vector points, DrawStyle drawStyle, const ColorRGB& rgb) + : points {std::move(points)} , drawStyle {drawStyle} , rgb {rgb} {} @@ -670,7 +668,6 @@ void ShapeHintsItem::setShapeType(ShapeType::Type value) shapeType.type = value; } - void ShapeHintsItem::write(InventorOutput& out) const { out.write() << "ShapeHints {\n"; @@ -699,8 +696,8 @@ void PolygonOffsetItem::write(InventorOutput& out) const // ----------------------------------------------------------------------------- -Coordinate3Item::Coordinate3Item(const std::vector& points) - : points(points) +Coordinate3Item::Coordinate3Item(std::vector points) + : points(std::move(points)) {} void Coordinate3Item::write(InventorOutput& out) const @@ -739,8 +736,8 @@ void LineSetItem::write(InventorOutput& out) const // ----------------------------------------------------------------------------- -FaceSetItem::FaceSetItem(const std::vector& indices) - : indices(indices) +FaceSetItem::FaceSetItem(std::vector indices) + : indices(std::move(indices)) {} void FaceSetItem::write(InventorOutput& out) const @@ -755,8 +752,8 @@ void FaceSetItem::write(InventorOutput& out) const // ----------------------------------------------------------------------------- -IndexedLineSetItem::IndexedLineSetItem(const std::vector& indices) - : indices(indices) +IndexedLineSetItem::IndexedLineSetItem(std::vector indices) + : indices(std::move(indices)) {} void IndexedLineSetItem::write(InventorOutput& out) const @@ -771,8 +768,8 @@ void IndexedLineSetItem::write(InventorOutput& out) const // ----------------------------------------------------------------------------- -IndexedFaceSetItem::IndexedFaceSetItem(const std::vector& indices) - : indices(indices) +IndexedFaceSetItem::IndexedFaceSetItem(std::vector indices) + : indices(std::move(indices)) {} void IndexedFaceSetItem::write(InventorOutput& out) const @@ -787,8 +784,8 @@ void IndexedFaceSetItem::write(InventorOutput& out) const // ----------------------------------------------------------------------------- -NormalItem::NormalItem(const std::vector& vec) - : vector(vec) +NormalItem::NormalItem(std::vector vec) + : vector(std::move(vec)) {} void NormalItem::write(InventorOutput& out) const @@ -903,8 +900,8 @@ void NurbsSurfaceItem::write(InventorOutput& out) const // ----------------------------------------------------------------------------- -Text2Item::Text2Item(const std::string& string) - : string(string) +Text2Item::Text2Item(std::string string) + : string(std::move(string)) {} void Text2Item::write(InventorOutput& out) const @@ -915,6 +912,7 @@ void Text2Item::write(InventorOutput& out) const // ----------------------------------------------------------------------------- +// NOLINTNEXTLINE TransformItem::TransformItem(const Base::Placement& placement) : placement(placement) {} diff --git a/src/Base/Builder3D.h b/src/Base/Builder3D.h index b01d816f4d..fd14e9188b 100644 --- a/src/Base/Builder3D.h +++ b/src/Base/Builder3D.h @@ -260,7 +260,7 @@ protected: class BaseExport LabelItem: public NodeItem { public: - explicit LabelItem(const std::string& text); + explicit LabelItem(std::string text); void write(InventorOutput& out) const override; private: @@ -273,7 +273,7 @@ private: class BaseExport InfoItem: public NodeItem { public: - explicit InfoItem(const std::string& text); + explicit InfoItem(std::string text); void write(InventorOutput& out) const override; private: @@ -326,7 +326,7 @@ class BaseExport MultiLineItem: public NodeItem public: /// add a line defined by a list of points whereat always a pair (i.e. a point and the following /// point) builds a line. - explicit MultiLineItem(const std::vector& points, + explicit MultiLineItem(std::vector points, DrawStyle drawStyle, const ColorRGB& rgb = ColorRGB {1.0F, 1.0F, 1.0F}); void write(InventorOutput& out) const override; @@ -466,7 +466,7 @@ private: class BaseExport Coordinate3Item: public NodeItem { public: - explicit Coordinate3Item(const std::vector& points); + explicit Coordinate3Item(std::vector points); void write(InventorOutput& out) const override; private: @@ -499,7 +499,7 @@ public: class BaseExport FaceSetItem: public NodeItem { public: - explicit FaceSetItem(const std::vector&); + explicit FaceSetItem(std::vector); void write(InventorOutput& out) const override; private: @@ -512,7 +512,7 @@ private: class BaseExport IndexedLineSetItem: public NodeItem { public: - explicit IndexedLineSetItem(const std::vector&); + explicit IndexedLineSetItem(std::vector); void write(InventorOutput& out) const override; private: @@ -525,7 +525,7 @@ private: class BaseExport IndexedFaceSetItem: public NodeItem { public: - explicit IndexedFaceSetItem(const std::vector&); + explicit IndexedFaceSetItem(std::vector); void write(InventorOutput& out) const override; private: @@ -538,7 +538,7 @@ private: class BaseExport NormalItem: public NodeItem { public: - explicit NormalItem(const std::vector& vec); + explicit NormalItem(std::vector vec); void write(InventorOutput& out) const override; private: @@ -627,7 +627,7 @@ private: class BaseExport Text2Item: public NodeItem { public: - explicit Text2Item(const std::string&); + explicit Text2Item(std::string); void write(InventorOutput& out) const override; private: diff --git a/src/Base/Exception.cpp b/src/Base/Exception.cpp index c2e419a73f..6de4007eec 100644 --- a/src/Base/Exception.cpp +++ b/src/Base/Exception.cpp @@ -38,12 +38,11 @@ TYPESYSTEM_SOURCE(Base::Exception, Base::BaseClass) Exception::Exception() - : _line(0) + : _sErrMsg("FreeCAD Exception") + , _line(0) , _isTranslatable(false) , _isReported(false) -{ - _sErrMsg = "FreeCAD Exception"; -} +{} Exception::Exception(const Exception& inst) = default; @@ -56,8 +55,8 @@ Exception::Exception(const char* sMessage) , _isReported(false) {} -Exception::Exception(const std::string& sMessage) - : _sErrMsg(sMessage) +Exception::Exception(std::string sMessage) + : _sErrMsg(std::move(sMessage)) , _line(0) , _isTranslatable(false) , _isReported(false) @@ -283,9 +282,8 @@ FileException::FileException(const char* sMessage, const FileInfo& File) FileException::FileException() : Exception("Unknown file exception happened") -{ - _sErrMsgAndFileName = _sErrMsg; -} + , _sErrMsgAndFileName(_sErrMsg) +{} void FileException::setFileName(const char* sFileName) { diff --git a/src/Base/Exception.h b/src/Base/Exception.h index 9bb33b3db3..77e9545f84 100644 --- a/src/Base/Exception.h +++ b/src/Base/Exception.h @@ -248,7 +248,7 @@ protected: * The preferred way of throwing an exception is using the macros above. * This way, the file, line, and function are automatically inserted. */ explicit Exception(const char* sMessage); - explicit Exception(const std::string& sMessage); + explicit Exception(std::string sMessage); Exception(); Exception(const Exception& inst); Exception(Exception&& inst) noexcept; diff --git a/src/Base/FutureWatcherProgress.cpp b/src/Base/FutureWatcherProgress.cpp index ab2de29e2e..8ffbfdcadd 100644 --- a/src/Base/FutureWatcherProgress.cpp +++ b/src/Base/FutureWatcherProgress.cpp @@ -30,7 +30,6 @@ using namespace Base; FutureWatcherProgress::FutureWatcherProgress(const char* text, unsigned int steps) : seq(text, 100) , steps(steps) - , current(0) {} FutureWatcherProgress::~FutureWatcherProgress() = default; diff --git a/src/Base/FutureWatcherProgress.h b/src/Base/FutureWatcherProgress.h index d585b511e5..d24180a5fe 100644 --- a/src/Base/FutureWatcherProgress.h +++ b/src/Base/FutureWatcherProgress.h @@ -49,7 +49,7 @@ public Q_SLOTS: private: Base::SequencerLauncher seq; - unsigned int steps, current; + unsigned int steps, current {0}; }; } // namespace Base diff --git a/src/Base/InputSource.cpp b/src/Base/InputSource.cpp index ca1ff34386..6946d56d9f 100644 --- a/src/Base/InputSource.cpp +++ b/src/Base/InputSource.cpp @@ -60,6 +60,7 @@ struct StdInputStream::TextCodec { QTextCodec* textCodec = QTextCodec::codecForName("UTF-8"); if (textCodec) { + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) const QString text = textCodec->toUnicode(reinterpret_cast(toFill), static_cast(len), &state); @@ -85,6 +86,7 @@ struct StdInputStream::TextCodec { void validateBytes(XMLByte* const toFill, std::streamsize len) { + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) QByteArray encodedString(reinterpret_cast(toFill), static_cast(len)); auto toUtf16 = QStringDecoder(QStringDecoder::Utf8); QString text = toUtf16(encodedString); @@ -133,7 +135,7 @@ XMLSize_t StdInputStream::readBytes(XMLByte* const toFill, const XMLSize_t maxTo // Read up to the maximum bytes requested. We return the number // actually read. // - + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) stream.read(reinterpret_cast(toFill), static_cast(maxToRead)); std::streamsize len = stream.gcount(); diff --git a/src/Base/Interpreter.h b/src/Base/Interpreter.h index e42305c8a2..1044807059 100644 --- a/src/Base/Interpreter.h +++ b/src/Base/Interpreter.h @@ -169,7 +169,7 @@ public: return _exitCode; } -protected: +private: long _exitCode; }; diff --git a/src/Base/Tools.cpp b/src/Base/Tools.cpp index a764c0c5e8..1f315ce721 100644 --- a/src/Base/Tools.cpp +++ b/src/Base/Tools.cpp @@ -76,8 +76,8 @@ struct string_comp class unique_name { public: - unique_name(const std::string& name, const std::vector& names, int padding) - : base_name {name} + unique_name(std::string name, const std::vector& names, int padding) + : base_name {std::move(name)} , padding {padding} { removeDigitsFromEnd(); diff --git a/src/Base/XMLTools.cpp b/src/Base/XMLTools.cpp index a9f780e407..930e4f7a41 100644 --- a/src/Base/XMLTools.cpp +++ b/src/Base/XMLTools.cpp @@ -28,7 +28,7 @@ using namespace Base; XERCES_CPP_NAMESPACE_USE -std::unique_ptr XMLTools::transcoder; +std::unique_ptr XMLTools::transcoder; // NOLINT void XMLTools::initialize() { @@ -40,7 +40,7 @@ void XMLTools::initialize() 4096, XMLPlatformUtils::fgMemoryManager)); if (res != XMLTransService::Ok) { - throw Base::UnicodeError("Can\'t create transcoder"); + throw Base::UnicodeError("Can't create transcoder"); } } } @@ -65,6 +65,7 @@ std::string XMLTools::toStdString(const XMLCh* const toTranscode) 128, eaten, XMLTranscoder::UnRep_RepChar); + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) str.append(reinterpret_cast(outBuff), outputLength); offset += eaten; inputLength -= eaten; @@ -88,6 +89,7 @@ std::basic_string XMLTools::toXMLString(const char* const fromTranscode) initialize(); static XMLCh outBuff[128]; + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) const XMLByte* xmlBytes = reinterpret_cast(fromTranscode); XMLSize_t outputLength = 0; XMLSize_t eaten = 0; diff --git a/src/Base/XMLTools.h b/src/Base/XMLTools.h index 7becb7e51a..caab71235a 100644 --- a/src/Base/XMLTools.h +++ b/src/Base/XMLTools.h @@ -78,10 +78,8 @@ inline std::ostream& operator<<(std::ostream& target, const StrX& toDump) } inline StrX::StrX(const XMLCh* const toTranscode) -{ - // Call the private transcoding method - fLocalForm = XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode(toTranscode); -} + : fLocalForm(XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode(toTranscode)) +{} inline StrX::~StrX() { @@ -158,9 +156,8 @@ private: inline XStr::XStr(const char* const toTranscode) -{ - fUnicodeForm = XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode(toTranscode); -} + : fUnicodeForm(XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode(toTranscode)) +{} inline XStr::~XStr() {