Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cppcheck suppresions set 59 #38747

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be an issue with cppcheck not being able to find boost macros, will create an issue for it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that situation occurred for us as well.

BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(getEulerAngles_overloads, Goniometer::getEulerAngles, 0, 1)
GNU_DIAG_ON("conversion")
GNU_DIAG_ON("unused-local-typedef")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ void export_Instrument() {
"represents the source")

.def("getComponentByName",
// cppcheck-suppress cstyleCast
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cstylecast used in all such exports, suspect it is not worth changing them all under the scope of this hackathon. Will raise an issue.

(std::shared_ptr<const IComponent>(Instrument::*)(const std::string &, int) const) &
Instrument::getComponentByName,
(arg("self"), arg("cname"), arg("nlevels") = 0), "Returns the named :class:`~mantid.geometry.Component`")

.def("getDetector",
// cppcheck-suppress cstyleCast
(std::shared_ptr<const IDetector>(Instrument::*)(const detid_t &) const) & Instrument::getDetector,
(arg("self"), arg("detector_id")), "Returns the :class:`~mantid.geometry.Detector` with the given ID")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}`.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ template <> std::string dtype(ArrayProperty<std::string> &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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<InstrumentInfo>(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")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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<IPropertySettings>(settingsManager->clone()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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); }
Expand Down
15 changes: 0 additions & 15 deletions buildconfig/CMake/CppCheck_Suppressions.txt.in
Original file line number Diff line number Diff line change
Expand Up @@ -818,21 +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
adriazalvarez marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down