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 suppressions set 56 #38744

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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 @@ -124,8 +124,10 @@ GNU_DIAG_OFF("unused-local-typedef")
// Seen with GCC 7.1.1 and Boost 1.63.0
GNU_DIAG_OFF("conversion")
/// Define overload generators
// cppcheck-suppress unknownMacro
BOOST_PYTHON_FUNCTION_OVERLOADS(create_overloads, create, 2, 3)
BOOST_PYTHON_FUNCTION_OVERLOADS(createUnmanaged_overloads, createUnmanaged, 2, 3)

GNU_DIAG_ON("conversion")
GNU_DIAG_ON("unused-local-typedef")
///@endcond
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace {
* @param direction An output/input/inout property
* @return A pointer to a new AlgorithmProperty object
*/
AlgorithmProperty *createPropertyWithValidatorAndDirection(const std::string &name, IValidator *validator,
AlgorithmProperty *createPropertyWithValidatorAndDirection(const std::string &name, const IValidator *validator,
unsigned int direction) {
return new AlgorithmProperty(name, validator->clone(), direction);
}
Expand All @@ -39,9 +39,10 @@ AlgorithmProperty *createPropertyWithValidatorAndDirection(const std::string &na
* when passed to the framework
* @return A pointer to a new AlgorithmProperty object
*/
AlgorithmProperty *createPropertyWithValidator(const std::string &name, IValidator *validator) {
static const AlgorithmProperty *(*const createPropertyWithValidator)(const std::string &, const IValidator *) =
+[](const std::string &name, const IValidator *validator) -> const AlgorithmProperty * {
return createPropertyWithValidatorAndDirection(name, validator, Mantid::Kernel::Direction::Input);
}
};
} // namespace

void export_AlgorithmProperty() {
Expand All @@ -54,7 +55,7 @@ void export_AlgorithmProperty() {
.def(init<const std::string &>(args("name")))
// These variants require the validator object to be cloned
.def("__init__",
make_constructor(&createPropertyWithValidator, default_call_policies(), args("name", "validator")))
make_constructor(createPropertyWithValidator, default_call_policies(), args("name", "validator")))
.def("__init__", make_constructor(&createPropertyWithValidatorAndDirection, default_call_policies(),
args("name", "validator", "direction")));
}
1 change: 1 addition & 0 deletions Framework/PythonInterface/mantid/api/src/Exports/Axis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ GNU_DIAG_OFF("unused-local-typedef")
GNU_DIAG_OFF("conversion")

// Overloads for operator() function which has 1 optional argument
// cppcheck-suppress unknownMacro
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Axis_getValue, Axis::getValue, 1, 2)

GNU_DIAG_ON("conversion")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,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 getInstrumentFilename
// cppcheck-suppress unknownMacro
BOOST_PYTHON_FUNCTION_OVERLOADS(getInstrumentFilename_Overload, getInstrumentFilenameWarn, 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 @@ -221,7 +221,7 @@ std::string createDocString(const IAlgorithm &self) {
buffer << "Property descriptions: " << EOL << EOL;
// write the actual property descriptions
for (size_t i = 0; i < numProps; ++i) {
Mantid::Kernel::Property *prop = properties[i];
const Mantid::Kernel::Property *prop = properties[i];
buffer << prop->name() << "(" << Mantid::Kernel::Direction::asText(prop->direction());
if (!prop->isValid().empty())
buffer << ":req";
Expand Down Expand Up @@ -251,7 +251,7 @@ std::string createDocString(const IAlgorithm &self) {
struct AllowCThreads {
explicit AllowCThreads(const object &algm)
: m_tracefunc(nullptr), m_tracearg(nullptr), m_saved(nullptr), m_tracking(false) {
PyThreadState *curThreadState = PyThreadState_GET();
const PyThreadState *curThreadState = PyThreadState_GET();
m_tracefunc = curThreadState->c_tracefunc;
m_tracearg = curThreadState->c_traceobj;
Py_XINCREF(m_tracearg);
Expand Down Expand Up @@ -315,8 +315,7 @@ PyObject *getAlgorithmID(const IAlgorithm &self) {
AlgorithmID id = self.getAlgorithmID();
if (id)
return to_python_value<AlgorithmIDProxy>()(AlgorithmIDProxy(id));
else
Py_RETURN_NONE;
return Py_NewRef(Py_None);
}

//--------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ void export_IEventList() {
"Mask out events that have a tof between tofMin and tofMax "
"(inclusively)")
.def("maskCondition", &maskCondition, args("self", "mask"), "Mask out events by the condition vector")
.def("getTofs", (std::vector<double>(IEventList::*)(void) const) & IEventList::getTofs, args("self"),
.def("getTofs", (std::vector<double>(IEventList::*)() const) & IEventList::getTofs, args("self"),
return_clone_numpy(), "Get a vector of the TOFs of the events")
.def("getWeights", (std::vector<double>(IEventList::*)(void) const) & IEventList::getWeights, args("self"),
.def("getWeights", (std::vector<double>(IEventList::*)() const) & IEventList::getWeights, args("self"),
return_clone_numpy(), "Get a vector of the weights of the events")
.def("getWeightErrors", (std::vector<double>(IEventList::*)() const) & IEventList::getWeightErrors, args("self"),
return_clone_numpy(), "Get a vector of the weights of the events")
.def("getWeightErrors", (std::vector<double>(IEventList::*)(void) const) & IEventList::getWeightErrors,
args("self"), return_clone_numpy(), "Get a vector of the weights of the events")
.def("getPulseTimes", &IEventList::getPulseTimes, args("self"), "Get a vector of the pulse times of the events")
.def("getPulseTimesAsNumpy",
make_function(&IEventList::getPulseTimes, return_value_policy<Policies::VectorToNumpy>()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(declareAttributeType1_Overloads, declareA
using declareAttributeType2 = void (IFunctionAdapter::*)(const std::string &name,
const boost::python::object &defaultValue,
const boost::python::object &validator);
// cppcheck-suppress unknownMacro
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(declareAttributeType2_Overloads, declareAttribute, 3, 3)

BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(tie_Overloads, tie, 2, 3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ void export_IFunction1D() {
*/
class_<IFunction1D, bases<IFunction>, std::shared_ptr<IFunction1DAdapter>, boost::noncopyable>(
"IFunction1D", "Base class for 1D Fit functions")
// suppress c-style cast of Function1D object - think this is desired behaviour
// cppcheck-suppress cstyleCast
.def("function1D", (object(IFunction1DAdapter::*)(const object &) const)&IFunction1DAdapter::function1D,
(arg("self"), arg("xvals")),
"Calculate the values of the function for the given x values and "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ void export_IMaskWorkspace() {
.def("isMasked", isMaskedFromList, (arg("self"), arg("detector_id_list")),
"Returns whether all of the given detector ID list are masked");

// register pointers
// register pointers - required to map between C++ type T and python type
// cppcheck-suppress unusedScopedObject
RegisterWorkspacePtrToPython<IMaskWorkspace>();
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ using namespace boost::python;
void export_IPeakFunction() {

register_ptr_to_python<std::shared_ptr<IPeakFunction>>();

class_<IPeakFunction, bases<IFunction1D>, std::shared_ptr<IPeakFunctionAdapter>, boost::noncopyable>(
"IPeakFunction", "Base class for peak Fit functions")
// suppress c-style cast of IPeakFunction object - think this is desired behaviour
// cppcheck-suppress cstyleCast
.def("functionLocal", (object(IPeakFunctionAdapter::*)(const object &) const)&IPeakFunctionAdapter::functionLocal,
(arg("self"), arg("vec_x")),
"Calculate the values of the function for the given x values. The "
Expand Down
9 changes: 0 additions & 9 deletions buildconfig/CMake/CppCheck_Suppressions.txt.in
Original file line number Diff line number Diff line change
Expand Up @@ -837,20 +837,11 @@ constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/sr
unknownMacro:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/Algorithm.cpp:76
unknownMacro:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmFactory.cpp:155
unknownMacro:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmManager.cpp:127
constParameterCallback:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmProperty.cpp:30
unknownMacro:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/Axis.cpp:44
unknownMacro:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/ExperimentInfo.cpp:57
constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/IAlgorithm.cpp:224
constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/IAlgorithm.cpp:254
missingReturn:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/IAlgorithm.cpp:319
cstyleCast:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/IEventList.cpp:75
cstyleCast:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/IEventList.cpp:77
cstyleCast:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/IEventList.cpp:79
unknownMacro:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/IFunction.cpp:150
cstyleCast:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/IFunction1D.cpp:23
cstyleCast:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/IMDHistoWorkspace.cpp:50
unusedScopedObject:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/IMaskWorkspace.cpp:45
cstyleCast:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/IPeakFunction.cpp:23
unusedScopedObject:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/ISplittersWorkspace.cpp:25
unknownMacro:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/ITableWorkspace.cpp:251
unknownMacro:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/InstrumentFileFinder.cpp:36
Expand Down