From 4e07172a6fc3dd330e5616f05e85ab976790e463 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 8 Aug 2022 15:25:14 +0300 Subject: [PATCH] Cppcheck warnings. --- scripts/cppcheck.sh | 17 ++- src/app/puzzle/layout/vppiece.h | 1 + src/app/puzzle/layout/vpsheet.h | 2 +- src/app/puzzle/scene/vpgraphicspiece.h | 1 + .../puzzle/scene/vpgraphicspiececontrols.cpp | 2 +- src/app/puzzle/scene/vpgraphicstilegrid.h | 1 + src/app/puzzle/undocommands/vpundocommand.h | 1 + src/app/puzzle/vpapplication.h | 1 + src/app/puzzle/vptilefactory.h | 1 + src/app/puzzle/xml/vplayoutfilereader.cpp | 1 + .../tape/dialogs/dialogdimensioncustomnames.h | 1 + .../tape/dialogs/dialogdimensionlabels.cpp | 2 - .../dialogs/dialogmeasurementscsvcolumns.cpp | 1 + .../tape/dialogs/dialogrestrictdimension.cpp | 1 + src/app/tape/dialogs/dialogsetupmultisize.h | 1 + src/app/tape/mapplication.h | 1 + src/app/valentina/core/vapplication.h | 1 + .../configpages/preferencespatternpage.cpp | 1 + .../dialogs/dialogaddbackgroundimage.h | 1 + src/app/valentina/dialogs/dialoghistory.cpp | 3 +- src/app/valentina/dialogs/dialogincrements.h | 1 + .../dialogs/vwidgetbackgroundimages.h | 1 + src/app/valentina/dialogs/vwidgetgroups.cpp | 1 + src/app/valentina/xml/vpattern.cpp | 1 + src/libs/ifc/ifcdef.cpp | 1 + src/libs/ifc/xml/vdomdocument.cpp | 4 - src/libs/qmuparser/qmuparserbase.cpp | 1 - src/libs/qmuparser/qmuparserbase.h | 1 + src/libs/qmuparser/qmuparserbytecode.cpp | 26 +++-- src/libs/qmuparser/qmuparsererror.h | 1 + src/libs/qmuparser/qmuparsertest.cpp | 2 - src/libs/qmuparser/qmuparsertest.h | 15 --- src/libs/vdxf/libdxfrw/drw_entities.cpp | 22 ++-- src/libs/vdxf/libdxfrw/drw_entities.h | 19 ++-- src/libs/vdxf/libdxfrw/drw_header.cpp | 100 ++++++++---------- src/libs/vdxf/libdxfrw/drw_header.h | 12 +-- src/libs/vdxf/libdxfrw/drw_objects.h | 3 +- .../vdxf/libdxfrw/intern/drw_textcodec.cpp | 8 +- src/libs/vdxf/libdxfrw/intern/drw_textcodec.h | 2 +- src/libs/vdxf/libdxfrw/intern/dxfreader.cpp | 3 + src/libs/vdxf/libdxfrw/libdxfrw.cpp | 1 + src/libs/vformat/vdimensions.h | 2 - src/libs/vgeometry/vabstractcubicbezier.h | 1 - src/libs/vgeometry/vplacelabelitem.cpp | 1 + .../vlayout/dialogs/dialoglayoutscale.cpp | 1 + .../vlayout/dialogs/vabstractlayoutdialog.cpp | 1 + src/libs/vlayout/vcontour_p.h | 1 + src/libs/vlayout/vposter.h | 1 - src/libs/vlayout/vrawsapoint.h | 3 - src/libs/vlayout/vsapoint.h | 1 - src/libs/vmisc/compatibility.h | 1 + src/libs/vmisc/def.h | 1 + src/libs/vmisc/projectversion.cpp | 1 + src/libs/vmisc/qxtcsvmodel.cpp | 3 - src/libs/vmisc/vabstractapplication.cpp | 3 - src/libs/vmisc/vlockguard.h | 1 - src/libs/vobj/delaunay.cpp | 3 + src/libs/vobj/predicates.cpp | 1 + src/libs/vobj/vobjengine.cpp | 6 +- .../floatItemData/vabstractfloatitemdata_p.h | 2 - .../floatItemData/vgrainlinedata_p.h | 4 +- .../floatItemData/vpatternlabeldata_p.h | 4 +- .../floatItemData/vpiecelabeldata_p.h | 3 - src/libs/vpatterndb/variables/varcradius.cpp | 1 + src/libs/vpatterndb/variables/varcradius_p.h | 4 +- src/libs/vpatterndb/variables/vcurveangle.cpp | 1 + .../vpatterndb/variables/vcurveclength.cpp | 1 + .../vpatterndb/variables/vcurvelength.cpp | 1 + .../vpatterndb/variables/vcurvevariable.cpp | 1 + .../vpatterndb/variables/vcurvevariable_p.h | 3 - .../variables/vinternalvariable_p.h | 2 - src/libs/vpatterndb/variables/vlineangle.cpp | 1 + src/libs/vpatterndb/variables/vlineangle_p.h | 4 +- src/libs/vpatterndb/variables/vlinelength.cpp | 1 + src/libs/vpatterndb/variables/vlinelength_p.h | 6 +- src/libs/vpatterndb/variables/vvariable_p.h | 2 - src/libs/vpatterndb/vtranslatevars.h | 1 + .../plugins/Vector3d/vvector3dproperty.cpp | 8 +- .../plugins/vfilepropertyeditor.cpp | 13 ++- src/libs/vpropertyexplorer/vproperty.cpp | 2 +- .../vpropertyexplorer/vpropertyformwidget.cpp | 6 +- src/libs/vpropertyexplorer/vpropertymodel_p.h | 10 +- src/libs/vpropertyexplorer/vpropertyset.cpp | 13 +-- .../vpropertyexplorer/vpropertytreeview.cpp | 6 +- .../vpropertyexplorer/vpropertytreeview.h | 2 +- src/libs/vtools/dialogs/dialogtoolbox.cpp | 1 + .../dialogs/support/dialogeditwrongformula.h | 1 + src/libs/vtools/dialogs/tools/dialogtool.h | 2 +- .../vbackgroundimagecontrols.h | 1 + .../backgroundimage/vbackgroundimageitem.h | 1 + src/libs/vtools/tools/nodeDetails/vnodearc.h | 2 +- .../tools/nodeDetails/vnodeellipticalarc.h | 2 +- .../vtools/tools/nodeDetails/vnodespline.h | 2 +- .../tools/nodeDetails/vnodesplinepath.h | 2 +- src/libs/vtools/tools/vabstracttool.h | 3 +- .../vtools/undocommands/addpatternpiece.cpp | 1 + .../undocommands/deletepatternpiece.cpp | 4 +- .../undocommands/image/addbackgroundimage.h | 1 + .../image/deletebackgroundimage.h | 1 + .../image/hideallbackgroundimages.h | 1 + .../undocommands/image/hidebackgroundimage.h | 1 + .../image/holdallbackgroundimages.h | 1 + .../undocommands/image/holdbackgroundimage.h | 1 + .../undocommands/image/movebackgroundimage.h | 1 + .../image/opaquebackgroundimage.h | 1 + .../image/renamebackgroundimage.h | 1 + .../undocommands/image/resetbackgroundimage.h | 1 + .../image/rotatebackgroundimage.h | 1 + .../undocommands/image/scalebackgroundimage.h | 1 + .../image/zvaluemovebackgroundimage.h | 1 + src/libs/vtools/undocommands/movespline.cpp | 6 +- src/libs/vtools/undocommands/movespoint.cpp | 6 +- .../vtools/visualization/line/visline.cpp | 2 +- src/libs/vtools/visualization/visualization.h | 1 + src/libs/vwidgets/fancytabbar/fancytabbar.h | 2 +- src/libs/vwidgets/qtcolorpicker.cpp | 26 +++-- src/libs/vwidgets/vabstractmainwindow.cpp | 1 - src/libs/vwidgets/vlineedit.h | 2 +- src/libs/vwidgets/vplaintextedit.h | 2 +- .../TranslationsTest/tst_buitinregexp.cpp | 12 +-- .../tst_measurementregexp.cpp | 1 + .../tst_qmuparsererrormsg.cpp | 3 +- .../tst_tslocaletranslation.cpp | 24 ++--- .../TranslationsTest/tst_tstranslation.cpp | 19 ++-- src/test/ValentinaTest/tst_readval.cpp | 8 +- src/test/ValentinaTest/tst_varc.cpp | 4 + src/test/ValentinaTest/tst_vcommandline.cpp | 1 + src/test/ValentinaTest/tst_vellipticalarc.cpp | 13 ++- src/test/ValentinaTest/tst_vlockguard.cpp | 1 + src/test/ValentinaTest/tst_vmeasurements.cpp | 2 + src/test/ValentinaTest/tst_vpointf.cpp | 1 + src/test/ValentinaTest/tst_vspline.cpp | 3 +- src/test/ValentinaTest/tst_vsplinepath.cpp | 2 + .../ValentinaTest/tst_vtooluniondetails.cpp | 1 + 134 files changed, 292 insertions(+), 286 deletions(-) diff --git a/scripts/cppcheck.sh b/scripts/cppcheck.sh index 47c85de83..7a3cda9c1 100755 --- a/scripts/cppcheck.sh +++ b/scripts/cppcheck.sh @@ -3,24 +3,19 @@ # Please, run this script from folder /scripts. # Because we use the last available cppcheck version usually we build it manually. -CPPCHECK="../../../../cppcheck/cppcheck" +CPPCHECK="../../../../cppcheck-2.8/cppcheck" $CPPCHECK \ -j4 -f -q \ -UDRW_DBG \ -U__INTEL_COMPILER_UPDATE \ - -UqApp \ --template '{file}:{line}:{message}:{id}' \ --inline-suppr \ --platform=unix64 \ - --std=c++11 \ - --std=posix \ + --std=c++17 \ --enable=all \ - --library=qt.cfg \ - --library=std.cfg \ - --library=posix.cfg \ + --library=qt \ + --library=std \ + --library=posix \ --inconclusive \ - --suppress=leakReturnValNotUsed:../src/app/valentina/core/vapplication.cpp \ - --suppress=unmatchedSuppression:../src/libs/ifc/xml/vdomdocument.cpp \ - --suppress=redundantCondition:../src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp \ - --suppress=unmatchedSuppression:../src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp \ + --suppress=*:*/vdxf/libdxfrw/intern/make_unique.h \ ../src diff --git a/src/app/puzzle/layout/vppiece.h b/src/app/puzzle/layout/vppiece.h index c1037bad8..9c6600d8e 100644 --- a/src/app/puzzle/layout/vppiece.h +++ b/src/app/puzzle/layout/vppiece.h @@ -132,6 +132,7 @@ public: void SetZValue(qreal newZValue); private: + // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VPPiece) // NOLINT VPLayoutWeakPtr m_layout{}; diff --git a/src/app/puzzle/layout/vpsheet.h b/src/app/puzzle/layout/vpsheet.h index d1ef8f332..c266990fb 100644 --- a/src/app/puzzle/layout/vpsheet.h +++ b/src/app/puzzle/layout/vpsheet.h @@ -51,7 +51,6 @@ class VPGraphicsTileGrid; class VPGraphicsSheet; class VLayoutPiece; -// cppcheck-suppress noCopyConstructor class VPSheetSceneData { public: @@ -95,6 +94,7 @@ public: void RefreshSheetSize(); private: + // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VPSheetSceneData) // NOLINT VPLayoutWeakPtr m_layout{}; diff --git a/src/app/puzzle/scene/vpgraphicspiece.h b/src/app/puzzle/scene/vpgraphicspiece.h index 952bf11f8..d217ef6ee 100644 --- a/src/app/puzzle/scene/vpgraphicspiece.h +++ b/src/app/puzzle/scene/vpgraphicspiece.h @@ -86,6 +86,7 @@ protected: void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override; private: + // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VPGraphicsPiece) // NOLINT VPPieceWeakPtr m_piece; diff --git a/src/app/puzzle/scene/vpgraphicspiececontrols.cpp b/src/app/puzzle/scene/vpgraphicspiececontrols.cpp index 2428f4d06..85cb973c6 100644 --- a/src/app/puzzle/scene/vpgraphicspiececontrols.cpp +++ b/src/app/puzzle/scene/vpgraphicspiececontrols.cpp @@ -45,7 +45,6 @@ #include "qgraphicsscene.h" #include "qgraphicsview.h" #include "qnamespace.h" -#include "vpgraphicspiece.h" namespace { @@ -73,6 +72,7 @@ auto TransformationOrigin(const VPLayoutPtr &layout, const QRectF &boundingRect) origin.origin = boundingRect.center(); origin.custom = false; + // cppcheck-suppress unknownMacro QT_WARNING_POP return origin; diff --git a/src/app/puzzle/scene/vpgraphicstilegrid.h b/src/app/puzzle/scene/vpgraphicstilegrid.h index 85a6b61b8..6aa0740a9 100644 --- a/src/app/puzzle/scene/vpgraphicstilegrid.h +++ b/src/app/puzzle/scene/vpgraphicstilegrid.h @@ -54,6 +54,7 @@ public: void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; private: + // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VPGraphicsTileGrid) // NOLINT VPLayoutWeakPtr m_layout; diff --git a/src/app/puzzle/undocommands/vpundocommand.h b/src/app/puzzle/undocommands/vpundocommand.h index 19c2dc917..fd97e833d 100644 --- a/src/app/puzzle/undocommands/vpundocommand.h +++ b/src/app/puzzle/undocommands/vpundocommand.h @@ -66,6 +66,7 @@ public: auto AllowMerge() const -> bool; private: + // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VPUndoCommand) // NOLINT bool m_allowMerge{false}; diff --git a/src/app/puzzle/vpapplication.h b/src/app/puzzle/vpapplication.h index bf50aa52c..47d6b0159 100644 --- a/src/app/puzzle/vpapplication.h +++ b/src/app/puzzle/vpapplication.h @@ -86,6 +86,7 @@ private slots: void NewLocalSocketConnection(); private: + // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VPApplication) //NOLINT QList > m_mainWindows{}; QLocalServer *m_localServer{nullptr}; diff --git a/src/app/puzzle/vptilefactory.h b/src/app/puzzle/vptilefactory.h index 0c9dd9de3..50b2f6f2d 100644 --- a/src/app/puzzle/vptilefactory.h +++ b/src/app/puzzle/vptilefactory.h @@ -105,6 +105,7 @@ public: const QString &watermarkPath, qreal xScale = 1.0, qreal yScale = 1.0); private: + // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VPTileFactory) // NOLINT VPLayoutWeakPtr m_layout; diff --git a/src/app/puzzle/xml/vplayoutfilereader.cpp b/src/app/puzzle/xml/vplayoutfilereader.cpp index 30572ab0a..7b650995f 100644 --- a/src/app/puzzle/xml/vplayoutfilereader.cpp +++ b/src/app/puzzle/xml/vplayoutfilereader.cpp @@ -713,6 +713,7 @@ auto VPLayoutFileReader::ReadMarker() -> VLayoutPlaceLabel marker.shape = shape; + // cppcheck-suppress unknownMacro QT_WARNING_POP return marker; diff --git a/src/app/tape/dialogs/dialogdimensioncustomnames.h b/src/app/tape/dialogs/dialogdimensioncustomnames.h index 9af71c537..53e2d38ba 100644 --- a/src/app/tape/dialogs/dialogdimensioncustomnames.h +++ b/src/app/tape/dialogs/dialogdimensioncustomnames.h @@ -53,6 +53,7 @@ public: auto CustomNames() const -> QMap; private: + // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(DialogDimensionCustomNames) // NOLINT Ui::DialogDimensionCustomNames *ui; diff --git a/src/app/tape/dialogs/dialogdimensionlabels.cpp b/src/app/tape/dialogs/dialogdimensionlabels.cpp index 5a5bcc8d9..02411b0b1 100644 --- a/src/app/tape/dialogs/dialogdimensionlabels.cpp +++ b/src/app/tape/dialogs/dialogdimensionlabels.cpp @@ -196,8 +196,6 @@ void DialogDimensionLabels::InitTable() //--------------------------------------------------------------------------------------------------------------------- auto DialogDimensionLabels::DimensionValue(const MeasurementDimension_p &dimension, qreal value) const -> QString { - QStringList labels; - if (dimension->Type() == MeasurementDimension::X) { return QString::number(value); diff --git a/src/app/tape/dialogs/dialogmeasurementscsvcolumns.cpp b/src/app/tape/dialogs/dialogmeasurementscsvcolumns.cpp index 66e4609e9..2e90ef0e4 100644 --- a/src/app/tape/dialogs/dialogmeasurementscsvcolumns.cpp +++ b/src/app/tape/dialogs/dialogmeasurementscsvcolumns.cpp @@ -807,6 +807,7 @@ void DialogMeasurementsCSVColumns::CheckStatus() auto SetStatus = [this](bool status) { QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok); + // cppcheck-suppress unknownMacro SCASSERT(bOk != nullptr) bOk->setEnabled(status); }; diff --git a/src/app/tape/dialogs/dialogrestrictdimension.cpp b/src/app/tape/dialogs/dialogrestrictdimension.cpp index 1b9f9e5a7..cfe7f89a6 100644 --- a/src/app/tape/dialogs/dialogrestrictdimension.cpp +++ b/src/app/tape/dialogs/dialogrestrictdimension.cpp @@ -128,6 +128,7 @@ void DialogRestrictDimension::changeEvent(QEvent *event) auto RetranslateControls = [this](int index, QLabel *name, QComboBox *control) { + // cppcheck-suppress unknownMacro SCASSERT(name != nullptr) SCASSERT(control != nullptr) diff --git a/src/app/tape/dialogs/dialogsetupmultisize.h b/src/app/tape/dialogs/dialogsetupmultisize.h index 6c1ff85db..908e9bdcf 100644 --- a/src/app/tape/dialogs/dialogsetupmultisize.h +++ b/src/app/tape/dialogs/dialogsetupmultisize.h @@ -70,6 +70,7 @@ private slots: void ZDimensionBodyMeasurementChanged(); private: + // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(DialogSetupMultisize) // NOLINT Ui::DialogSetupMultisize *ui; bool m_isInitialized{false}; diff --git a/src/app/tape/mapplication.h b/src/app/tape/mapplication.h index 37089b6f4..d07f31cfc 100644 --- a/src/app/tape/mapplication.h +++ b/src/app/tape/mapplication.h @@ -88,6 +88,7 @@ private slots: void NewLocalSocketConnection(); private: + // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(MApplication) // NOLINT QList > m_mainWindows{}; QLocalServer *m_localServer{nullptr}; diff --git a/src/app/valentina/core/vapplication.h b/src/app/valentina/core/vapplication.h index 6c338d04d..d262f7376 100644 --- a/src/app/valentina/core/vapplication.h +++ b/src/app/valentina/core/vapplication.h @@ -80,6 +80,7 @@ protected slots: void AboutToQuit() override; private: + // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VApplication) // NOLINT VTranslateVars *m_trVars{nullptr}; QTimer *m_autoSaveTimer{nullptr}; diff --git a/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp b/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp index 46aed8b0b..02e8cbc91 100644 --- a/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp +++ b/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp @@ -253,6 +253,7 @@ void PreferencesPatternPage::InitLabelDateTimeFormats() //--------------------------------------------------------------------------------------------------------------------- void PreferencesPatternPage::InitComboBoxFormats(QComboBox *box, const QStringList &items, const QString ¤tFormat) { + // cppcheck-suppress unknownMacro SCASSERT(box != nullptr) box->addItems(items); diff --git a/src/app/valentina/dialogs/dialogaddbackgroundimage.h b/src/app/valentina/dialogs/dialogaddbackgroundimage.h index 35cdaefc8..2b529927c 100644 --- a/src/app/valentina/dialogs/dialogaddbackgroundimage.h +++ b/src/app/valentina/dialogs/dialogaddbackgroundimage.h @@ -51,6 +51,7 @@ public: auto BuiltIn() const -> bool; private: + // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(DialogAddBackgroundImage) Ui::DialogAddBackgroundImage *ui; }; diff --git a/src/app/valentina/dialogs/dialoghistory.cpp b/src/app/valentina/dialogs/dialoghistory.cpp index 5a7abcd7c..0a376b2b2 100644 --- a/src/app/valentina/dialogs/dialoghistory.cpp +++ b/src/app/valentina/dialogs/dialoghistory.cpp @@ -34,12 +34,10 @@ #include "../vgeometry/vsplinepath.h" #include "../vgeometry/vcubicbezierpath.h" #include "../vgeometry/vpointf.h" -#include "../vtools/tools/vabstracttool.h" #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h" #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h" #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h" #include "../xml/vpattern.h" -#include "../vmisc/diagnostic.h" #include "../vmisc/vtablesearch.h" #include "../vmisc/vvalentinasettings.h" @@ -214,6 +212,7 @@ void DialogHistory::FillTable() { cursorRow = CursorRow(); QTableWidgetItem *item = ui->tableWidget->item(cursorRow, 0); + // cppcheck-suppress unknownMacro SCASSERT(item != nullptr) item->setIcon(QIcon("://icon/32x32/put_after.png")); } diff --git a/src/app/valentina/dialogs/dialogincrements.h b/src/app/valentina/dialogs/dialogincrements.h index 18c4b118a..47c4c4ee4 100644 --- a/src/app/valentina/dialogs/dialogincrements.h +++ b/src/app/valentina/dialogs/dialogincrements.h @@ -83,6 +83,7 @@ private slots: void RefreshPattern(); private: + // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(DialogIncrements) // NOLINT /** @brief ui keeps information about user interface */ diff --git a/src/app/valentina/dialogs/vwidgetbackgroundimages.h b/src/app/valentina/dialogs/vwidgetbackgroundimages.h index ae603d4d1..baac11960 100644 --- a/src/app/valentina/dialogs/vwidgetbackgroundimages.h +++ b/src/app/valentina/dialogs/vwidgetbackgroundimages.h @@ -82,6 +82,7 @@ private slots: void ImagePositionChanged(const QUuid &id); private: + // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VWidgetBackgroundImages) Ui::VWidgetBackgroundImages *ui; VAbstractPattern *m_doc; diff --git a/src/app/valentina/dialogs/vwidgetgroups.cpp b/src/app/valentina/dialogs/vwidgetgroups.cpp index 7fc596220..0c6017168 100644 --- a/src/app/valentina/dialogs/vwidgetgroups.cpp +++ b/src/app/valentina/dialogs/vwidgetgroups.cpp @@ -45,6 +45,7 @@ VWidgetGroups::VWidgetGroups(VAbstractPattern *doc, QWidget *parent) { ui->setupUi(this); + // cppcheck-suppress unknownMacro SCASSERT(doc != nullptr) FillTable(doc->GetGroups()); diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index b894e03d3..d6f5f9915 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -4519,6 +4519,7 @@ QRectF VPattern::ActiveDrawBoundingRect() const return rec; } +// cppcheck-suppress unknownMacro QT_WARNING_POP //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/ifc/ifcdef.cpp b/src/libs/ifc/ifcdef.cpp index 191d22326..c1d2b89ee 100644 --- a/src/libs/ifc/ifcdef.cpp +++ b/src/libs/ifc/ifcdef.cpp @@ -217,6 +217,7 @@ QString PenStyleToLineStyle(Qt::PenStyle penStyle) break; } + // cppcheck-suppress unknownMacro QT_WARNING_POP return TypeLineLine; diff --git a/src/libs/ifc/xml/vdomdocument.cpp b/src/libs/ifc/xml/vdomdocument.cpp index d3bb7cba6..1a8c4a48c 100644 --- a/src/libs/ifc/xml/vdomdocument.cpp +++ b/src/libs/ifc/xml/vdomdocument.cpp @@ -711,7 +711,6 @@ void VDomDocument::CacheRefreshed() void VDomDocument::setXMLContent(const QString &fileName) { QFile file(fileName); - // cppcheck-suppress ConfigurationNotChecked if (file.open(QIODevice::ReadOnly) == false) { const QString errorMsg(tr("Can't open file %1:\n%2.").arg(fileName, file.errorString())); @@ -766,7 +765,6 @@ bool VDomDocument::SaveDocument(const QString &fileName, QString &error) } bool success = false; QSaveFile file(fileName); - // cppcheck-suppress ConfigurationNotChecked if (file.open(QIODevice::WriteOnly)) { // See issue #666. QDomDocument produces random attribute order. @@ -1000,7 +998,6 @@ bool VDomDocument::SafeCopy(const QString &source, const QString &destination, Q QTemporaryFile destFile(destination + QLatin1String(".XXXXXX")); destFile.setAutoRemove(false);// Will be renamed to be destination file - // cppcheck-suppress ConfigurationNotChecked if (not destFile.open()) { error = destFile.errorString(); @@ -1008,7 +1005,6 @@ bool VDomDocument::SafeCopy(const QString &source, const QString &destination, Q else { QFile sourceFile(source); - // cppcheck-suppress ConfigurationNotChecked if (sourceFile.open(QIODevice::ReadOnly)) { result = true; diff --git a/src/libs/qmuparser/qmuparserbase.cpp b/src/libs/qmuparser/qmuparserbase.cpp index bc1d4c849..bc61fa601 100644 --- a/src/libs/qmuparser/qmuparserbase.cpp +++ b/src/libs/qmuparser/qmuparserbase.cpp @@ -1937,7 +1937,6 @@ void QmuParserBase::Eval(qreal *results, int nBulkSize) const #endif int nMaxThreads = qMin(omp_get_max_threads(), s_MaxNumOpenMPThreads); - // cppcheck-suppress unreadVariable int ct=0; omp_set_num_threads(nMaxThreads); diff --git a/src/libs/qmuparser/qmuparserbase.h b/src/libs/qmuparser/qmuparserbase.h index 2aeb40cba..42903db66 100644 --- a/src/libs/qmuparser/qmuparserbase.h +++ b/src/libs/qmuparser/qmuparserbase.h @@ -283,6 +283,7 @@ private: void StackDump(const QStack &a_stVal, const QStack &a_stOprt) const; }; +// cppcheck-suppress unknownMacro QT_WARNING_POP //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/qmuparser/qmuparserbytecode.cpp b/src/libs/qmuparser/qmuparserbytecode.cpp index b2253719a..328626a3e 100644 --- a/src/libs/qmuparser/qmuparserbytecode.cpp +++ b/src/libs/qmuparser/qmuparserbytecode.cpp @@ -102,7 +102,7 @@ void QmuParserByteCode::AddVar(qreal *a_pVar) m_iMaxStackSize = qMax(m_iMaxStackSize, m_iStackPos); // optimization does not apply - SToken tok; + SToken tok{}; tok.Cmd = cmVAR; tok.Val.ptr = a_pVar; tok.Val.data = 1; @@ -130,7 +130,7 @@ void QmuParserByteCode::AddVal(qreal a_fVal) m_iMaxStackSize = qMax(m_iMaxStackSize, m_iStackPos); // If optimization does not apply - SToken tok; + SToken tok{}; tok.Cmd = cmVAL; tok.Val.ptr = nullptr; tok.Val.data = 0; @@ -147,34 +147,42 @@ void QmuParserByteCode::ConstantFolding(ECmdCode a_Oprt) switch (a_Oprt) { case cmLAND: + // cppcheck-suppress assignBoolToFloat x = static_cast(x) && static_cast(y); m_vRPN.pop_back(); break; case cmLOR: + // cppcheck-suppress assignBoolToFloat x = static_cast(x) || static_cast(y); m_vRPN.pop_back(); break; case cmLT: + // cppcheck-suppress assignBoolToFloat x = x < y; m_vRPN.pop_back(); break; case cmGT: + // cppcheck-suppress assignBoolToFloat x = x > y; m_vRPN.pop_back(); break; case cmLE: + // cppcheck-suppress assignBoolToFloat x = x <= y; m_vRPN.pop_back(); break; case cmGE: + // cppcheck-suppress assignBoolToFloat x = x >= y; m_vRPN.pop_back(); break; case cmNEQ: + // cppcheck-suppress assignBoolToFloat x = not QmuFuzzyComparePossibleNulls(x, y); m_vRPN.pop_back(); break; case cmEQ: + // cppcheck-suppress assignBoolToFloat x = QmuFuzzyComparePossibleNulls(x, y); m_vRPN.pop_back(); break; @@ -367,7 +375,7 @@ void QmuParserByteCode::AddOp(ECmdCode a_Oprt) if (bOptimized == false) { --m_iStackPos; - SToken tok; + SToken tok{}; tok.Cmd = a_Oprt; m_vRPN.push_back(tok); } @@ -378,7 +386,7 @@ QT_WARNING_POP //--------------------------------------------------------------------------------------------------------------------- void QmuParserByteCode::AddIfElse(ECmdCode a_Oprt) { - SToken tok; + SToken tok{}; tok.Cmd = a_Oprt; m_vRPN.push_back(tok); } @@ -399,7 +407,7 @@ void QmuParserByteCode::AddAssignOp(qreal *a_pVar) { --m_iStackPos; - SToken tok; + SToken tok{}; tok.Cmd = cmASSIGN; tok.Oprt.ptr = a_pVar; m_vRPN.push_back(tok); @@ -425,7 +433,7 @@ void QmuParserByteCode::AddFun(generic_fun_type a_pFun, int a_iArgc) } m_iMaxStackSize = qMax(m_iMaxStackSize, m_iStackPos); - SToken tok; + SToken tok{}; tok.Cmd = cmFUNC; tok.Fun.argc = a_iArgc; tok.Fun.ptr = a_pFun; @@ -444,7 +452,7 @@ void QmuParserByteCode::AddBulkFun(generic_fun_type a_pFun, int a_iArgc) m_iStackPos = static_cast(static_cast(m_iStackPos) - a_iArgc + 1); m_iMaxStackSize = qMax(m_iMaxStackSize, m_iStackPos); - SToken tok; + SToken tok{}; tok.Cmd = cmFUNC_BULK; tok.Fun.argc = a_iArgc; tok.Fun.ptr = a_pFun; @@ -463,7 +471,7 @@ void QmuParserByteCode::AddStrFun(generic_fun_type a_pFun, int a_iArgc, int a_iI { m_iStackPos = static_cast(static_cast(m_iStackPos) - a_iArgc + 1); - SToken tok; + SToken tok{}; tok.Cmd = cmFUNC_STR; tok.Fun.argc = a_iArgc; tok.Fun.idx = a_iIdx; @@ -481,7 +489,7 @@ void QmuParserByteCode::AddStrFun(generic_fun_type a_pFun, int a_iArgc, int a_iI */ void QmuParserByteCode::Finalize() { - SToken tok; + SToken tok{}; tok.Cmd = cmEND; m_vRPN.push_back(tok); rpn_type(m_vRPN).swap(m_vRPN); // shrink bytecode vector to fit diff --git a/src/libs/qmuparser/qmuparsererror.h b/src/libs/qmuparser/qmuparsererror.h index 4fc6d35e9..2b4559690 100644 --- a/src/libs/qmuparser/qmuparsererror.h +++ b/src/libs/qmuparser/qmuparsererror.h @@ -135,6 +135,7 @@ public: explicit QmuParserWarning ( const QString &sMsg ); QmuParserWarning ( const QmuParserWarning &a_Obj ); QmuParserWarning& operator= ( const QmuParserWarning &a_Obj ); + // cppcheck-suppress unknownMacro virtual ~QmuParserWarning() QMUP_NOEXCEPT_EXPR (true) override {} const QString& GetMsg() const; diff --git a/src/libs/qmuparser/qmuparsertest.cpp b/src/libs/qmuparser/qmuparsertest.cpp index afa05001d..a090a5eb2 100644 --- a/src/libs/qmuparser/qmuparsertest.cpp +++ b/src/libs/qmuparser/qmuparsertest.cpp @@ -1239,7 +1239,6 @@ int QmuParserTester::EqnTestWithVarChange (const QString &a_str, double a_fRes1, var = a_fRes1; fVal[0] = p.Eval(); - // cppcheck-suppress redundantAssignment var = a_fRes2; //-V519 fVal[1] = p.Eval(); @@ -1281,7 +1280,6 @@ int QmuParserTester::EqnTestWithVarChange (const QString &a_str, double a_fRes1, int QmuParserTester::EqnTest ( const QString &a_str, double a_fRes, bool a_fPass ) { QmuParserTester::c_iCount++; - // cppcheck-suppress variableScope int iRet ( 0 ); qreal fVal[5] = { -999, -998, -997, -996, -995}; // initially should be different diff --git a/src/libs/qmuparser/qmuparsertest.h b/src/libs/qmuparser/qmuparsertest.h index 5041af96a..098fe1c06 100644 --- a/src/libs/qmuparser/qmuparsertest.h +++ b/src/libs/qmuparser/qmuparsertest.h @@ -242,7 +242,6 @@ private: return static_cast( ( 1 + ( v * QRandomGenerator().bounded(static_cast(RAND_MAX)) / ( RAND_MAX + 1.0 ) ) ) ); #else - // cppcheck-suppress qrandCalled return static_cast( ( 1 + ( v * qrand() / ( RAND_MAX + 1.0 ) ) ) ); #endif } @@ -253,7 +252,6 @@ private: return static_cast( ( 1 + ( 1000.0f * QRandomGenerator().bounded(static_cast(RAND_MAX)) / ( RAND_MAX + 1.0 ) ) ) ); #else - // cppcheck-suppress qrandCalled return static_cast( ( 1 + ( 1000.0f * static_cast(qrand()) / ( RAND_MAX + 1.0 ) ) ) ); #endif } @@ -312,31 +310,18 @@ private: static int IsHexVal (const QString &a_szExpr, int *a_iPos, qreal *a_fVal, const QLocale &locale, bool cNumbers, const QChar &decimal, const QChar &thousand); - // cppcheck-suppress functionStatic int TestNames(); - // cppcheck-suppress functionStatic int TestSyntax(); - // cppcheck-suppress functionStatic int TestMultiArg(); - // cppcheck-suppress functionStatic int TestPostFix(); - // cppcheck-suppress functionStatic int TestExpression(); - // cppcheck-suppress functionStatic int TestInfixOprt(); - // cppcheck-suppress functionStatic int TestBinOprt(); - // cppcheck-suppress functionStatic int TestVarConst(); - // cppcheck-suppress functionStatic int TestInterface(); - // cppcheck-suppress functionStatic int TestException(); - // cppcheck-suppress functionStatic int TestStrArg(); - // cppcheck-suppress functionStatic int TestIfThenElse(); - // cppcheck-suppress functionStatic int TestBulkMode(); static void Abort(); diff --git a/src/libs/vdxf/libdxfrw/drw_entities.cpp b/src/libs/vdxf/libdxfrw/drw_entities.cpp index 6aebcb27b..e63d2a700 100644 --- a/src/libs/vdxf/libdxfrw/drw_entities.cpp +++ b/src/libs/vdxf/libdxfrw/drw_entities.cpp @@ -157,38 +157,38 @@ bool DRW_Entity::parseCode(int code, dxfReader *reader){ //parses dxf 102 groups to read entity bool DRW_Entity::parseDxfGroups(int code, dxfReader *reader){ std::list ls; - DRW_Variant curr; + DRW_Variant c; int nc; std::string appName= reader->getString(); if (!appName.empty() && appName.at(0)== '{'){ - curr.addString(appName.substr(1, static_cast(appName.size()-1))); - curr.code = code; - ls.push_back(curr); + c.addString(appName.substr(1, static_cast(appName.size()-1))); + c.code = code; + ls.push_back(c); while (code !=102 && appName.at(0)== '}'){ reader->readRec(&nc); - curr.code = code; + c.code = code; if (code == 330 || code == 360) - curr.addInt(reader->getHandleString()); + c.addInt(reader->getHandleString()); else { switch (reader->type) { case dxfReader::STRING: - curr.addString(reader->getString()); + c.addString(reader->getString()); break; case dxfReader::INT32: case dxfReader::INT64: - curr.addInt(reader->getInt32()); + c.addInt(reader->getInt32()); break; case dxfReader::DOUBLE: - curr.addDouble(reader->getDouble()); + c.addDouble(reader->getDouble()); break; case dxfReader::BOOL: - curr.addInt(reader->getInt32()); + c.addInt(reader->getInt32()); break; default: break; } } - ls.push_back(curr); + ls.push_back(c); } } diff --git a/src/libs/vdxf/libdxfrw/drw_entities.h b/src/libs/vdxf/libdxfrw/drw_entities.h index 5b8cba949..814102830 100644 --- a/src/libs/vdxf/libdxfrw/drw_entities.h +++ b/src/libs/vdxf/libdxfrw/drw_entities.h @@ -263,7 +263,7 @@ public: } protected: - bool parseCode(int code, dxfReader *reader); + auto parseCode(int code, dxfReader *reader) -> bool override; public: double angle{0}; /*!< angle, code 50 */ @@ -946,11 +946,13 @@ public: fitpoint() { eType = DRW::SPLINE; - - for(double v : p.knotslist) knotslist.push_back(v); - for(double v : p.weightlist) weightlist.push_back(v); - for(DRW_Coord *v : p.controllist) controllist.push_back(new DRW_Coord(*v)); - for(DRW_Coord *v : p.fitlist) fitlist.push_back(new DRW_Coord(*v)); + + std::copy(p.knotslist.begin(), p.knotslist.end(), std::back_inserter(knotslist)); + std::copy(p.weightlist.begin(), p.weightlist.end(), std::back_inserter(weightlist)); + std::transform(p.controllist.cbegin(), p.controllist.cend(), std::back_inserter(controllist), + [](DRW_Coord *v) { return new DRW_Coord(*v); }); + std::transform(p.fitlist.cbegin(), p.fitlist.cend(), std::back_inserter(fitlist), + [](DRW_Coord *v) { return new DRW_Coord(*v); }); } ~DRW_Spline() { @@ -991,9 +993,7 @@ public: private: DRW_Spline &operator=(const DRW_Spline &) Q_DECL_EQ_DELETE; - // cppcheck-suppress unsafeClassCanLeak DRW_Coord *controlpoint; /*!< current control point to add data */ - // cppcheck-suppress unsafeClassCanLeak DRW_Coord *fitpoint; /*!< current fit point to add data */ }; @@ -1350,7 +1350,7 @@ public: } DRW_Coord getClonepoint() const {return getPt2();} /*!< Insertion for clones (Baseline & Continue), 12, 22 & 32 */ - void setClonePoint(DRW_Coord &c){setPt2(c);} + void setClonePoint(const DRW_Coord &c){setPt2(c);} DRW_Coord getDimPoint() const {return getDefPoint();} /*!< dim line location point, code 10, 20 & 30 */ void setDimPoint(const DRW_Coord &p){setDefPoint(p);} @@ -1584,7 +1584,6 @@ public: private: Q_DISABLE_COPY(DRW_Leader) - // cppcheck-suppress unsafeClassCanLeak DRW_Coord *vertexpoint; /*!< current control point to add data */ }; diff --git a/src/libs/vdxf/libdxfrw/drw_header.cpp b/src/libs/vdxf/libdxfrw/drw_header.cpp index e2bc28deb..73f65acba 100644 --- a/src/libs/vdxf/libdxfrw/drw_header.cpp +++ b/src/libs/vdxf/libdxfrw/drw_header.cpp @@ -597,10 +597,10 @@ void DRW_Header::write(dxfWriter *writer, DRW::Version ver){ writer->writeInt16(70, 3); writer->writeString(9, "$DIMTXSTY"); if (getStr("$DIMTXSTY", &varStr)) - if (ver == DRW::AC1009) - writer->writeUtf8Caps(7, varStr); - else - writer->writeUtf8String(7, varStr); +// if (ver == DRW::AC1009) +// writer->writeUtf8Caps(7, varStr); +// else + writer->writeUtf8String(7, varStr); else writer->writeString(7, "STANDARD"); writer->writeString(9, "$DIMAUNIT"); @@ -640,10 +640,10 @@ void DRW_Header::write(dxfWriter *writer, DRW::Version ver){ writer->writeInt16(70, 0); writer->writeString(9, "$DIMLDRBLK"); if (getStr("$DIMLDRBLK", &varStr)) - if (ver == DRW::AC1009) - writer->writeUtf8Caps(1, varStr); - else - writer->writeUtf8String(1, varStr); +// if (ver == DRW::AC1009) +// writer->writeUtf8Caps(1, varStr); +// else + writer->writeUtf8String(1, varStr); else writer->writeString(1, "STANDARD"); //verify if exist "$DIMLUNIT" or obsolete "$DIMUNIT" (pre v2000) @@ -710,26 +710,17 @@ void DRW_Header::write(dxfWriter *writer, DRW::Version ver){ writer->writeInt16(70, 0); writer->writeString(9, "$DIMLTYPE"); if (getStr("$DIMLTYPE", &varStr)) - if (ver == DRW::AC1009) - writer->writeUtf8Caps(6, varStr); - else - writer->writeUtf8String(6, varStr); + writer->writeUtf8String(6, varStr); else writer->writeString(6, ""); writer->writeString(9, "$DIMLTEX1"); if (getStr("$DIMLTEX1", &varStr)) - if (ver == DRW::AC1009) - writer->writeUtf8Caps(6, varStr); - else - writer->writeUtf8String(6, varStr); + writer->writeUtf8String(6, varStr); else writer->writeString(6, ""); writer->writeString(9, "$DIMLTEX2"); if (getStr("$DIMLTEX2", &varStr)) - if (ver == DRW::AC1009) - writer->writeUtf8Caps(6, varStr); - else - writer->writeUtf8String(6, varStr); + writer->writeUtf8String(6, varStr); else writer->writeString(6, ""); if (ver > DRW::AC1021) {// and post v2007 dim vars @@ -939,10 +930,7 @@ void DRW_Header::write(dxfWriter *writer, DRW::Version ver){ if (ver > DRW::AC1009) { writer->writeString(9, "$UCSBASE"); if (getStr("$UCSBASE", &varStr)) - if (ver == DRW::AC1009) - writer->writeUtf8Caps(2, varStr); - else - writer->writeUtf8String(2, varStr); + writer->writeUtf8String(2, varStr); else writer->writeString(2, ""); } @@ -987,10 +975,10 @@ void DRW_Header::write(dxfWriter *writer, DRW::Version ver){ if (ver > DRW::AC1009) { //begin post r12 UCS vars writer->writeString(9, "$UCSORTHOREF"); if (getStr("$UCSORTHOREF", &varStr)) - if (ver == DRW::AC1009) - writer->writeUtf8Caps(2, varStr); - else - writer->writeUtf8String(2, varStr); +// if (ver == DRW::AC1009) +// writer->writeUtf8Caps(2, varStr); +// else + writer->writeUtf8String(2, varStr); else writer->writeString(2, ""); writer->writeString(9, "$UCSORTHOVIEW"); @@ -1060,10 +1048,10 @@ void DRW_Header::write(dxfWriter *writer, DRW::Version ver){ } writer->writeString(9, "$PUCSBASE"); if (getStr("$PUCSBASE", &varStr)) - if (ver == DRW::AC1009) - writer->writeUtf8Caps(2, varStr); - else - writer->writeUtf8String(2, varStr); +// if (ver == DRW::AC1009) +// writer->writeUtf8Caps(2, varStr); +// else + writer->writeUtf8String(2, varStr); else writer->writeString(2, ""); } //end post r12 UCS vars @@ -1108,10 +1096,10 @@ void DRW_Header::write(dxfWriter *writer, DRW::Version ver){ if (ver > DRW::AC1009) { //begin post r12 PUCS vars writer->writeString(9, "$PUCSORTHOREF"); if (getStr("$PUCSORTHOREF", &varStr)) - if (ver == DRW::AC1009) - writer->writeUtf8Caps(2, varStr); - else - writer->writeUtf8String(2, varStr); +// if (ver == DRW::AC1009) +// writer->writeUtf8Caps(2, varStr); +// else + writer->writeUtf8String(2, varStr); else writer->writeString(2, ""); writer->writeString(9, "$PUCSORTHOVIEW"); @@ -1359,10 +1347,10 @@ void DRW_Header::write(dxfWriter *writer, DRW::Version ver){ writer->writeInt16(70, 3020); writer->writeString(9, "$CMLSTYLE"); if (getStr("$CMLSTYLE", &varStr)) - if (ver == DRW::AC1009) - writer->writeUtf8Caps(2, varStr); - else - writer->writeUtf8String(2, varStr); +// if (ver == DRW::AC1009) +// writer->writeUtf8Caps(2, varStr); +// else + writer->writeUtf8String(2, varStr); else writer->writeString(2, "Standard"); writer->writeString(9, "$CMLJUST"); @@ -1414,18 +1402,18 @@ void DRW_Header::write(dxfWriter *writer, DRW::Version ver){ } writer->writeString(9, "$HYPERLINKBASE"); if (getStr("$HYPERLINKBASE", &varStr)) - if (ver == DRW::AC1009) - writer->writeUtf8Caps(1, varStr); - else - writer->writeUtf8String(1, varStr); +// if (ver == DRW::AC1009) +// writer->writeUtf8Caps(1, varStr); +// else + writer->writeUtf8String(1, varStr); else writer->writeString(1, ""); writer->writeString(9, "$STYLESHEET"); if (getStr("$STYLESHEET", &varStr)) - if (ver == DRW::AC1009) - writer->writeUtf8Caps(1, varStr); - else - writer->writeUtf8String(1, varStr); +// if (ver == DRW::AC1009) +// writer->writeUtf8Caps(1, varStr); +// else + writer->writeUtf8String(1, varStr); else writer->writeString(1, ""); writer->writeString(9, "$XEDIT"); //RLZ bool flag, verify in bin version @@ -1678,7 +1666,6 @@ void DRW_Header::write(dxfWriter *writer, DRW::Version ver){ } void DRW_Header::addDouble(std::string key, double value, int code){ - // cppcheck-suppress publicAllocationError curr = new DRW_Variant(); curr->addDouble( value ); curr->code = code; @@ -1686,30 +1673,27 @@ void DRW_Header::addDouble(std::string key, double value, int code){ } void DRW_Header::addInt(std::string key, int value, int code){ - // cppcheck-suppress publicAllocationError curr = new DRW_Variant(); curr->addInt( value ); curr->code = code; vars[key] =curr; } -void DRW_Header::addStr(std::string key, std::string value, int code){ - // cppcheck-suppress publicAllocationError +void DRW_Header::addStr(std::string key, const std::string &value, int code){ curr = new DRW_Variant(); curr->addString( value ); curr->code = code; vars[key] =curr; } -void DRW_Header::addCoord(std::string key, DRW_Coord value, int code){ - // cppcheck-suppress publicAllocationError +void DRW_Header::addCoord(std::string key, const DRW_Coord &value, int code){ curr = new DRW_Variant(); curr->addCoord( value ); curr->code = code; vars[key] =curr; } -bool DRW_Header::getDouble(std::string key, double *varDouble){ +bool DRW_Header::getDouble(const std::string &key, double *varDouble){ bool result = false; auto it=vars.find( key); if (it != vars.end()) { @@ -1724,7 +1708,7 @@ bool DRW_Header::getDouble(std::string key, double *varDouble){ return result; } -bool DRW_Header::getInt(std::string key, int *varInt){ +bool DRW_Header::getInt(const std::string &key, int *varInt){ bool result = false; auto it=vars.find( key); if (it != vars.end()) { @@ -1739,7 +1723,7 @@ bool DRW_Header::getInt(std::string key, int *varInt){ return result; } -bool DRW_Header::getStr(std::string key, std::string *varStr){ +bool DRW_Header::getStr(const std::string &key, std::string *varStr){ bool result = false; auto it=vars.find( key); if (it != vars.end()) { @@ -1754,7 +1738,7 @@ bool DRW_Header::getStr(std::string key, std::string *varStr){ return result; } -bool DRW_Header::getCoord(std::string key, DRW_Coord *varCoord){ +bool DRW_Header::getCoord(const std::string &key, DRW_Coord *varCoord){ bool result = false; auto it=vars.find( key); if (it != vars.end()) { diff --git a/src/libs/vdxf/libdxfrw/drw_header.h b/src/libs/vdxf/libdxfrw/drw_header.h index 08440f465..34883a213 100644 --- a/src/libs/vdxf/libdxfrw/drw_header.h +++ b/src/libs/vdxf/libdxfrw/drw_header.h @@ -78,8 +78,8 @@ public: void addDouble(std::string key, double value, int code); void addInt(std::string key, int value, int code); - void addStr(std::string key, std::string value, int code); - void addCoord(std::string key, DRW_Coord value, int code); + void addStr(std::string key, const std::string &value, int code); + void addCoord(std::string key, const DRW_Coord &value, int code); std::string getComments() const {return comments;} void write(dxfWriter *writer, DRW::Version ver); void addComment(const std::string &c); @@ -87,10 +87,10 @@ public: protected: bool parseCode(int code, dxfReader *reader); private: - bool getDouble(std::string key, double *varDouble); - bool getInt(std::string key, int *varInt); - bool getStr(std::string key, std::string *varStr); - bool getCoord(std::string key, DRW_Coord *varCoord); + bool getDouble(const std::string &key, double *varDouble); + bool getInt(const std::string &key, int *varInt); + bool getStr(const std::string &key, std::string *varStr); + bool getCoord(const std::string &key, DRW_Coord *varCoord); void clearVars() { for (auto it=vars.begin(); it!=vars.end(); ++it) diff --git a/src/libs/vdxf/libdxfrw/drw_objects.h b/src/libs/vdxf/libdxfrw/drw_objects.h index 492d9f596..c908df6bc 100644 --- a/src/libs/vdxf/libdxfrw/drw_objects.h +++ b/src/libs/vdxf/libdxfrw/drw_objects.h @@ -113,7 +113,6 @@ public: private: DRW_TableEntry &operator=(const DRW_TableEntry &) Q_DECL_EQ_DELETE; - // cppcheck-suppress unsafeClassCanLeak DRW_Variant* curr{nullptr}; }; @@ -642,7 +641,7 @@ public: } protected: - bool parseCode(int code, dxfReader *reader){return DRW_TableEntry::parseCode(code, reader);} + bool parseCode(int code, dxfReader *reader) override {return DRW_TableEntry::parseCode(code, reader);} }; namespace DRW { diff --git a/src/libs/vdxf/libdxfrw/intern/drw_textcodec.cpp b/src/libs/vdxf/libdxfrw/intern/drw_textcodec.cpp index 72dbf92e0..a9fcc67c7 100644 --- a/src/libs/vdxf/libdxfrw/intern/drw_textcodec.cpp +++ b/src/libs/vdxf/libdxfrw/intern/drw_textcodec.cpp @@ -221,16 +221,16 @@ std::string DRW_TextCodec::fromUtf8(const std::string &s) { return std::string(encodedString.constData()); } -std::string DRW_TextCodec::correctCodePage(const std::string& s) { +auto DRW_TextCodec::correctCodePage(const std::string& s) -> std::string { //stringstream cause crash in OS/X, bug#3597944 - QString cp = QString::fromStdString(s); - cp = cp.toUpper(); + QString codePage = QString::fromStdString(s); + codePage = codePage.toUpper(); QMap codeMap = DRW_TextCodec::DXFCodePageMap(); auto i = codeMap.constBegin(); while (i != codeMap.constEnd()) { - if (i.value().contains(cp)) + if (i.value().contains(codePage)) { return i.key().toStdString(); } diff --git a/src/libs/vdxf/libdxfrw/intern/drw_textcodec.h b/src/libs/vdxf/libdxfrw/intern/drw_textcodec.h index 3f1fca855..f9ccf70b8 100644 --- a/src/libs/vdxf/libdxfrw/intern/drw_textcodec.h +++ b/src/libs/vdxf/libdxfrw/intern/drw_textcodec.h @@ -25,7 +25,7 @@ public: static QTextCodec* CodecForName(const QString &name); private: - std::string correctCodePage(const std::string& s); + static auto correctCodePage(const std::string& s) -> std::string; private: Q_DISABLE_COPY(DRW_TextCodec) diff --git a/src/libs/vdxf/libdxfrw/intern/dxfreader.cpp b/src/libs/vdxf/libdxfrw/intern/dxfreader.cpp index d4d99c914..b070e6977 100644 --- a/src/libs/vdxf/libdxfrw/intern/dxfreader.cpp +++ b/src/libs/vdxf/libdxfrw/intern/dxfreader.cpp @@ -170,6 +170,7 @@ bool dxfReaderBinary::readInt32() { filestr->read(buffer,4); int32p = reinterpret_cast(buffer); intData = static_cast(*int32p); + // cppcheck-suppress danglingLifetime DRW_DBG(intData); DRW_DBG("\n"); return (filestr->good()); } @@ -181,6 +182,7 @@ bool dxfReaderBinary::readInt64() { filestr->read(buffer,8); int64p = reinterpret_cast(buffer); int64 = *int64p; + // cppcheck-suppress danglingLifetime DRW_DBG(int64); DRW_DBG(" int64\n"); return (filestr->good()); } @@ -193,6 +195,7 @@ bool dxfReaderBinary::readDouble() { // cppcheck-suppress invalidPointerCast result = reinterpret_cast(buffer); doubleData = *result; + // cppcheck-suppress danglingLifetime DRW_DBG(doubleData); DRW_DBG("\n"); return (filestr->good()); } diff --git a/src/libs/vdxf/libdxfrw/libdxfrw.cpp b/src/libs/vdxf/libdxfrw/libdxfrw.cpp index d4b41c0b5..48cd65df0 100644 --- a/src/libs/vdxf/libdxfrw/libdxfrw.cpp +++ b/src/libs/vdxf/libdxfrw/libdxfrw.cpp @@ -2878,6 +2878,7 @@ bool dxfRW::processDimension() { break; } } + // cppcheck-suppress unknownMacro QT_WARNING_POP return true; //found new entity or ENDSEC, terminate diff --git a/src/libs/vformat/vdimensions.h b/src/libs/vformat/vdimensions.h index e7358a375..faf81f528 100644 --- a/src/libs/vformat/vdimensions.h +++ b/src/libs/vformat/vdimensions.h @@ -80,7 +80,6 @@ public: auto Error() const -> QString; - // cppcheck-suppress functionStatic auto Units() const -> Unit; auto IsBodyMeasurement() const -> bool; @@ -111,7 +110,6 @@ protected: auto IsRangeValid() -> bool; auto IsStepValid() -> bool; auto IsBaseValid() -> bool; - // cppcheck-suppress functionStatic auto IsUnitsValid() const -> bool; private: diff --git a/src/libs/vgeometry/vabstractcubicbezier.h b/src/libs/vgeometry/vabstractcubicbezier.h index 0cc49787e..100b1fd17 100644 --- a/src/libs/vgeometry/vabstractcubicbezier.h +++ b/src/libs/vgeometry/vabstractcubicbezier.h @@ -35,7 +35,6 @@ #include #include -#include "../ifc/ifcdef.h" #include "vabstractbezier.h" #include "vgeometrydef.h" diff --git a/src/libs/vgeometry/vplacelabelitem.cpp b/src/libs/vgeometry/vplacelabelitem.cpp index 1b57f2d92..edbd3591a 100644 --- a/src/libs/vgeometry/vplacelabelitem.cpp +++ b/src/libs/vgeometry/vplacelabelitem.cpp @@ -409,6 +409,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default") case PlaceLabelType::Circle: return CircleShape(); } +// cppcheck-suppress unknownMacro QT_WARNING_POP return PlaceLabelImg(); diff --git a/src/libs/vlayout/dialogs/dialoglayoutscale.cpp b/src/libs/vlayout/dialogs/dialoglayoutscale.cpp index 5fc1a67b4..bbdc22286 100644 --- a/src/libs/vlayout/dialogs/dialoglayoutscale.cpp +++ b/src/libs/vlayout/dialogs/dialoglayoutscale.cpp @@ -44,6 +44,7 @@ DialogLayoutScale::DialogLayoutScale(bool printTiled, QWidget *parent) VAbstractApplication::VApp()->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok); + // cppcheck-suppress unknownMacro SCASSERT(bOk != nullptr) connect(bOk, &QPushButton::clicked, this, &DialogLayoutScale::Save); diff --git a/src/libs/vlayout/dialogs/vabstractlayoutdialog.cpp b/src/libs/vlayout/dialogs/vabstractlayoutdialog.cpp index aa060591e..3e4232387 100644 --- a/src/libs/vlayout/dialogs/vabstractlayoutdialog.cpp +++ b/src/libs/vlayout/dialogs/vabstractlayoutdialog.cpp @@ -87,6 +87,7 @@ void VAbstractLayoutDialog::InitTemplates(QComboBox *comboBoxTemplates) //--------------------------------------------------------------------------------------------------------------------- void VAbstractLayoutDialog::InitTileTemplates(QComboBox *comboBoxTemplates, bool keepCustom) { + // cppcheck-suppress unknownMacro SCASSERT(comboBoxTemplates != nullptr) InitTemplates(comboBoxTemplates); diff --git a/src/libs/vlayout/vcontour_p.h b/src/libs/vlayout/vcontour_p.h index 2cb3ef19f..30c22596a 100644 --- a/src/libs/vlayout/vcontour_p.h +++ b/src/libs/vlayout/vcontour_p.h @@ -85,6 +85,7 @@ private: Q_DISABLE_ASSIGN(VContourData) }; +// cppcheck-suppress unknownMacro QT_WARNING_POP #endif // VCONTOUR_P_H diff --git a/src/libs/vlayout/vposter.h b/src/libs/vlayout/vposter.h index 056b5fb3b..b4e562f31 100644 --- a/src/libs/vlayout/vposter.h +++ b/src/libs/vlayout/vposter.h @@ -61,7 +61,6 @@ struct PosterData Q_DECLARE_TYPEINFO(PosterData, Q_MOVABLE_TYPE); -// cppcheck-suppress noConstructor class VPoster { Q_DECLARE_TR_FUNCTIONS(VPoster) diff --git a/src/libs/vlayout/vrawsapoint.h b/src/libs/vlayout/vrawsapoint.h index fbd5dd6d7..785e6c489 100644 --- a/src/libs/vlayout/vrawsapoint.h +++ b/src/libs/vlayout/vrawsapoint.h @@ -42,7 +42,6 @@ class VRawSAPoint : public QPointF public: Q_DECL_CONSTEXPR VRawSAPoint(); Q_DECL_CONSTEXPR VRawSAPoint(qreal xpos, qreal ypos); - // cppcheck-suppress noExplicitConstructor Q_DECL_CONSTEXPR VRawSAPoint(QPointF p); Q_DECL_CONSTEXPR VRawSAPoint(QPointF p, bool loopPoint); @@ -68,13 +67,11 @@ Q_DECL_CONSTEXPR inline VRawSAPoint::VRawSAPoint(qreal xpos, qreal ypos) {} //--------------------------------------------------------------------------------------------------------------------- -// cppcheck-suppress passedByValue Q_DECL_CONSTEXPR inline VRawSAPoint::VRawSAPoint(QPointF p) : QPointF(p) {} //--------------------------------------------------------------------------------------------------------------------- -// cppcheck-suppress passedByValue Q_DECL_CONSTEXPR inline VRawSAPoint::VRawSAPoint(QPointF p, bool loopPoint) : QPointF(p), m_loopPoint(loopPoint) diff --git a/src/libs/vlayout/vsapoint.h b/src/libs/vlayout/vsapoint.h index 5207b725f..3bdc06b36 100644 --- a/src/libs/vlayout/vsapoint.h +++ b/src/libs/vlayout/vsapoint.h @@ -95,7 +95,6 @@ Q_DECL_CONSTEXPR inline VSAPoint::VSAPoint(qreal xpos, qreal ypos) {} //--------------------------------------------------------------------------------------------------------------------- -// cppcheck-suppress passedByValue Q_DECL_CONSTEXPR inline VSAPoint::VSAPoint(QPointF p) : QPointF(p) {} diff --git a/src/libs/vmisc/compatibility.h b/src/libs/vmisc/compatibility.h index c02ce9d01..82efbdb58 100644 --- a/src/libs/vmisc/compatibility.h +++ b/src/libs/vmisc/compatibility.h @@ -165,6 +165,7 @@ template inline void Move(T &vector, int from, int to) { QT_WARNING_PUSH + // cppcheck-suppress unknownMacro QT_WARNING_DISABLE_GCC("-Wstrict-overflow") #if QT_VERSION < QT_VERSION_CHECK(5, 6, 0) diff --git a/src/libs/vmisc/def.h b/src/libs/vmisc/def.h index 2b80a7ef3..c7b9850be 100644 --- a/src/libs/vmisc/def.h +++ b/src/libs/vmisc/def.h @@ -615,6 +615,7 @@ private: PUB* qxt_p_ptr; }; +// cppcheck-suppress unknownMacro QT_WARNING_POP template diff --git a/src/libs/vmisc/projectversion.cpp b/src/libs/vmisc/projectversion.cpp index 4d07ed0e7..2c051979b 100644 --- a/src/libs/vmisc/projectversion.cpp +++ b/src/libs/vmisc/projectversion.cpp @@ -76,6 +76,7 @@ QString compilerString() QLatin1String(" compatibility]"); #endif #elif defined(Q_CC_CLANG) // must be before GNU, because clang claims to be GNU too + // cppcheck-suppress unassignedVariable QString isAppleString; #if defined(__apple_build_version__) // Apple clang has other version numbers isAppleString = QLatin1String(" (Apple)"); diff --git a/src/libs/vmisc/qxtcsvmodel.cpp b/src/libs/vmisc/qxtcsvmodel.cpp index 99cc6aaa6..4679ddb0e 100644 --- a/src/libs/vmisc/qxtcsvmodel.cpp +++ b/src/libs/vmisc/qxtcsvmodel.cpp @@ -584,7 +584,6 @@ static QString qxt_addCsvQuotes(QxtCsvModel::QuoteMode mode, QString field) Fields in the output file will be separated by \a separator. Set \a withHeader to true to output a row of headers at the top of the file. */ -// cppcheck-suppress funcArgNamesDifferent bool QxtCsvModel::toCSV(QIODevice* dest, QString &error, bool withHeader, QChar separator, QTextCodec* codec) const { const QxtCsvModelPrivate& d_ptr = qxt_d(); @@ -707,7 +706,6 @@ void QxtCsvModel::setQuoteMode(QuoteMode mode) */ void QxtCsvModel::setText(int row, int column, const QString& value) { -// cppcheck-suppress indexCalled setData(index(row, column), value); } @@ -718,7 +716,6 @@ void QxtCsvModel::setText(int row, int column, const QString& value) */ QString QxtCsvModel::text(int row, int column) const { -// cppcheck-suppress indexCalled return data(index(row, column)).toString(); } diff --git a/src/libs/vmisc/vabstractapplication.cpp b/src/libs/vmisc/vabstractapplication.cpp index 7e89b5bbe..96227fb1c 100644 --- a/src/libs/vmisc/vabstractapplication.cpp +++ b/src/libs/vmisc/vabstractapplication.cpp @@ -120,7 +120,6 @@ VAbstractApplication::VAbstractApplication(int &argc, char **argv) rules += QLatin1String("kf5.kio.core*=false\n"); #endif - // cppcheck-suppress reademptycontainer if (not rules.isEmpty()) { QLoggingCategory::setFilterRules(rules); @@ -232,9 +231,7 @@ void VAbstractApplication::WinAttachConsole() auto stdout_type = GetFileType(GetStdHandle(STD_OUTPUT_HANDLE)); if (stdout_type == FILE_TYPE_UNKNOWN && AttachConsole(ATTACH_PARENT_PROCESS)) { - // cppcheck-suppress ignoredReturnValue freopen("CONOUT$", "w", stdout); - // cppcheck-suppress ignoredReturnValue freopen("CONOUT$", "w", stderr); } } diff --git a/src/libs/vmisc/vlockguard.h b/src/libs/vmisc/vlockguard.h index 702ed07b8..be89ffb8c 100644 --- a/src/libs/vmisc/vlockguard.h +++ b/src/libs/vmisc/vlockguard.h @@ -77,7 +77,6 @@ private: QString lockFile; QSharedPointer lock; - // cppcheck-suppress functionStatic bool TryLock(const QString &lockName, int stale, int timeout); }; diff --git a/src/libs/vobj/delaunay.cpp b/src/libs/vobj/delaunay.cpp index c34f27a18..58dce2838 100644 --- a/src/libs/vobj/delaunay.cpp +++ b/src/libs/vobj/delaunay.cpp @@ -28,6 +28,7 @@ QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wold-style-cast") +// cppcheck-suppress unknownMacro QT_WARNING_DISABLE_CLANG("-Wold-style-cast") QT_WARNING_DISABLE_GCC("-Wcast-qual") QT_WARNING_DISABLE_CLANG("-Wcast-qual") @@ -792,11 +793,13 @@ static halfedge_t* del_valid_link( halfedge_t *b ) { if( a == INSIDE ) { + // cppcheck-suppress unreadVariable g_p = g; gd = b; } else { + // cppcheck-suppress unreadVariable d_p = d; dd = b->pair; } diff --git a/src/libs/vobj/predicates.cpp b/src/libs/vobj/predicates.cpp index 54ddcb16e..c6e331c54 100644 --- a/src/libs/vobj/predicates.cpp +++ b/src/libs/vobj/predicates.cpp @@ -111,6 +111,7 @@ QT_WARNING_PUSH QT_WARNING_DISABLE_MSVC(4701) +// cppcheck-suppress unknownMacro QT_WARNING_DISABLE_GCC("-Wold-style-cast") QT_WARNING_DISABLE_GCC("-Wfloat-equal") #if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 diff --git a/src/libs/vobj/vobjengine.cpp b/src/libs/vobj/vobjengine.cpp index 90ca1c522..7db881be4 100644 --- a/src/libs/vobj/vobjengine.cpp +++ b/src/libs/vobj/vobjengine.cpp @@ -60,6 +60,7 @@ static inline QPaintEngine::PaintEngineFeatures svgEngineFeatures() { QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wsign-conversion") +// cppcheck-suppress unknownMacro QT_WARNING_DISABLE_INTEL(68) QT_WARNING_DISABLE_INTEL(2022) @@ -194,6 +195,7 @@ void VObjEngine::drawPath(const QPainterPath &path) delaunay2d_t *res = delaunay2d_from(points, num_points);//Calculate faces QPointF pf[MAX_POINTS]; + // cppcheck-suppress unreadVariable bool skipFace=false;//Need skip first face for (quint32 i = 0; i < res->num_faces; i++ ) @@ -216,9 +218,9 @@ void VObjEngine::drawPath(const QPainterPath &path) if (skipFace == false ) { QPolygonF face; - for ( int i = 0; i < num_verts; i++ ) + for ( int ind = 0; ind < num_verts; ind++ ) { - face << QPointF(pf[i]); + face << QPointF(pf[ind]); } QPolygonF united = polygon.united(face); qint64 sqUnited = Square(united); diff --git a/src/libs/vpatterndb/floatItemData/vabstractfloatitemdata_p.h b/src/libs/vpatterndb/floatItemData/vabstractfloatitemdata_p.h index e0f30e871..f42cc0e55 100644 --- a/src/libs/vpatterndb/floatItemData/vabstractfloatitemdata_p.h +++ b/src/libs/vpatterndb/floatItemData/vabstractfloatitemdata_p.h @@ -32,14 +32,12 @@ #include #include -#include "../vmisc/diagnostic.h" #include "../vmisc/defglobal.h" QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Weffc++") QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor") -// cppcheck-suppress copyCtorAndEqOperator class VAbstractFloatItemDataPrivate : public QSharedData { public: diff --git a/src/libs/vpatterndb/floatItemData/vgrainlinedata_p.h b/src/libs/vpatterndb/floatItemData/vgrainlinedata_p.h index 5ede782e6..b084663a2 100644 --- a/src/libs/vpatterndb/floatItemData/vgrainlinedata_p.h +++ b/src/libs/vpatterndb/floatItemData/vgrainlinedata_p.h @@ -32,16 +32,14 @@ #include #include -#include "../vmisc/diagnostic.h" #include "../vmisc/defglobal.h" +#include "../vmisc/typedef.h" #include "floatitemdef.h" -#include "../ifc/ifcdef.h" QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Weffc++") QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor") -// cppcheck-suppress copyCtorAndEqOperator class VGrainlineDataPrivate : public QSharedData { public: diff --git a/src/libs/vpatterndb/floatItemData/vpatternlabeldata_p.h b/src/libs/vpatterndb/floatItemData/vpatternlabeldata_p.h index 7cd91027b..c0879d754 100644 --- a/src/libs/vpatterndb/floatItemData/vpatternlabeldata_p.h +++ b/src/libs/vpatterndb/floatItemData/vpatternlabeldata_p.h @@ -32,15 +32,13 @@ #include #include -#include "../vmisc/diagnostic.h" +#include "../vmisc/typedef.h" #include "../vmisc/defglobal.h" -#include "../ifc/ifcdef.h" QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Weffc++") QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor") -// cppcheck-suppress copyCtorAndEqOperator class VPatternLabelDataPrivate : public QSharedData { public: diff --git a/src/libs/vpatterndb/floatItemData/vpiecelabeldata_p.h b/src/libs/vpatterndb/floatItemData/vpiecelabeldata_p.h index 215869d95..31b9910fe 100644 --- a/src/libs/vpatterndb/floatItemData/vpiecelabeldata_p.h +++ b/src/libs/vpatterndb/floatItemData/vpiecelabeldata_p.h @@ -33,16 +33,13 @@ #include #include -#include "../vmisc/diagnostic.h" #include "../vmisc/defglobal.h" -#include "floatitemdef.h" #include "../ifc/ifcdef.h" QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Weffc++") QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor") -// cppcheck-suppress copyCtorAndEqOperator class VPieceLabelDataPrivate : public QSharedData { public: diff --git a/src/libs/vpatterndb/variables/varcradius.cpp b/src/libs/vpatterndb/variables/varcradius.cpp index fbfdc2d56..e9988ff91 100644 --- a/src/libs/vpatterndb/variables/varcradius.cpp +++ b/src/libs/vpatterndb/variables/varcradius.cpp @@ -46,6 +46,7 @@ VArcRadius::VArcRadius() VArcRadius::VArcRadius(const quint32 &id, const quint32 &parentId, const VArc *arc, Unit patternUnit) :VCurveVariable(id, parentId) { + // cppcheck-suppress unknownMacro SCASSERT(arc != nullptr) SetType(VarType::ArcRadius); diff --git a/src/libs/vpatterndb/variables/varcradius_p.h b/src/libs/vpatterndb/variables/varcradius_p.h index 99bfde3a9..c06c2fce4 100644 --- a/src/libs/vpatterndb/variables/varcradius_p.h +++ b/src/libs/vpatterndb/variables/varcradius_p.h @@ -31,8 +31,8 @@ #include -#include "../vmisc/diagnostic.h" #include "../vmisc/defglobal.h" +#include "../vmisc/typedef.h" QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Weffc++") @@ -46,7 +46,7 @@ public: :arcId(NULL_ID) {} - VArcRadiusData(const quint32 &arcId) + explicit VArcRadiusData(const quint32 &arcId) :arcId(arcId) {} diff --git a/src/libs/vpatterndb/variables/vcurveangle.cpp b/src/libs/vpatterndb/variables/vcurveangle.cpp index df07d6d29..104f30d6b 100644 --- a/src/libs/vpatterndb/variables/vcurveangle.cpp +++ b/src/libs/vpatterndb/variables/vcurveangle.cpp @@ -85,6 +85,7 @@ VCurveAngle::VCurveAngle(const quint32 &id, const quint32 &parentId, const VAbst const VSpline &spl, CurveAngle angle, qint32 segment) :VCurveVariable(id, parentId) { + // cppcheck-suppress unknownMacro SCASSERT(baseCurve != nullptr) SetType(VarType::CurveAngle); diff --git a/src/libs/vpatterndb/variables/vcurveclength.cpp b/src/libs/vpatterndb/variables/vcurveclength.cpp index 0494db3c0..448043c38 100644 --- a/src/libs/vpatterndb/variables/vcurveclength.cpp +++ b/src/libs/vpatterndb/variables/vcurveclength.cpp @@ -78,6 +78,7 @@ VCurveCLength::VCurveCLength(const quint32 &id, const quint32 &parentId, const V const VSpline &spl, CurveCLength cType, Unit patternUnit, qint32 segment) : VCurveVariable(id, parentId) { + // cppcheck-suppress unknownMacro SCASSERT(baseCurve != nullptr) SetType(VarType::CurveCLength); diff --git a/src/libs/vpatterndb/variables/vcurvelength.cpp b/src/libs/vpatterndb/variables/vcurvelength.cpp index 5a70f206b..d1f9cb566 100644 --- a/src/libs/vpatterndb/variables/vcurvelength.cpp +++ b/src/libs/vpatterndb/variables/vcurvelength.cpp @@ -48,6 +48,7 @@ VCurveLength::VCurveLength(const quint32 &id, const quint32 &parentId, const VAb :VCurveVariable(id, parentId) { SetType(VarType::CurveLength); + // cppcheck-suppress unknownMacro SCASSERT(curve != nullptr) SetName(curve->name()); diff --git a/src/libs/vpatterndb/variables/vcurvevariable.cpp b/src/libs/vpatterndb/variables/vcurvevariable.cpp index da3ccb887..7586faa38 100644 --- a/src/libs/vpatterndb/variables/vcurvevariable.cpp +++ b/src/libs/vpatterndb/variables/vcurvevariable.cpp @@ -99,6 +99,7 @@ bool VCurveVariable::Filter(quint32 id) return d->id == id || d->parentId == id; } + // cppcheck-suppress unknownMacro QT_WARNING_POP return d->id == id; diff --git a/src/libs/vpatterndb/variables/vcurvevariable_p.h b/src/libs/vpatterndb/variables/vcurvevariable_p.h index 5560cf62b..4ab280332 100644 --- a/src/libs/vpatterndb/variables/vcurvevariable_p.h +++ b/src/libs/vpatterndb/variables/vcurvevariable_p.h @@ -31,15 +31,12 @@ #include -#include "../ifc/ifcdef.h" -#include "../vmisc/diagnostic.h" #include "../vmisc/defglobal.h" QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Weffc++") QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor") -// cppcheck-suppress copyCtorAndEqOperator class VCurveVariableData final : public QSharedData { public: diff --git a/src/libs/vpatterndb/variables/vinternalvariable_p.h b/src/libs/vpatterndb/variables/vinternalvariable_p.h index 56889a204..f77bed0ab 100644 --- a/src/libs/vpatterndb/variables/vinternalvariable_p.h +++ b/src/libs/vpatterndb/variables/vinternalvariable_p.h @@ -31,14 +31,12 @@ #include #include "../vmisc/def.h" -#include "../vmisc/diagnostic.h" #include "../vmisc/defglobal.h" QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Weffc++") QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor") -// cppcheck-suppress copyCtorAndEqOperator class VInternalVariableData final : public QSharedData { public: diff --git a/src/libs/vpatterndb/variables/vlineangle.cpp b/src/libs/vpatterndb/variables/vlineangle.cpp index 5eb6115ba..58a3dba92 100644 --- a/src/libs/vpatterndb/variables/vlineangle.cpp +++ b/src/libs/vpatterndb/variables/vlineangle.cpp @@ -53,6 +53,7 @@ VLineAngle::VLineAngle(const VPointF *p1, const quint32 &p1Id, const VPointF *p2 { SetType(VarType::LineAngle); + // cppcheck-suppress unknownMacro SCASSERT(p1 != nullptr) SCASSERT(p2 != nullptr) diff --git a/src/libs/vpatterndb/variables/vlineangle_p.h b/src/libs/vpatterndb/variables/vlineangle_p.h index 2adf4f2d4..f2bb8fbfe 100644 --- a/src/libs/vpatterndb/variables/vlineangle_p.h +++ b/src/libs/vpatterndb/variables/vlineangle_p.h @@ -31,15 +31,13 @@ #include -#include "../ifc/ifcdef.h" -#include "../vmisc/diagnostic.h" #include "../vmisc/defglobal.h" +#include "../vmisc/typedef.h" QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Weffc++") QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor") -// cppcheck-suppress copyCtorAndEqOperator class VLineAngleData final : public QSharedData { public: diff --git a/src/libs/vpatterndb/variables/vlinelength.cpp b/src/libs/vpatterndb/variables/vlinelength.cpp index f6efa051a..c6236a5d6 100644 --- a/src/libs/vpatterndb/variables/vlinelength.cpp +++ b/src/libs/vpatterndb/variables/vlinelength.cpp @@ -50,6 +50,7 @@ VLengthLine::VLengthLine(const VPointF *p1, const quint32 &p1Id, const VPointF * Unit patternUnit) :VInternalVariable(), d(new VLengthLineData(p1Id, p2Id, patternUnit)) { + // cppcheck-suppress unknownMacro SCASSERT(p1 != nullptr) SCASSERT(p2 != nullptr) diff --git a/src/libs/vpatterndb/variables/vlinelength_p.h b/src/libs/vpatterndb/variables/vlinelength_p.h index d3726c1be..c93f1d991 100644 --- a/src/libs/vpatterndb/variables/vlinelength_p.h +++ b/src/libs/vpatterndb/variables/vlinelength_p.h @@ -31,19 +31,17 @@ #include -#include "../ifc/ifcdef.h" -#include "../vmisc/diagnostic.h" #include "../vmisc/defglobal.h" +#include "../vmisc/def.h" +#include "../vmisc/typedef.h" QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Weffc++") QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor") -// cppcheck-suppress copyCtorAndEqOperator class VLengthLineData final : public QSharedData { public: - VLengthLineData() :p1Id(NULL_ID), p2Id(NULL_ID), patternUnit(Unit::Cm) {} diff --git a/src/libs/vpatterndb/variables/vvariable_p.h b/src/libs/vpatterndb/variables/vvariable_p.h index c9457e444..66744aec1 100644 --- a/src/libs/vpatterndb/variables/vvariable_p.h +++ b/src/libs/vpatterndb/variables/vvariable_p.h @@ -31,14 +31,12 @@ #include -#include "../vmisc/diagnostic.h" #include "../vmisc/defglobal.h" QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Weffc++") QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor") -// cppcheck-suppress copyCtorAndEqOperator class VVariableData final : public QSharedData { public: diff --git a/src/libs/vpatterndb/vtranslatevars.h b/src/libs/vpatterndb/vtranslatevars.h index ef815209a..8d45c6730 100644 --- a/src/libs/vpatterndb/vtranslatevars.h +++ b/src/libs/vpatterndb/vtranslatevars.h @@ -70,6 +70,7 @@ public: static void BiasTokens(int position, int bias, QMap &tokens); private: + // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VTranslateVars) //NOLINT QMap PMSystemNames{}; QMap PMSystemAuthors{}; diff --git a/src/libs/vpropertyexplorer/plugins/Vector3d/vvector3dproperty.cpp b/src/libs/vpropertyexplorer/plugins/Vector3d/vvector3dproperty.cpp index 403018cc0..519b5e92d 100644 --- a/src/libs/vpropertyexplorer/plugins/Vector3d/vvector3dproperty.cpp +++ b/src/libs/vpropertyexplorer/plugins/Vector3d/vvector3dproperty.cpp @@ -31,10 +31,10 @@ VPE::QVector3DProperty::QVector3DProperty(const QString& name) : VProperty(name, QVariant::String) // todo: QVariant::Vector3D?? { QVariant tmpFloat(0); tmpFloat.convert(QVariant::Double); - VDoubleProperty* tmpX = new VDoubleProperty("X"); addChild(tmpX); tmpX->setUpdateBehaviour(true, false); - VDoubleProperty* tmpY = new VDoubleProperty("Y"); addChild(tmpY); tmpY->setUpdateBehaviour(true, false); - VDoubleProperty* tmpZ = new VDoubleProperty("Z"); addChild(tmpZ); tmpZ->setUpdateBehaviour(true, false); - setVector(Vector3D()); + auto* tmpX = new VDoubleProperty("X"); addChild(tmpX); tmpX->setUpdateBehaviour(true, false); + auto* tmpY = new VDoubleProperty("Y"); addChild(tmpY); tmpY->setUpdateBehaviour(true, false); + auto* tmpZ = new VDoubleProperty("Z"); addChild(tmpZ); tmpZ->setUpdateBehaviour(true, false); + VPE::QVector3DProperty::setVector(Vector3D()); } diff --git a/src/libs/vpropertyexplorer/plugins/vfilepropertyeditor.cpp b/src/libs/vpropertyexplorer/plugins/vfilepropertyeditor.cpp index 9879ab869..41a71187d 100644 --- a/src/libs/vpropertyexplorer/plugins/vfilepropertyeditor.cpp +++ b/src/libs/vpropertyexplorer/plugins/vfilepropertyeditor.cpp @@ -212,20 +212,19 @@ void VPE::VFileEditWidget::dropEvent(QDropEvent* event) } -bool VPE::VFileEditWidget::checkMimeData(const QMimeData* data, QString& file) const +auto VPE::VFileEditWidget::checkMimeData(const QMimeData* data, QString& file) const -> bool { if (data->hasUrls()) { QList tmpUrlList = data->urls(); QFileInfo tmpFileInfo; - for(const QUrl &tmpUrl : tmpUrlList) + auto tmpUrl = std::find_if(tmpUrlList.cbegin(), tmpUrlList.cend(), + [](const QUrl &tmpUrl){return QFile::exists(tmpUrl.toLocalFile());}); + + if (tmpUrl != tmpUrlList.cend()) { - if (QFile::exists(tmpUrl.toLocalFile())) - { - tmpFileInfo = QFileInfo(tmpUrl.toLocalFile()); - break; - } + tmpFileInfo = QFileInfo(tmpUrl->toLocalFile()); } if (checkFileFilter(tmpFileInfo.fileName())) diff --git a/src/libs/vpropertyexplorer/vproperty.cpp b/src/libs/vpropertyexplorer/vproperty.cpp index d215b53cf..14c6e98a4 100644 --- a/src/libs/vpropertyexplorer/vproperty.cpp +++ b/src/libs/vpropertyexplorer/vproperty.cpp @@ -47,7 +47,7 @@ VPE::VProperty::VProperty(VPropertyPrivate *d) VPE::VProperty::~VProperty() { - setParent(nullptr); + VPE::VProperty::setParent(nullptr); while (!d_ptr->Children.isEmpty()) { diff --git a/src/libs/vpropertyexplorer/vpropertyformwidget.cpp b/src/libs/vpropertyexplorer/vpropertyformwidget.cpp index 339e6a147..7d3d92d39 100644 --- a/src/libs/vpropertyexplorer/vpropertyformwidget.cpp +++ b/src/libs/vpropertyexplorer/vpropertyformwidget.cpp @@ -40,7 +40,7 @@ VPE::VPropertyFormWidget::VPropertyFormWidget(const QString &title, const QStrin const QList& properties, QWidget *parent) : QGroupBox(title, parent), d_ptr(new VPropertyFormWidgetPrivate(properties)) { - build(); + VPE::VPropertyFormWidget::build(); setToolTip(description); setWhatsThis(description); } @@ -51,7 +51,7 @@ VPE::VPropertyFormWidget::VPropertyFormWidget(VProperty *parent_property, QWidge if (parent_property) { d_ptr->Properties = parent_property->getChildren(); - build(); + VPE::VPropertyFormWidget::build(); setTitle(parent_property->getName()); setToolTip(parent_property->getDescription()); setWhatsThis(parent_property->getDescription()); @@ -62,7 +62,7 @@ VPE::VPropertyFormWidget::VPropertyFormWidget(VPropertyFormWidgetPrivate *d_poin const QString &title, const QString &description) : QGroupBox(title, parent), d_ptr(d_pointer) { - build(); + VPE::VPropertyFormWidget::build(); setToolTip(description); setWhatsThis(description); } diff --git a/src/libs/vpropertyexplorer/vpropertymodel_p.h b/src/libs/vpropertyexplorer/vpropertymodel_p.h index cabd95480..2ff582739 100644 --- a/src/libs/vpropertyexplorer/vpropertymodel_p.h +++ b/src/libs/vpropertyexplorer/vpropertymodel_p.h @@ -47,14 +47,12 @@ public: //! Constructor VPropertyModelPrivate() - : Properties(nullptr), HeadlineProperty(QString()), HeadlineValue(QString()) - { + : Properties(nullptr), //: The text that appears in the first column header - HeadlineProperty = QObject::tr("Property"); - + HeadlineProperty(QObject::tr("Property")), //: The text that appears in the second column header - HeadlineValue = QObject::tr("Value"); - } + HeadlineValue(QObject::tr("Value")) + {} private: Q_DISABLE_COPY(VPropertyModelPrivate) diff --git a/src/libs/vpropertyexplorer/vpropertyset.cpp b/src/libs/vpropertyexplorer/vpropertyset.cpp index f1a1ca355..3f028a6df 100644 --- a/src/libs/vpropertyexplorer/vpropertyset.cpp +++ b/src/libs/vpropertyexplorer/vpropertyset.cpp @@ -37,7 +37,7 @@ VPE::VPropertySet::VPropertySet() VPE::VPropertySet::~VPropertySet() { // Delete all the properties - clear(true); + VPE::VPropertySet::clear(true); delete d_ptr; } @@ -221,15 +221,8 @@ bool VPE::VPropertySet::hasProperty(VProperty *property, VProperty *parent) cons } const QList& tmpChildrenList = (parent != nullptr ? parent->getChildren() : d_ptr->RootProperties); - for(auto tmpProp : tmpChildrenList) - { - if (tmpProp && (tmpProp == property || hasProperty(property, tmpProp))) - { - return true; - } - } - - return false; + return std::any_of(tmpChildrenList.begin(), tmpChildrenList.end(), [this, property](VProperty* tmpProp) + {return tmpProp && (tmpProp == property || hasProperty(property, tmpProp));}); } void VPE::VPropertySet::cloneProperty(VProperty* property_to_clone, VProperty *parent_property, diff --git a/src/libs/vpropertyexplorer/vpropertytreeview.cpp b/src/libs/vpropertyexplorer/vpropertytreeview.cpp index d1d06ac15..7d8298e1c 100644 --- a/src/libs/vpropertyexplorer/vpropertytreeview.cpp +++ b/src/libs/vpropertyexplorer/vpropertytreeview.cpp @@ -30,13 +30,13 @@ VPE::VPropertyTreeView::VPropertyTreeView(QWidget *parent) : QTreeView(parent), d_ptr(new VPropertyTreeViewPrivate()) { - init(); + VPE::VPropertyTreeView::init(); } VPE::VPropertyTreeView::VPropertyTreeView(VPropertyModel *model, QWidget *parent) : QTreeView(parent), d_ptr(new VPropertyTreeViewPrivate()) { - init(); + VPE::VPropertyTreeView::init(); if (model) { @@ -49,7 +49,7 @@ VPE::VPropertyTreeView::VPropertyTreeView(VPropertyTreeViewPrivate *d, bool init { if (init_) { - init(); + VPE::VPropertyTreeView::init(); } } diff --git a/src/libs/vpropertyexplorer/vpropertytreeview.h b/src/libs/vpropertyexplorer/vpropertytreeview.h index 90b0dc6e5..d0d873ed9 100644 --- a/src/libs/vpropertyexplorer/vpropertytreeview.h +++ b/src/libs/vpropertyexplorer/vpropertytreeview.h @@ -69,6 +69,6 @@ private: Q_DISABLE_COPY(VPropertyTreeView) }; -} +} // namespace VPE #endif // VPROPERTYTREEVIEWEEVIEW_H diff --git a/src/libs/vtools/dialogs/dialogtoolbox.cpp b/src/libs/vtools/dialogs/dialogtoolbox.cpp index 99b6ff136..b6f93f5f0 100644 --- a/src/libs/vtools/dialogs/dialogtoolbox.cpp +++ b/src/libs/vtools/dialogs/dialogtoolbox.cpp @@ -199,6 +199,7 @@ void MoveCursorToEnd(QPlainTextEdit *plainTextEdit) //--------------------------------------------------------------------------------------------------------------------- void DeployFormula(QDialog *dialog, QPlainTextEdit *formula, QPushButton *buttonGrowLength, int formulaBaseHeight) { + // cppcheck-suppress unknownMacro SCASSERT(dialog != nullptr) SCASSERT(formula != nullptr) SCASSERT(buttonGrowLength != nullptr) diff --git a/src/libs/vtools/dialogs/support/dialogeditwrongformula.h b/src/libs/vtools/dialogs/support/dialogeditwrongformula.h index f5cefa6d6..52635c1ed 100644 --- a/src/libs/vtools/dialogs/support/dialogeditwrongformula.h +++ b/src/libs/vtools/dialogs/support/dialogeditwrongformula.h @@ -110,6 +110,7 @@ protected: private slots: void FilterVariablesEdited(const QString &filter); private: + // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(DialogEditWrongFormula) //NOLINT Ui::DialogEditWrongFormula *ui; diff --git a/src/libs/vtools/dialogs/tools/dialogtool.h b/src/libs/vtools/dialogs/tools/dialogtool.h index a31ae9f60..a0965de26 100644 --- a/src/libs/vtools/dialogs/tools/dialogtool.h +++ b/src/libs/vtools/dialogs/tools/dialogtool.h @@ -128,7 +128,6 @@ public slots: virtual void PointNameChanged() {} protected: /** @brief data container with data */ - // cppcheck-suppress duplInheritedMember const VContainer *data; /** @brief isInitialized true if window is initialized */ @@ -237,6 +236,7 @@ private: const quint32 &ch1 = NULL_ID, const quint32 &ch2 = NULL_ID) const; }; +// cppcheck-suppress unknownMacro QT_WARNING_POP //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/backgroundimage/vbackgroundimagecontrols.h b/src/libs/vtools/tools/backgroundimage/vbackgroundimagecontrols.h index 89cac03bc..848cf92fe 100644 --- a/src/libs/vtools/tools/backgroundimage/vbackgroundimagecontrols.h +++ b/src/libs/vtools/tools/backgroundimage/vbackgroundimagecontrols.h @@ -104,6 +104,7 @@ private slots: void ScreenChanged(); private: + // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VBackgroundImageControls) // NOLINT QUuid m_id{}; diff --git a/src/libs/vtools/tools/backgroundimage/vbackgroundimageitem.h b/src/libs/vtools/tools/backgroundimage/vbackgroundimageitem.h index 964bb4d01..8aad79a08 100644 --- a/src/libs/vtools/tools/backgroundimage/vbackgroundimageitem.h +++ b/src/libs/vtools/tools/backgroundimage/vbackgroundimageitem.h @@ -111,6 +111,7 @@ private slots: void ZValueChanged(); private: + // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(VBackgroundImageItem) VBackgroundPatternImage m_image; diff --git a/src/libs/vtools/tools/nodeDetails/vnodearc.h b/src/libs/vtools/tools/nodeDetails/vnodearc.h index fda646051..40f58614e 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodearc.h +++ b/src/libs/vtools/tools/nodeDetails/vnodearc.h @@ -62,7 +62,7 @@ protected: private: Q_DISABLE_COPY(VNodeArc) - VNodeArc(const VAbstractNodeInitData &initData, QObject *qoParent = nullptr); + explicit VNodeArc(const VAbstractNodeInitData &initData, QObject *qoParent = nullptr); }; #endif // VNODEARC_H4 diff --git a/src/libs/vtools/tools/nodeDetails/vnodeellipticalarc.h b/src/libs/vtools/tools/nodeDetails/vnodeellipticalarc.h index 1c250b05a..2e80bf590 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodeellipticalarc.h +++ b/src/libs/vtools/tools/nodeDetails/vnodeellipticalarc.h @@ -59,7 +59,7 @@ protected: private: Q_DISABLE_COPY(VNodeEllipticalArc) - VNodeEllipticalArc(const VAbstractNodeInitData &initData, QObject *qoParent = nullptr); + explicit VNodeEllipticalArc(const VAbstractNodeInitData &initData, QObject *qoParent = nullptr); }; #endif // VNODEELLIPTICALARC_H diff --git a/src/libs/vtools/tools/nodeDetails/vnodespline.h b/src/libs/vtools/tools/nodeDetails/vnodespline.h index e94b6156b..655090516 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodespline.h +++ b/src/libs/vtools/tools/nodeDetails/vnodespline.h @@ -62,7 +62,7 @@ protected: private: Q_DISABLE_COPY(VNodeSpline) - VNodeSpline(const VAbstractNodeInitData &initData, QObject *qoParent = nullptr); + explicit VNodeSpline(const VAbstractNodeInitData &initData, QObject *qoParent = nullptr); }; #endif // VNODESPLINE_H diff --git a/src/libs/vtools/tools/nodeDetails/vnodesplinepath.h b/src/libs/vtools/tools/nodeDetails/vnodesplinepath.h index bd9c18b51..2bae52a42 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodesplinepath.h +++ b/src/libs/vtools/tools/nodeDetails/vnodesplinepath.h @@ -62,7 +62,7 @@ protected: private: Q_DISABLE_COPY(VNodeSplinePath) - VNodeSplinePath(const VAbstractNodeInitData &initData, QObject *qoParent = nullptr); + explicit VNodeSplinePath(const VAbstractNodeInitData &initData, QObject *qoParent = nullptr); }; #endif // VNODESPLINEPATH_H diff --git a/src/libs/vtools/tools/vabstracttool.h b/src/libs/vtools/tools/vabstracttool.h index b7d4de8ba..9f3d68a34 100644 --- a/src/libs/vtools/tools/vabstracttool.h +++ b/src/libs/vtools/tools/vabstracttool.h @@ -209,7 +209,8 @@ template inline void VAbstractTool::AddVisualization() { T *visual = new T(getData()); - VMainGraphicsScene *scene = qobject_cast(VAbstractValApplication::VApp()->getCurrentScene()); + auto *scene = qobject_cast(VAbstractValApplication::VApp()->getCurrentScene()); + // cppcheck-suppress unknownMacro SCASSERT(scene != nullptr) scene->addItem(visual); diff --git a/src/libs/vtools/undocommands/addpatternpiece.cpp b/src/libs/vtools/undocommands/addpatternpiece.cpp index 1c33b5024..2bf385fe8 100644 --- a/src/libs/vtools/undocommands/addpatternpiece.cpp +++ b/src/libs/vtools/undocommands/addpatternpiece.cpp @@ -37,6 +37,7 @@ AddPatternPiece::AddPatternPiece(const QDomElement &xml, VAbstractPattern *doc, QUndoCommand *parent) : VUndoCommand(xml, doc, parent), namePP(namePP) { + // cppcheck-suppress unknownMacro SCASSERT(namePP.isEmpty() == false) setText(tr("add pattern piece %1").arg(namePP)); } diff --git a/src/libs/vtools/undocommands/deletepatternpiece.cpp b/src/libs/vtools/undocommands/deletepatternpiece.cpp index 15c6b9503..19a3c334c 100644 --- a/src/libs/vtools/undocommands/deletepatternpiece.cpp +++ b/src/libs/vtools/undocommands/deletepatternpiece.cpp @@ -98,7 +98,7 @@ void DeletePatternPiece::redo() emit doc->SetCurrentPP(namePP);//Without this user will not see this change } QDomElement rootElement = doc->documentElement(); - const QDomElement patternPiece = doc->GetPPElement(namePP); - rootElement.removeChild(patternPiece); + const QDomElement patternPieceElement = doc->GetPPElement(namePP); + rootElement.removeChild(patternPieceElement); emit NeedFullParsing(); } diff --git a/src/libs/vtools/undocommands/image/addbackgroundimage.h b/src/libs/vtools/undocommands/image/addbackgroundimage.h index 979e43e14..fdfd1b287 100644 --- a/src/libs/vtools/undocommands/image/addbackgroundimage.h +++ b/src/libs/vtools/undocommands/image/addbackgroundimage.h @@ -47,6 +47,7 @@ signals: void AddItem(const QUuid &id); void DeleteItem(const QUuid &id); private: + // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(AddBackgroundImage) VBackgroundPatternImage m_image; }; diff --git a/src/libs/vtools/undocommands/image/deletebackgroundimage.h b/src/libs/vtools/undocommands/image/deletebackgroundimage.h index 74f13a3b7..08c527ac6 100644 --- a/src/libs/vtools/undocommands/image/deletebackgroundimage.h +++ b/src/libs/vtools/undocommands/image/deletebackgroundimage.h @@ -48,6 +48,7 @@ signals: void AddItem(const QUuid &id); void DeleteItem(const QUuid &id); private: + // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(DeleteBackgroundImage) VBackgroundPatternImage m_image; int m_index{-1}; diff --git a/src/libs/vtools/undocommands/image/hideallbackgroundimages.h b/src/libs/vtools/undocommands/image/hideallbackgroundimages.h index 17ddd044a..5b8dad798 100644 --- a/src/libs/vtools/undocommands/image/hideallbackgroundimages.h +++ b/src/libs/vtools/undocommands/image/hideallbackgroundimages.h @@ -43,6 +43,7 @@ public: void undo() override; void redo() override; private: + // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(HideAllBackgroundImages) bool m_hide; QMap m_oldVisibility{}; diff --git a/src/libs/vtools/undocommands/image/hidebackgroundimage.h b/src/libs/vtools/undocommands/image/hidebackgroundimage.h index b363bb848..92052655c 100644 --- a/src/libs/vtools/undocommands/image/hidebackgroundimage.h +++ b/src/libs/vtools/undocommands/image/hidebackgroundimage.h @@ -43,6 +43,7 @@ public: void undo() override; void redo() override; private: + // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(HideBackgroundImage) QUuid m_id; bool m_hide; diff --git a/src/libs/vtools/undocommands/image/holdallbackgroundimages.h b/src/libs/vtools/undocommands/image/holdallbackgroundimages.h index 9a3e57fce..3432793a9 100644 --- a/src/libs/vtools/undocommands/image/holdallbackgroundimages.h +++ b/src/libs/vtools/undocommands/image/holdallbackgroundimages.h @@ -42,6 +42,7 @@ public: void undo() override; void redo() override; private: + // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(HoldAllBackgroundImages) bool m_hold; QMap m_oldHold{}; diff --git a/src/libs/vtools/undocommands/image/holdbackgroundimage.h b/src/libs/vtools/undocommands/image/holdbackgroundimage.h index 56a71d00b..bc6559c73 100644 --- a/src/libs/vtools/undocommands/image/holdbackgroundimage.h +++ b/src/libs/vtools/undocommands/image/holdbackgroundimage.h @@ -43,6 +43,7 @@ public: void undo() override; void redo() override; private: + // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(HoldBackgroundImage) QUuid m_id; bool m_hold; diff --git a/src/libs/vtools/undocommands/image/movebackgroundimage.h b/src/libs/vtools/undocommands/image/movebackgroundimage.h index 54d707bc9..e51574717 100644 --- a/src/libs/vtools/undocommands/image/movebackgroundimage.h +++ b/src/libs/vtools/undocommands/image/movebackgroundimage.h @@ -57,6 +57,7 @@ public: auto AllowMerge() const -> bool; private: + // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(MoveBackgroundImage) QUuid m_id; diff --git a/src/libs/vtools/undocommands/image/opaquebackgroundimage.h b/src/libs/vtools/undocommands/image/opaquebackgroundimage.h index 27cd8c5bd..12e4aadb3 100644 --- a/src/libs/vtools/undocommands/image/opaquebackgroundimage.h +++ b/src/libs/vtools/undocommands/image/opaquebackgroundimage.h @@ -42,6 +42,7 @@ public: void undo() override; void redo() override; private: + // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(OpaqueBackgroundImage) QUuid m_id; qreal m_opacity; diff --git a/src/libs/vtools/undocommands/image/renamebackgroundimage.h b/src/libs/vtools/undocommands/image/renamebackgroundimage.h index fa7808dde..f3f66e8e7 100644 --- a/src/libs/vtools/undocommands/image/renamebackgroundimage.h +++ b/src/libs/vtools/undocommands/image/renamebackgroundimage.h @@ -43,6 +43,7 @@ public: void undo() override; void redo() override; private: + // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(RenameBackgroundImage) QUuid m_id; QString m_name; diff --git a/src/libs/vtools/undocommands/image/resetbackgroundimage.h b/src/libs/vtools/undocommands/image/resetbackgroundimage.h index 341983a77..aed6bd7b1 100644 --- a/src/libs/vtools/undocommands/image/resetbackgroundimage.h +++ b/src/libs/vtools/undocommands/image/resetbackgroundimage.h @@ -47,6 +47,7 @@ public: void redo() override; private: + // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(ResetBackgroundImage) QUuid m_id; diff --git a/src/libs/vtools/undocommands/image/rotatebackgroundimage.h b/src/libs/vtools/undocommands/image/rotatebackgroundimage.h index 3536b9d59..512bccdfd 100644 --- a/src/libs/vtools/undocommands/image/rotatebackgroundimage.h +++ b/src/libs/vtools/undocommands/image/rotatebackgroundimage.h @@ -56,6 +56,7 @@ public: auto AllowMerge() const -> bool; private: + // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(RotateBackgroundImage) QUuid m_id; diff --git a/src/libs/vtools/undocommands/image/scalebackgroundimage.h b/src/libs/vtools/undocommands/image/scalebackgroundimage.h index 66b928a99..7d2389c9a 100644 --- a/src/libs/vtools/undocommands/image/scalebackgroundimage.h +++ b/src/libs/vtools/undocommands/image/scalebackgroundimage.h @@ -57,6 +57,7 @@ public: auto AllowMerge() const -> bool; private: + // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(ScaleBackgroundImage) QUuid m_id; diff --git a/src/libs/vtools/undocommands/image/zvaluemovebackgroundimage.h b/src/libs/vtools/undocommands/image/zvaluemovebackgroundimage.h index 91d98b945..f5f8643e1 100644 --- a/src/libs/vtools/undocommands/image/zvaluemovebackgroundimage.h +++ b/src/libs/vtools/undocommands/image/zvaluemovebackgroundimage.h @@ -50,6 +50,7 @@ public: void undo() override; void redo() override; private: + // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(ZValueMoveBackgroundImage) QUuid m_id; ZValueMove m_move; diff --git a/src/libs/vtools/undocommands/movespline.cpp b/src/libs/vtools/undocommands/movespline.cpp index 0ef95274b..ab3078262 100644 --- a/src/libs/vtools/undocommands/movespline.cpp +++ b/src/libs/vtools/undocommands/movespline.cpp @@ -76,11 +76,11 @@ void MoveSpline::redo() //--------------------------------------------------------------------------------------------------------------------- bool MoveSpline::mergeWith(const QUndoCommand *command) { - const MoveSpline *moveCommand = static_cast(command); + const auto *moveCommand = static_cast(command); SCASSERT(moveCommand != nullptr) - const quint32 id = moveCommand->getSplineId(); + const quint32 splineId = moveCommand->getSplineId(); - if (id != nodeId) + if (splineId != nodeId) { return false; } diff --git a/src/libs/vtools/undocommands/movespoint.cpp b/src/libs/vtools/undocommands/movespoint.cpp index bbf9d0f26..aa3d8991e 100644 --- a/src/libs/vtools/undocommands/movespoint.cpp +++ b/src/libs/vtools/undocommands/movespoint.cpp @@ -87,12 +87,12 @@ void MoveSPoint::redo() //--------------------------------------------------------------------------------------------------------------------- bool MoveSPoint::mergeWith(const QUndoCommand *command) { - const MoveSPoint *moveCommand = static_cast(command); + const auto *moveCommand = static_cast(command); SCASSERT(moveCommand != nullptr) - const quint32 id = moveCommand->getSPointId(); + const quint32 sPointId = moveCommand->getSPointId(); qCDebug(vUndo, "Mergin."); - if (id != nodeId) + if (sPointId != nodeId) { qCDebug(vUndo, "Merging canceled."); return false; diff --git a/src/libs/vtools/visualization/line/visline.cpp b/src/libs/vtools/visualization/line/visline.cpp index 02a5fb5f8..ef7f77881 100644 --- a/src/libs/vtools/visualization/line/visline.cpp +++ b/src/libs/vtools/visualization/line/visline.cpp @@ -44,7 +44,7 @@ VisLine::VisLine(const VContainer *data, QGraphicsItem *parent) :Visualization(data), VScaledLine(parent) { this->setZValue(1);// Show on top of a real tool - InitPen(); + VisLine::InitPen(); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/visualization/visualization.h b/src/libs/vtools/visualization/visualization.h index 27ed8693c..263825e35 100644 --- a/src/libs/vtools/visualization/visualization.h +++ b/src/libs/vtools/visualization/visualization.h @@ -126,6 +126,7 @@ private: Q_DISABLE_COPY(Visualization) }; +// cppcheck-suppress unknownMacro QT_WARNING_POP //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vwidgets/fancytabbar/fancytabbar.h b/src/libs/vwidgets/fancytabbar/fancytabbar.h index 373dd4b22..8b3c4c81c 100644 --- a/src/libs/vwidgets/fancytabbar/fancytabbar.h +++ b/src/libs/vwidgets/fancytabbar/fancytabbar.h @@ -52,7 +52,7 @@ public: Right }; - FancyTabBar(const TabBarPosition position, QWidget *parent = nullptr); + explicit FancyTabBar(const TabBarPosition position, QWidget *parent = nullptr); virtual ~FancyTabBar() Q_DECL_EQ_DEFAULT; virtual QSize sizeHint() const override; diff --git a/src/libs/vwidgets/qtcolorpicker.cpp b/src/libs/vwidgets/qtcolorpicker.cpp index 4af80d542..8988219e6 100644 --- a/src/libs/vwidgets/qtcolorpicker.cpp +++ b/src/libs/vwidgets/qtcolorpicker.cpp @@ -600,14 +600,14 @@ ColorPickerPopup::~ColorPickerPopup() If there is an item whole color is equal to \a col, returns a pointer to this item; otherwise returns 0. */ -ColorPickerItem *ColorPickerPopup::find(const QColor &col) const +auto ColorPickerPopup::find(const QColor &col) const -> ColorPickerItem * { - for (auto *item : items) + auto item = std::find_if(items.begin(), items.end(), + [col](ColorPickerItem *item){return item && item->color() == col;}); + + if (item != items.end()) { - if (item && item->color() == col) - { - return item; - } + return *item; } return nullptr; @@ -832,11 +832,10 @@ void ColorPickerPopup::keyPressEvent(QKeyEvent *e) int i = 0; while ((layoutItem = grid->itemAt(i)) != 0) { - QWidget *w = layoutItem->widget(); - if (w && w->inherits("ColorPickerItem")) + QWidget *wl = layoutItem->widget(); + if (wl && wl->inherits("ColorPickerItem")) { - ColorPickerItem *litem - = reinterpret_cast(layoutItem->widget()); + auto *litem = reinterpret_cast(layoutItem->widget()); if (litem != wi) { litem->setSelected(false); @@ -858,11 +857,10 @@ void ColorPickerPopup::keyPressEvent(QKeyEvent *e) int i = 0; while ((layoutItem = grid->itemAt(i)) != 0) { - QWidget *w = layoutItem->widget(); - if (w && w->inherits("ColorPickerItem")) + QWidget *wl = layoutItem->widget(); + if (wl && wl->inherits("ColorPickerItem")) { - ColorPickerItem *litem - = reinterpret_cast(layoutItem->widget()); + auto *litem = reinterpret_cast(layoutItem->widget()); if (litem != wi) { litem->setSelected(false); diff --git a/src/libs/vwidgets/vabstractmainwindow.cpp b/src/libs/vwidgets/vabstractmainwindow.cpp index d01c4ed35..39bf2ed4d 100644 --- a/src/libs/vwidgets/vabstractmainwindow.cpp +++ b/src/libs/vwidgets/vabstractmainwindow.cpp @@ -268,7 +268,6 @@ auto VAbstractMainWindow::CheckFilePermissions(const QString &path, QWidget *mes return true; } - // cppcheck-suppress unreadVariable const bool isFileWritable = info.isWritable(); //#ifdef Q_OS_WIN32 diff --git a/src/libs/vwidgets/vlineedit.h b/src/libs/vwidgets/vlineedit.h index 23a75a35c..939ee8815 100644 --- a/src/libs/vwidgets/vlineedit.h +++ b/src/libs/vwidgets/vlineedit.h @@ -38,7 +38,7 @@ class VLineEdit : public QLineEdit Q_OBJECT public: explicit VLineEdit(QWidget * parent = nullptr); - VLineEdit(const QString &contents, QWidget *parent = nullptr); + explicit VLineEdit(const QString &contents, QWidget *parent = nullptr); protected: virtual void focusInEvent(QFocusEvent *e) override; diff --git a/src/libs/vwidgets/vplaintextedit.h b/src/libs/vwidgets/vplaintextedit.h index 4d9909b74..41adc194c 100644 --- a/src/libs/vwidgets/vplaintextedit.h +++ b/src/libs/vwidgets/vplaintextedit.h @@ -36,7 +36,7 @@ class VPlainTextEdit : public QPlainTextEdit Q_OBJECT public: explicit VPlainTextEdit(QWidget * parent = nullptr); - VPlainTextEdit(const QString & text, QWidget * parent = nullptr); + explicit VPlainTextEdit(const QString & text, QWidget * parent = nullptr); virtual ~VPlainTextEdit(); void SetMatchParenthesesEnabled(bool enabled); diff --git a/src/test/TranslationsTest/tst_buitinregexp.cpp b/src/test/TranslationsTest/tst_buitinregexp.cpp index e65af2a60..58bfe3659 100644 --- a/src/test/TranslationsTest/tst_buitinregexp.cpp +++ b/src/test/TranslationsTest/tst_buitinregexp.cpp @@ -226,24 +226,24 @@ void TST_BuitInRegExp::TestCheckInternalVaribleRegExp() static const QString regex = QStringLiteral("(.){1,}_(.){1,}$"); - const QString sourceRegex = QLatin1String("^") + var + regex; + const QString sourceRegex = QChar('^') + var + regex; const QRegularExpression sourceRe(sourceRegex); const QString translated = m_trMs->InternalVarToUser(var); - const QString translationRegex = QLatin1String("^") + translated + regex; + const QString translationRegex = QChar('^') + translated + regex; const QRegularExpression translationRe(translationRegex); { if (sourceRe.match(originalName).hasMatch() || translationRe.match(originalName).hasMatch()) { - const QString message = QString("Invalid original string '%1'").arg(originalName); + const QString message = QStringLiteral("Invalid original string '%1'").arg(originalName); QFAIL(qUtf8Printable(message)); } - const QString translated = m_trMs->VarToUser(originalName); - if (sourceRe.match(translated).hasMatch() || translationRe.match(translated).hasMatch()) + const QString translatedMessage = m_trMs->VarToUser(originalName); + if (sourceRe.match(translatedMessage).hasMatch() || translationRe.match(translatedMessage).hasMatch()) { - const QString message = QString("Invalid translation string '%1'").arg(translated); + const QString message = QStringLiteral("Invalid translation string '%1'").arg(translatedMessage); QFAIL(qUtf8Printable(message)); } } diff --git a/src/test/TranslationsTest/tst_measurementregexp.cpp b/src/test/TranslationsTest/tst_measurementregexp.cpp index 5a99db3c9..84f0b7b72 100644 --- a/src/test/TranslationsTest/tst_measurementregexp.cpp +++ b/src/test/TranslationsTest/tst_measurementregexp.cpp @@ -201,6 +201,7 @@ void TST_MeasurementRegExp::TestCombinations(int systemCounts, const QStringList QDir dir(TranslationsPath()); const QStringList fileNames = dir.entryList(QStringList("measurements_p*_*.qm")); + // cppcheck-suppress unreadVariable const QString error = QString("Unexpected count of files. Excpected %1, got %2.") .arg(combinations).arg(fileNames.size()); QVERIFY2(combinations == fileNames.size(), qUtf8Printable(error)); diff --git a/src/test/TranslationsTest/tst_qmuparsererrormsg.cpp b/src/test/TranslationsTest/tst_qmuparsererrormsg.cpp index 39c48b667..4a6d5f38e 100644 --- a/src/test/TranslationsTest/tst_qmuparsererrormsg.cpp +++ b/src/test/TranslationsTest/tst_qmuparsererrormsg.cpp @@ -126,7 +126,8 @@ void TST_QmuParserErrorMsg::TestEErrorCodes() QFETCH(bool, pos); const QString translated = (*msg)[code]; - const QString message = QString("String: '%1'.").arg(translated); + // cppcheck-suppress unreadVariable + const QString message = QStringLiteral("String: '%1'.").arg(translated); QVERIFY2((translated.indexOf(QLatin1String("$TOK$")) != -1) == tok, qUtf8Printable(message)); QVERIFY2((translated.indexOf(QLatin1String("$POS$")) != -1) == pos, qUtf8Printable(message)); diff --git a/src/test/TranslationsTest/tst_tslocaletranslation.cpp b/src/test/TranslationsTest/tst_tslocaletranslation.cpp index c32eee28a..ec646de56 100644 --- a/src/test/TranslationsTest/tst_tslocaletranslation.cpp +++ b/src/test/TranslationsTest/tst_tslocaletranslation.cpp @@ -78,14 +78,14 @@ void TST_TSLocaleTranslation::CheckPlaceMarkerExist_data() continue; } - const QString message = QStringLiteral("File '%1'. Check place holder source message '%2'") + const QString caseName = QStringLiteral("File '%1'. Check place holder source message '%2'") .arg(filename, source); - QTest::newRow(qUtf8Printable(message)) << source << translation << locale.textDirection(); + QTest::newRow(qUtf8Printable(caseName)) << source << translation << locale.textDirection(); } else { - const QString message = QStringLiteral("File '%2'. Message %1 is null.").arg(i).arg(filename); - QFAIL(qUtf8Printable(message)); + const QString caseName = QStringLiteral("File '%2'. Message %1 is null.").arg(i).arg(filename); + QFAIL(qUtf8Printable(caseName)); } } } @@ -184,13 +184,13 @@ void TST_TSLocaleTranslation::TestPunctuation_data() continue; } - const QString message = QString("File '%1'.").arg(filename); - QTest::newRow(qUtf8Printable(message)) << m_locale << source << translation; + const QString caseName = QStringLiteral("File '%1'.").arg(filename); + QTest::newRow(qUtf8Printable(caseName)) << m_locale << source << translation; } else { - const QString message = QString("File '%2'. Message %1 is null.").arg(i).arg(filename); - QFAIL(qUtf8Printable(message)); + const QString caseName = QStringLiteral("File '%2'. Message %1 is null.").arg(i).arg(filename); + QFAIL(qUtf8Printable(caseName)); } } } @@ -303,13 +303,13 @@ void TST_TSLocaleTranslation::TestHTMLTags_data() continue; } - const QString message = QString("File '%1'.").arg(filename); - QTest::newRow(qUtf8Printable(message)) << source << translation; + const QString caseName = QStringLiteral("File '%1'.").arg(filename); + QTest::newRow(qUtf8Printable(caseName)) << source << translation; } else { - const QString message = QString("File '%2'. Message %1 is null.").arg(i).arg(filename); - QFAIL(qUtf8Printable(message)); + const QString caseName = QStringLiteral("File '%2'. Message %1 is null.").arg(i).arg(filename); + QFAIL(qUtf8Printable(caseName)); } } } diff --git a/src/test/TranslationsTest/tst_tstranslation.cpp b/src/test/TranslationsTest/tst_tstranslation.cpp index ac4103284..00193bcbb 100644 --- a/src/test/TranslationsTest/tst_tstranslation.cpp +++ b/src/test/TranslationsTest/tst_tstranslation.cpp @@ -55,7 +55,7 @@ void TST_TSTranslation::CheckEnglishLocalization_data() for (qint32 i = 0, num = messages.size(); i < num; ++i) { const QDomElement message = messages.at(i).toElement(); - if (message.isNull() == false) + if (not message.isNull()) { const QString source = message.firstChildElement(TagSource).text(); if (source.isEmpty()) @@ -78,13 +78,14 @@ void TST_TSTranslation::CheckEnglishLocalization_data() continue; } - const QString message = QString("File '%1'. Check modification source message '%2'.").arg(fileName, source); - QTest::newRow(qUtf8Printable(message)) << source << translation; + const QString caseName = QStringLiteral("File '%1'. Check modification source message '%2'.") + .arg(fileName, source); + QTest::newRow(qUtf8Printable(caseName)) << source << translation; } else { - const QString message = QString("Message %1 is null.").arg(i); - QFAIL(qUtf8Printable(message)); + const QString caseName = QStringLiteral("Message %1 is null.").arg(i); + QFAIL(qUtf8Printable(caseName)); } } } @@ -215,7 +216,7 @@ void TST_TSTranslation::PrepareOriginalStrings() for (qint32 i = 0, num = messages.size(); i < num; ++i) { const QDomElement message = messages.at(i).toElement(); - if (message.isNull() == false) + if (not message.isNull()) { const QString source = message.firstChildElement(TagSource).text(); if (source.isEmpty()) @@ -223,13 +224,13 @@ void TST_TSTranslation::PrepareOriginalStrings() continue; } - const QString tag = QString("File '%1'. Check modification source message '%2'.").arg(fileName, source); + const QString tag = QStringLiteral("File '%1'. Check modification source message '%2'.").arg(fileName, source); QTest::newRow(qUtf8Printable(tag)) << source << message; } else { - const QString message = QString("Message %1 is null.").arg(i); - QFAIL(qUtf8Printable(message)); + const QString errorMessage = QStringLiteral("Message %1 is null.").arg(i); + QFAIL(qUtf8Printable(errorMessage)); } } } diff --git a/src/test/ValentinaTest/tst_readval.cpp b/src/test/ValentinaTest/tst_readval.cpp index fcf30755e..8e1bed040 100644 --- a/src/test/ValentinaTest/tst_readval.cpp +++ b/src/test/ValentinaTest/tst_readval.cpp @@ -123,7 +123,7 @@ void TST_ReadVal::PrepareVal(qreal val, const QLocale &locale) //--------------------------------------------------------------------------------------------------------------------- void TST_ReadVal::PrepareString(const QString &str, const QLocale &locale, qreal val, int count) { - const QString tag = QString("%1. String '%2'").arg(locale.name(), str); + const QString tag = QStringLiteral("%1. String '%2'").arg(locale.name(), str); QTest::newRow(qUtf8Printable(tag)) << str << count << val << locale; } @@ -140,12 +140,14 @@ void TST_ReadVal::TestVal() const int resCount = ReadVal(formula, resVal, locale, locale.decimalPoint(), locale.groupSeparator()); - QString errorMsg = QString("Conversion failed. Locale: '%1'.").arg(locale.name()); + // cppcheck-suppress unreadVariable + QString errorMsg = QStringLiteral("Conversion failed. Locale: '%1'.").arg(locale.name()); QVERIFY2(resCount == expCount, qUtf8Printable(errorMsg)); if (resCount != -1) { - QString errorMsg = QString("Unexpected result. Locale: '%1'.").arg(locale.name()); + // cppcheck-suppress unreadVariable + errorMsg = QStringLiteral("Unexpected result. Locale: '%1'.").arg(locale.name()); QVERIFY2(QmuFuzzyComparePossibleNulls(resVal, expVal), qUtf8Printable(errorMsg)); } } diff --git a/src/test/ValentinaTest/tst_varc.cpp b/src/test/ValentinaTest/tst_varc.cpp index 2e2fb83af..6b2bced6f 100644 --- a/src/test/ValentinaTest/tst_varc.cpp +++ b/src/test/ValentinaTest/tst_varc.cpp @@ -207,6 +207,7 @@ void TST_VArc::TestGetPoints() { QLineF rLine(static_cast(center), point); const qreal value = qAbs(rLine.length() - radius); + // cppcheck-suppress unreadVariable const QString errorMsg = QString("Broken the first rule. All points should be on the same distance from " "the center. Error ='%1'.").arg(value); QVERIFY2(value <= epsRadius, qUtf8Printable(errorMsg)); @@ -229,6 +230,7 @@ void TST_VArc::TestGetPoints() // calculated square const qreal cSquare = qAbs(VAbstractPiece::SumTrapezoids(points)/2.0); const qreal value = qAbs(gSquare - cSquare); + // cppcheck-suppress unreadVariable const QString errorMsg = QString("Broken the second rule. Interpolation has too big computing error. Error ='%1'.").arg(value); const qreal epsSquare = gSquare * 0.24 / 100; // computing error 0.24 % from origin square @@ -267,6 +269,7 @@ void TST_VArc::TestRotation() QCOMPARE(arcOrigin.GetLength(), rotatedArc.GetLength()); QCOMPARE(arcOrigin.AngleArc(), rotatedArc.AngleArc()); QCOMPARE(arcOrigin.GetRadius(), rotatedArc.GetRadius()); + // cppcheck-suppress unreadVariable const QString errorMsg = QString("The name doesn't contain the prefix '%1'.").arg(prefix); QVERIFY2(rotatedArc.name().endsWith(prefix), qUtf8Printable(errorMsg)); } @@ -332,6 +335,7 @@ void TST_VArc::TestFlip() VArc originArc(VPointF(center), radius, startAngle, endAngle); const VArc res = originArc.Flip(axis, prefix); + // cppcheck-suppress unreadVariable const QString errorMsg = QString("The name doesn't contain the prefix '%1'.").arg(prefix); QVERIFY2(res.name().endsWith(prefix), qUtf8Printable(errorMsg)); diff --git a/src/test/ValentinaTest/tst_vcommandline.cpp b/src/test/ValentinaTest/tst_vcommandline.cpp index a77cbee99..b60eb501c 100644 --- a/src/test/ValentinaTest/tst_vcommandline.cpp +++ b/src/test/ValentinaTest/tst_vcommandline.cpp @@ -47,6 +47,7 @@ void TST_VCommandLine::UniqueKeys() for (auto &str : options) { + // cppcheck-suppress unreadVariable const QString message = QString("Options '%1' is not unique!").arg(str); QVERIFY2(not unique.contains(str), qUtf8Printable(message)); unique.insert(str); diff --git a/src/test/ValentinaTest/tst_vellipticalarc.cpp b/src/test/ValentinaTest/tst_vellipticalarc.cpp index 4e967a811..ab6bf8168 100644 --- a/src/test/ValentinaTest/tst_vellipticalarc.cpp +++ b/src/test/ValentinaTest/tst_vellipticalarc.cpp @@ -85,6 +85,7 @@ void TST_VEllipticalArc::CompareTwoWays() const qreal lengthEps = ToPixel(0.45, Unit::Mm); // computing error + // cppcheck-suppress unreadVariable QString errorLengthMsg = QString("Difference between real and computing lengthes bigger than eps = %1. l1 = %2; l2 = %3"); QVERIFY2(qAbs(arc2.GetLength() - length) <= lengthEps, @@ -93,6 +94,7 @@ void TST_VEllipticalArc::CompareTwoWays() qUtf8Printable(errorLengthMsg.arg(lengthEps).arg(arc2.GetLength()).arg(arc2.GetLength()))); const qreal angleEps = 0.4; + // cppcheck-suppress unreadVariable const QString errorAngleMsg = QString("Difference between real and computing angles bigger than eps = %1. f1 = %2; f2 = %3"); // compare angles @@ -118,6 +120,7 @@ void TST_VEllipticalArc::NegativeArc() VEllipticalArc arc(-length, center, radius1, radius2, f1, rotationAngle); const qreal eps = ToPixel(0.45, Unit::Mm); // computing error + // cppcheck-suppress unreadVariable const QString errorMsg = QString("Difference between real and computing lengthes bigger than eps = %1. v1 = %2; v2 = %3"); @@ -289,6 +292,7 @@ void TST_VEllipticalArc::TestGetPoints1() { const qreal equationRes = p.rx()*p.rx()/(radius1*radius1) + p.ry()*p.ry()/(radius2*radius2); const qreal diff = qAbs(equationRes - 1); + // cppcheck-suppress unreadVariable const QString errorMsg = QString("Broken the first rule. Any point must satisfy the equation of ellipse." "diff = '%1' > eps = '%2'").number(diff).number(eps); QVERIFY2( diff <= eps, qUtf8Printable(errorMsg)); @@ -358,6 +362,7 @@ void TST_VEllipticalArc::TestGetPoints2() const QLineF rLine2(focus2, points.at(i)); const qreal resultingDistance = rLine1.length()+rLine2.length(); const qreal diff = qAbs(resultingDistance - distance); + // cppcheck-suppress unreadVariable const QString errorMsg = QString("Broken the first rule, part 2. Distance from the any point to the focus1" " plus distance from this point to the focus2 should be the same. Problem" " with point '%1'. The disired distance is '%2', but resulting distance" @@ -388,6 +393,7 @@ void TST_VEllipticalArc::TestGetPoints3() const qreal epsSquare = ellipseSquare * 1.7 / 100; // computing error 1.7 % from origin square const qreal arcSquare = qAbs(VAbstractPiece::SumTrapezoids(points)/2.0); const qreal diffSquare = qAbs(ellipseSquare - arcSquare); + // cppcheck-suppress unreadVariable const QString errorMsg1 = QString("Broken the second rule. Interpolation has too big computing error. " "Difference ='%1' bigger than eps = '%2'.").arg(diffSquare).arg(epsSquare); QVERIFY2(diffSquare <= epsSquare, qUtf8Printable(errorMsg1)); @@ -413,9 +419,9 @@ void TST_VEllipticalArc::TestGetPoints4() const qreal h = ((radius1-radius2)*(radius1-radius2))/((radius1+radius2)*(radius1+radius2)); const qreal ellipseLength = M_PI*(radius1+radius2)*(1+3*h/(10+qSqrt(4-3*h))); const qreal epsLength = ellipseLength*0.5/100; // computing error - VEllipticalArc arc(center, radius1, radius2, 0, 360, 0); - const qreal arcLength = arc.GetLength(); + const qreal arcLength = VEllipticalArc(center, radius1, radius2, 0, 360, 0).GetLength(); const qreal diffLength = qAbs(arcLength - ellipseLength); + // cppcheck-suppress unreadVariable const QString errorMsg2 = QString("Difference between real and computing lengthes " "(diff = '%1') bigger than eps = '%2'.").arg(diffLength).arg(epsLength); QVERIFY2(diffLength <= epsLength, qUtf8Printable(errorMsg2)); @@ -524,6 +530,7 @@ void TST_VEllipticalArc::TestRotation() QVERIFY2(qAbs(arcOrigin.AngleArc() - rotatedArc.AngleArc()) <= 1.6, qUtf8Printable(QString("a1 = %1, a2 - %2").arg(arcOrigin.AngleArc()).arg(rotatedArc.AngleArc()))); + // cppcheck-suppress unreadVariable QString errorLengthMsg = QString("Difference between real and computing lengthes bigger than eps = %1. l1 = %2; l2 = %3"); QVERIFY2(qAbs(arcOrigin.GetLength() - rotatedArc.GetLength()) <= ToPixel(1, Unit::Mm), @@ -534,6 +541,7 @@ void TST_VEllipticalArc::TestRotation() QCOMPARE(arcOrigin.GetRadius1(), rotatedArc.GetRadius1()); QCOMPARE(arcOrigin.GetRadius2(), rotatedArc.GetRadius2()); QCOMPARE(arcOrigin.GetRotationAngle(), rotatedArc.GetRotationAngle()); + // cppcheck-suppress unreadVariable const QString errorMsg = QString("The name doesn't contain the prefix '%1'.").arg(prefix); QVERIFY2(rotatedArc.name().endsWith(prefix), qUtf8Printable(errorMsg)); } @@ -570,6 +578,7 @@ void TST_VEllipticalArc::TestFlip() const VEllipticalArc res = elArc.Flip(axis, prefix); + // cppcheck-suppress unreadVariable const QString errorMsg = QString("The name doesn't contain the prefix '%1'.").arg(prefix); QVERIFY2(res.name().endsWith(prefix), qUtf8Printable(errorMsg)); diff --git a/src/test/ValentinaTest/tst_vlockguard.cpp b/src/test/ValentinaTest/tst_vlockguard.cpp index f403c71d7..7587cc016 100644 --- a/src/test/ValentinaTest/tst_vlockguard.cpp +++ b/src/test/ValentinaTest/tst_vlockguard.cpp @@ -45,6 +45,7 @@ void TST_VLockGuard::TryLock() const QSharedPointer> lock; VlpCreateLock(lock, fileName); + // cppcheck-suppress nullPointer fileName = lock->GetLockFile(); QVERIFY2(QFileInfo::exists(fileName), "Lock file doesn't exist!"); diff --git a/src/test/ValentinaTest/tst_vmeasurements.cpp b/src/test/ValentinaTest/tst_vmeasurements.cpp index 644458511..24e46be0d 100644 --- a/src/test/ValentinaTest/tst_vmeasurements.cpp +++ b/src/test/ValentinaTest/tst_vmeasurements.cpp @@ -175,6 +175,7 @@ void TST_VMeasurements::ValidPMCodesMultisizeFile() QString error; const bool result = m->SaveDocument(fileName, error); + // cppcheck-suppress unreadVariable const QString message = QString("Error: %1 for code=%2").arg(error, listSystems.at(i)); QVERIFY2(result, qUtf8Printable(message)); } @@ -227,6 +228,7 @@ void TST_VMeasurements::ValidPMCodesIndividualFile() QString error; const bool result = m->SaveDocument(fileName, error); + // cppcheck-suppress unreadVariable const QString message = QString("Error: %1 for code=%2").arg(error, listSystems.at(i)); QVERIFY2(result, qUtf8Printable(message)); } diff --git a/src/test/ValentinaTest/tst_vpointf.cpp b/src/test/ValentinaTest/tst_vpointf.cpp index 04a43afd4..b3ab2d72a 100644 --- a/src/test/ValentinaTest/tst_vpointf.cpp +++ b/src/test/ValentinaTest/tst_vpointf.cpp @@ -77,6 +77,7 @@ void TST_VPointF::TestFlip() const VPointF res = originPoint.Flip(axis, prefix); + // cppcheck-suppress unreadVariable const QString errorMsg = QString("The name doesn't contain the prefix '%1'.").arg(prefix); QVERIFY2(res.name().endsWith(prefix), qUtf8Printable(errorMsg)); diff --git a/src/test/ValentinaTest/tst_vspline.cpp b/src/test/ValentinaTest/tst_vspline.cpp index 1689f8602..d03471da9 100644 --- a/src/test/ValentinaTest/tst_vspline.cpp +++ b/src/test/ValentinaTest/tst_vspline.cpp @@ -840,7 +840,8 @@ void TST_VSpline::TestFlip() const VSpline res = spl.Flip(axis, prefix); - const QString errorMsg = QString("The name doesn't contain the prefix '%1'.").arg(prefix); + // cppcheck-suppress unreadVariable + const QString errorMsg = QStringLiteral("The name doesn't contain the prefix '%1'.").arg(prefix); QVERIFY2(res.name().endsWith(prefix), qUtf8Printable(errorMsg)); QCOMPARE(spl.GetLength(), res.GetLength()); diff --git a/src/test/ValentinaTest/tst_vsplinepath.cpp b/src/test/ValentinaTest/tst_vsplinepath.cpp index 90ef7a573..af5495ffa 100644 --- a/src/test/ValentinaTest/tst_vsplinepath.cpp +++ b/src/test/ValentinaTest/tst_vsplinepath.cpp @@ -116,6 +116,7 @@ void TST_VSplinePath::TestRotation() QCOMPARE(rotatedPath.GetLength(), res.GetLength()); QCOMPARE(rotatedPath.CountPoints(), res.CountPoints()); + // cppcheck-suppress unreadVariable const QString errorMsg = QString("The name doesn't contain the prefix '%1'.").arg(prefix); QVERIFY2(res.name().endsWith(prefix), qUtf8Printable(errorMsg)); @@ -188,6 +189,7 @@ void TST_VSplinePath::TestFlip() const VSplinePath splPath(originPoints); const VSplinePath res = splPath.Flip(axis, prefix); + // cppcheck-suppress unreadVariable const QString errorMsg = QStringLiteral("The name doesn't contain the prefix '%1'.").arg(prefix); QVERIFY2(res.name().endsWith(prefix), qUtf8Printable(errorMsg)); diff --git a/src/test/ValentinaTest/tst_vtooluniondetails.cpp b/src/test/ValentinaTest/tst_vtooluniondetails.cpp index 61ff21d18..7177306d5 100644 --- a/src/test/ValentinaTest/tst_vtooluniondetails.cpp +++ b/src/test/ValentinaTest/tst_vtooluniondetails.cpp @@ -161,6 +161,7 @@ void TST_VToolUnionDetails::TestUnitingMainPaths() const VPieceNode resP = result.at(i).second; const VPieceNode outP = out.at(i).second; + // cppcheck-suppress unreadVariable const QString msg = QString("Index: %1. Got item with id = %2, type = %3; Expected item with id = %4, " "type = %5.") .arg(i).arg(outP.GetId()).arg(static_cast(outP.GetTypeTool()))