From b539fe69ccd0a149f85a2c107d82c5e55ef53706 Mon Sep 17 00:00:00 2001 From: adriazalvarez Date: Wed, 29 Jan 2025 13:38:46 +0000 Subject: [PATCH 1/3] commit suppresions 1-7 --- .../mantid/geometry/src/Exports/Goniometer.cpp | 1 + .../mantid/geometry/src/Exports/Instrument.cpp | 2 ++ .../mantid/geometry/src/Exports/MeshObject.cpp | 2 +- .../mantid/geometry/src/Exports/ReflectionGenerator.cpp | 2 +- .../mantid/geometry/src/Exports/UnitCell.cpp | 1 + .../mantid/kernel/src/Exports/ArrayProperty.cpp | 2 +- buildconfig/CMake/CppCheck_Suppressions.txt.in | 7 ------- 7 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Framework/PythonInterface/mantid/geometry/src/Exports/Goniometer.cpp b/Framework/PythonInterface/mantid/geometry/src/Exports/Goniometer.cpp index e63906ec314c..cf654ad81e6c 100644 --- a/Framework/PythonInterface/mantid/geometry/src/Exports/Goniometer.cpp +++ b/Framework/PythonInterface/mantid/geometry/src/Exports/Goniometer.cpp @@ -28,6 +28,7 @@ GNU_DIAG_OFF("unused-local-typedef") // Seen with GCC 7.1.1 and Boost 1.63.0 GNU_DIAG_OFF("conversion") // define overloaded functions +// cppcheck-suppress unknownMacro BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(getEulerAngles_overloads, Goniometer::getEulerAngles, 0, 1) GNU_DIAG_ON("conversion") GNU_DIAG_ON("unused-local-typedef") diff --git a/Framework/PythonInterface/mantid/geometry/src/Exports/Instrument.cpp b/Framework/PythonInterface/mantid/geometry/src/Exports/Instrument.cpp index fa902b1e8ddd..3877d0348879 100644 --- a/Framework/PythonInterface/mantid/geometry/src/Exports/Instrument.cpp +++ b/Framework/PythonInterface/mantid/geometry/src/Exports/Instrument.cpp @@ -46,6 +46,7 @@ void export_Instrument() { "represents the source") .def("getComponentByName", + // cppcheck-suppress cstyleCast (std::shared_ptr(Instrument::*)(const std::string &, int) const) & Instrument::getComponentByName, (arg("self"), arg("cname"), arg("nlevels") = 0), "Returns the named :class:`~mantid.geometry.Component`") @@ -58,6 +59,7 @@ void export_Instrument() { Instrument_getNumberDetectors((arg("self"), arg("skipMonitors") = false))) .def("getReferenceFrame", + // cppcheck-suppress cstyleCast (std::shared_ptr(Instrument::*)()) & Instrument::getReferenceFrame, arg("self"), return_value_policy(), "Returns the :class:`~mantid.geometry.ReferenceFrame` attached that " diff --git a/Framework/PythonInterface/mantid/geometry/src/Exports/MeshObject.cpp b/Framework/PythonInterface/mantid/geometry/src/Exports/MeshObject.cpp index 8ca68573e99d..f6c296df54fd 100644 --- a/Framework/PythonInterface/mantid/geometry/src/Exports/MeshObject.cpp +++ b/Framework/PythonInterface/mantid/geometry/src/Exports/MeshObject.cpp @@ -26,7 +26,7 @@ using namespace boost::python; GET_POINTER_SPECIALIZATION(MeshObject) -boost::python::object wrapMeshWithNDArray(MeshObject &self) { +boost::python::object wrapMeshWithNDArray(const MeshObject &self) { // PyArray_SimpleNewFromData doesn't interact well with smart pointers so use raw pointer const auto &vertices = self.getV3Ds(); const auto &triangles = self.getTriangles(); diff --git a/Framework/PythonInterface/mantid/geometry/src/Exports/ReflectionGenerator.cpp b/Framework/PythonInterface/mantid/geometry/src/Exports/ReflectionGenerator.cpp index 8e703bc23dc2..ad1396ceaeda 100644 --- a/Framework/PythonInterface/mantid/geometry/src/Exports/ReflectionGenerator.cpp +++ b/Framework/PythonInterface/mantid/geometry/src/Exports/ReflectionGenerator.cpp @@ -37,7 +37,7 @@ boost::python::list getUniqueHKLsDefaultFilter(const ReflectionGenerator &self, return getListFromV3DVector(self.getUniqueHKLs(dMin, dMax)); } -boost::python::list getUniqueHKLsUsingFilter(ReflectionGenerator &self, double dMin, double dMax, +boost::python::list getUniqueHKLsUsingFilter(const ReflectionGenerator &self, double dMin, double dMax, ReflectionConditionFilter filter) { return getListFromV3DVector(self.getUniqueHKLs(dMin, dMax, self.getReflectionConditionFilter(std::move(filter)))); } diff --git a/Framework/PythonInterface/mantid/geometry/src/Exports/UnitCell.cpp b/Framework/PythonInterface/mantid/geometry/src/Exports/UnitCell.cpp index c68a0daa8079..a7a5e0344f44 100644 --- a/Framework/PythonInterface/mantid/geometry/src/Exports/UnitCell.cpp +++ b/Framework/PythonInterface/mantid/geometry/src/Exports/UnitCell.cpp @@ -172,6 +172,7 @@ void export_UnitCell() { (arg("self"), arg("h"), arg("k"), arg("l")), "Returns :math:`d`-spacing for a given H, K, L coordinate in " ":math:`\\rm{\\AA}`.") + // cppcheck-suppress cstyleCast .def("d", (double(UnitCell::*)(const V3D &) const) & UnitCell::d, (arg("self"), arg("hkl")), "Returns :math:`d`-spacing for a given H, K, L coordinate in " ":math:`\\rm{\\AA}`.") diff --git a/Framework/PythonInterface/mantid/kernel/src/Exports/ArrayProperty.cpp b/Framework/PythonInterface/mantid/kernel/src/Exports/ArrayProperty.cpp index c923238084e6..e4aa9bb3671d 100644 --- a/Framework/PythonInterface/mantid/kernel/src/Exports/ArrayProperty.cpp +++ b/Framework/PythonInterface/mantid/kernel/src/Exports/ArrayProperty.cpp @@ -49,7 +49,7 @@ template <> std::string dtype(ArrayProperty &self) { // Loop for the number of strings // For each string store the number of characters - for (auto val : values) { + for (auto const &val : values) { auto size = val.size(); stringSizes.emplace_back(size); } diff --git a/buildconfig/CMake/CppCheck_Suppressions.txt.in b/buildconfig/CMake/CppCheck_Suppressions.txt.in index d3a18b8fa53e..b248730ed409 100644 --- a/buildconfig/CMake/CppCheck_Suppressions.txt.in +++ b/buildconfig/CMake/CppCheck_Suppressions.txt.in @@ -818,13 +818,6 @@ unknownMacro:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Export constParameterCallback:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/WorkspaceGroup.cpp:80 unusedScopedObject:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/WorkspaceGroup.cpp:113 syntaxError:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/dataobjects/src/Exports/EventList.cpp:37 -unknownMacro:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/geometry/src/Exports/Goniometer.cpp:31 -cstyleCast:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/geometry/src/Exports/Instrument.cpp:49 -cstyleCast:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/geometry/src/Exports/Instrument.cpp:54 -constParameterCallback:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/geometry/src/Exports/MeshObject.cpp:29 -constParameterCallback:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/geometry/src/Exports/ReflectionGenerator.cpp:40 -cstyleCast:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/geometry/src/Exports/UnitCell.cpp:175 -iterateByValue:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/kernel/src/Exports/ArrayProperty.cpp:52 unknownMacro:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/kernel/src/Exports/ConfigService.cpp:73 cstyleCast:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/kernel/src/Exports/FacilityInfo.cpp:46 constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/kernel/src/Exports/IPropertyManager.cpp:46 From 78e86f0f2741bddc506b74a2375db14e1f923623 Mon Sep 17 00:00:00 2001 From: adriazalvarez Date: Wed, 29 Jan 2025 13:54:23 +0000 Subject: [PATCH 2/3] fix suppresed line position --- .../PythonInterface/mantid/geometry/src/Exports/Instrument.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Framework/PythonInterface/mantid/geometry/src/Exports/Instrument.cpp b/Framework/PythonInterface/mantid/geometry/src/Exports/Instrument.cpp index 3877d0348879..0e883c92a9c0 100644 --- a/Framework/PythonInterface/mantid/geometry/src/Exports/Instrument.cpp +++ b/Framework/PythonInterface/mantid/geometry/src/Exports/Instrument.cpp @@ -52,6 +52,7 @@ void export_Instrument() { (arg("self"), arg("cname"), arg("nlevels") = 0), "Returns the named :class:`~mantid.geometry.Component`") .def("getDetector", + // cppcheck-suppress cstyleCast (std::shared_ptr(Instrument::*)(const detid_t &) const) & Instrument::getDetector, (arg("self"), arg("detector_id")), "Returns the :class:`~mantid.geometry.Detector` with the given ID") @@ -59,7 +60,6 @@ void export_Instrument() { Instrument_getNumberDetectors((arg("self"), arg("skipMonitors") = false))) .def("getReferenceFrame", - // cppcheck-suppress cstyleCast (std::shared_ptr(Instrument::*)()) & Instrument::getReferenceFrame, arg("self"), return_value_policy(), "Returns the :class:`~mantid.geometry.ReferenceFrame` attached that " From df46dbac106ce01c8f8b1a80caa92ac9ee250488 Mon Sep 17 00:00:00 2001 From: Waruna Wickramasingha Date: Mon, 10 Feb 2025 13:29:38 +0000 Subject: [PATCH 3/3] set59 cppcheck fixes --- .../mantid/kernel/src/Exports/ConfigService.cpp | 1 + .../mantid/kernel/src/Exports/FacilityInfo.cpp | 1 + .../mantid/kernel/src/Exports/IPropertyManager.cpp | 5 +++-- .../mantid/kernel/src/Exports/Property.cpp | 6 ++---- .../PythonInterface/mantid/kernel/src/Exports/Quat.cpp | 1 + .../mantid/kernel/src/Exports/Statistics.cpp | 1 + .../mantid/kernel/src/Exports/TimeSeriesProperty.cpp | 1 + buildconfig/CMake/CppCheck_Suppressions.txt.in | 8 -------- 8 files changed, 10 insertions(+), 14 deletions(-) diff --git a/Framework/PythonInterface/mantid/kernel/src/Exports/ConfigService.cpp b/Framework/PythonInterface/mantid/kernel/src/Exports/ConfigService.cpp index 94bcdc36478c..dc370e99b8dc 100644 --- a/Framework/PythonInterface/mantid/kernel/src/Exports/ConfigService.cpp +++ b/Framework/PythonInterface/mantid/kernel/src/Exports/ConfigService.cpp @@ -70,6 +70,7 @@ GNU_DIAG_OFF("unused-local-typedef") // Seen with GCC 7.1.1 and Boost 1.63.0 GNU_DIAG_OFF("conversion") // Overload generator for getInstrument +// cppcheck-suppress unknownMacro BOOST_PYTHON_FUNCTION_OVERLOADS(getInstrument_Overload, getInstrument, 1, 2) // Overload generator for getString BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(getString_Overload, ConfigServiceImpl::getString, 1, 2) diff --git a/Framework/PythonInterface/mantid/kernel/src/Exports/FacilityInfo.cpp b/Framework/PythonInterface/mantid/kernel/src/Exports/FacilityInfo.cpp index 73b85052360b..0af7a28ddb66 100644 --- a/Framework/PythonInterface/mantid/kernel/src/Exports/FacilityInfo.cpp +++ b/Framework/PythonInterface/mantid/kernel/src/Exports/FacilityInfo.cpp @@ -43,6 +43,7 @@ void export_FacilityInfo() { "Returns a list of instruments of this facility as defined in the " "Facilities.xml file") .def("instruments", + // cppcheck-suppress cstyleCast (std::vector(FacilityInfo::*)(const std::string &) const) & FacilityInfo::instruments, (arg("self"), arg("technique")), "Returns a list of instruments of given technique") .def("instrument", &FacilityInfo::instrument, (arg("self"), arg("instrumentName")), diff --git a/Framework/PythonInterface/mantid/kernel/src/Exports/IPropertyManager.cpp b/Framework/PythonInterface/mantid/kernel/src/Exports/IPropertyManager.cpp index f7898f451777..9c807aa43549 100644 --- a/Framework/PythonInterface/mantid/kernel/src/Exports/IPropertyManager.cpp +++ b/Framework/PythonInterface/mantid/kernel/src/Exports/IPropertyManager.cpp @@ -43,7 +43,7 @@ void setProperty(IPropertyManager &self, const std::string &name, const boost::p self.setPropertyValue(name, valuecpp()); } else { try { - Property *p = self.getProperty(name); + const Property *p = self.getProperty(name); const auto &entry = Registry::TypeRegistry::retrieve(*(p->type_info())); entry.set(&self, name, value); } catch (std::invalid_argument &e) { @@ -99,7 +99,8 @@ void declareOrSetProperty(IPropertyManager &self, const std::string &name, const * @param propName A property name that will pick up the settings manager * @param settingsManager The actual settings object */ -void setPropertySettings(IPropertyManager &self, const std::string &propName, IPropertySettings *settingsManager) { +void setPropertySettings(IPropertyManager &self, const std::string &propName, + const IPropertySettings *settingsManager) { self.setPropertySettings(propName, std::unique_ptr(settingsManager->clone())); } diff --git a/Framework/PythonInterface/mantid/kernel/src/Exports/Property.cpp b/Framework/PythonInterface/mantid/kernel/src/Exports/Property.cpp index 5b197178cc38..dc71f2c37b83 100644 --- a/Framework/PythonInterface/mantid/kernel/src/Exports/Property.cpp +++ b/Framework/PythonInterface/mantid/kernel/src/Exports/Property.cpp @@ -98,10 +98,8 @@ GNU_DIAG_OFF("unused-local-typedef") // Ignore -Wconversion warnings coming from boost::python // Seen with GCC 7.1.1 and Boost 1.63.0 GNU_DIAG_OFF("conversion") - -BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(valueAsPrettyStrOverloader, - - valueAsPrettyStr, 0, 2) +// cppcheck-suppress unknownMacro +BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(valueAsPrettyStrOverloader, valueAsPrettyStr, 0, 2) GNU_DIAG_ON("conversion") GNU_DIAG_ON("unused-local-typedef") diff --git a/Framework/PythonInterface/mantid/kernel/src/Exports/Quat.cpp b/Framework/PythonInterface/mantid/kernel/src/Exports/Quat.cpp index 3b09c7ad930b..fd4734d7e91c 100644 --- a/Framework/PythonInterface/mantid/kernel/src/Exports/Quat.cpp +++ b/Framework/PythonInterface/mantid/kernel/src/Exports/Quat.cpp @@ -52,6 +52,7 @@ void export_Quat() { .def("len2", &Quat::len2, arg("self"), "Returns the square of the 'length' of the quaternion") .def("getEulerAngles", &Quat::getEulerAngles, (arg("self"), arg("convention") = "YZX"), "Default convention is \'YZX\'.") + // cppcheck-suppress syntaxError .def("__add__", &Quat::operator+, (arg("left"), arg("right"))) .def("__iadd__", &Quat::operator+=, boost::python::return_self<>(), (arg("self"), arg("other"))) .def("__sub__", &Quat::operator-, (arg("left"), arg("right"))) diff --git a/Framework/PythonInterface/mantid/kernel/src/Exports/Statistics.cpp b/Framework/PythonInterface/mantid/kernel/src/Exports/Statistics.cpp index c7240ef6ad5a..67f9027c8a9f 100644 --- a/Framework/PythonInterface/mantid/kernel/src/Exports/Statistics.cpp +++ b/Framework/PythonInterface/mantid/kernel/src/Exports/Statistics.cpp @@ -106,6 +106,7 @@ GNU_DIAG_OFF("unused-local-typedef") GNU_DIAG_OFF("conversion") // Define an overload to handle the default argument +// cppcheck-suppress unknownMacro BOOST_PYTHON_FUNCTION_OVERLOADS(getStatisticsOverloads, getStatisticsNumpy, 1, 2) GNU_DIAG_ON("conversion") GNU_DIAG_ON("unused-local-typedef") diff --git a/Framework/PythonInterface/mantid/kernel/src/Exports/TimeSeriesProperty.cpp b/Framework/PythonInterface/mantid/kernel/src/Exports/TimeSeriesProperty.cpp index 0980af7abd47..869377417a45 100644 --- a/Framework/PythonInterface/mantid/kernel/src/Exports/TimeSeriesProperty.cpp +++ b/Framework/PythonInterface/mantid/kernel/src/Exports/TimeSeriesProperty.cpp @@ -131,6 +131,7 @@ GNU_DIAG_ON("conversion") // Ignore -Wconversion warnings coming from boost::python // Seen with GCC 7.1.1 and Boost 1.63.0 GNU_DIAG_OFF("conversion") +// cppcheck-suppress unknownMacro BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(getStatistics_overloads, getStatistics, 0, 1) void export_TimeSeriesProperty_Double() { EXPORT_TIMESERIES_PROP(double, Float); } diff --git a/buildconfig/CMake/CppCheck_Suppressions.txt.in b/buildconfig/CMake/CppCheck_Suppressions.txt.in index b248730ed409..917e18a52e50 100644 --- a/buildconfig/CMake/CppCheck_Suppressions.txt.in +++ b/buildconfig/CMake/CppCheck_Suppressions.txt.in @@ -818,14 +818,6 @@ unknownMacro:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Export constParameterCallback:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/WorkspaceGroup.cpp:80 unusedScopedObject:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/WorkspaceGroup.cpp:113 syntaxError:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/dataobjects/src/Exports/EventList.cpp:37 -unknownMacro:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/kernel/src/Exports/ConfigService.cpp:73 -cstyleCast:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/kernel/src/Exports/FacilityInfo.cpp:46 -constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/kernel/src/Exports/IPropertyManager.cpp:46 -constParameterCallback:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/kernel/src/Exports/IPropertyManager.cpp:102 -unknownMacro:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/kernel/src/Exports/Property.cpp:102 -syntaxError:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/kernel/src/Exports/Quat.cpp:55 -unknownMacro:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/kernel/src/Exports/Statistics.cpp:109 -unknownMacro:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/kernel/src/Exports/TimeSeriesProperty.cpp:134 syntaxError:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/kernel/src/Exports/V3D.cpp:123 syntaxError:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/kernel/src/Exports/VMD.cpp:100 unknownMacro:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/test/testhelpers/WorkspaceCreationHelper/WorkspaceCreationHelperModule.cpp:35