diff --git a/Framework/Muon/inc/MantidMuon/PlotAsymmetryByLogValue.h b/Framework/Muon/inc/MantidMuon/PlotAsymmetryByLogValue.h index fa8d6381f8b3..c03470faa242 100644 --- a/Framework/Muon/inc/MantidMuon/PlotAsymmetryByLogValue.h +++ b/Framework/Muon/inc/MantidMuon/PlotAsymmetryByLogValue.h @@ -86,7 +86,7 @@ class MANTID_MUON_DLL PlotAsymmetryByLogValue final : public API::Algorithm { /// Group detectors void groupDetectors(API::MatrixWorkspace_sptr &ws, const std::vector &spectraList); /// Get log value - double getLogValue(API::MatrixWorkspace &ws); + double getLogValue(const API::MatrixWorkspace &ws); /// Populate output workspace with results void populateOutputWorkspace(API::MatrixWorkspace_sptr &outWS, int nplots, const std::string &units); /// get log units diff --git a/Framework/Muon/src/LoadMuonNexus2.cpp b/Framework/Muon/src/LoadMuonNexus2.cpp index 7acf586bc19b..c1e2a489864a 100644 --- a/Framework/Muon/src/LoadMuonNexus2.cpp +++ b/Framework/Muon/src/LoadMuonNexus2.cpp @@ -84,7 +84,7 @@ void LoadMuonNexus2::exec() { } // Need to extract the user-defined output workspace name - Property *ws = getProperty("OutputWorkspace"); + const Property *ws = getProperty("OutputWorkspace"); std::string localWSName = ws->value(); // If multiperiod, will need to hold the Instrument & Sample for copying std::shared_ptr instrument; diff --git a/Framework/Muon/src/PlotAsymmetryByLogValue.cpp b/Framework/Muon/src/PlotAsymmetryByLogValue.cpp index 391e03e4ecb2..064712c3d9e1 100644 --- a/Framework/Muon/src/PlotAsymmetryByLogValue.cpp +++ b/Framework/Muon/src/PlotAsymmetryByLogValue.cpp @@ -213,7 +213,7 @@ const std::string PlotAsymmetryByLogValue::getLogUnits(const std::string &fileNa ws = std::dynamic_pointer_cast(group->getItem(m_red - 1)); } const Run &run = ws->run(); - auto property = run.getLogData(m_logName); + const auto *property = run.getLogData(m_logName); return property->units(); } @@ -449,7 +449,7 @@ void PlotAsymmetryByLogValue::populateOutputWorkspace(MatrixWorkspace_sptr &outW auto tAxis = std::make_unique(nplots); if (nplots == 1) { size_t i = 0; - for (auto &value : m_logValue) { + for (const auto &value : m_logValue) { outWS->mutableX(0)[i] = value.second; outWS->mutableY(0)[i] = m_redY[value.first]; outWS->mutableE(0)[i] = m_redE[value.first]; @@ -459,7 +459,7 @@ void PlotAsymmetryByLogValue::populateOutputWorkspace(MatrixWorkspace_sptr &outW } else { size_t i = 0; - for (auto &value : m_logValue) { + for (const auto &value : m_logValue) { outWS->mutableX(0)[i] = value.second; outWS->mutableY(0)[i] = m_diffY[value.first]; outWS->mutableE(0)[i] = m_diffE[value.first]; @@ -494,7 +494,7 @@ void PlotAsymmetryByLogValue::saveResultsToADS(MatrixWorkspace_sptr &outWS, int if (nplots == 2) { size_t i = 0; - for (auto &value : m_logValue) { + for (const auto &value : m_logValue) { size_t run = value.first; outWS->mutableX(0)[i] = static_cast(run); // run number outWS->mutableY(0)[i] = value.second; // log value @@ -504,7 +504,7 @@ void PlotAsymmetryByLogValue::saveResultsToADS(MatrixWorkspace_sptr &outWS, int } } else { size_t i = 0; - for (auto &value : m_logValue) { + for (const auto &value : m_logValue) { size_t run = value.first; outWS->mutableX(0)[i] = static_cast(run); // run number outWS->mutableY(0)[i] = value.second; // log value @@ -865,7 +865,7 @@ void PlotAsymmetryByLogValue::calcIntAsymmetry(const MatrixWorkspace_sptr &ws_re * @throw :: std::invalid_argument if the log cannot be converted to a double or *doesn't exist. */ -double PlotAsymmetryByLogValue::getLogValue(MatrixWorkspace &ws) { +double PlotAsymmetryByLogValue::getLogValue(const MatrixWorkspace &ws) { const Run &run = ws.run(); const auto &runROI = run.getTimeROI(); diff --git a/Framework/NexusGeometry/src/NexusShapeFactory.cpp b/Framework/NexusGeometry/src/NexusShapeFactory.cpp index 86b18ac903a4..7fb547b16ce4 100644 --- a/Framework/NexusGeometry/src/NexusShapeFactory.cpp +++ b/Framework/NexusGeometry/src/NexusShapeFactory.cpp @@ -30,7 +30,7 @@ namespace { /// Finalise shape std::unique_ptr createCylinderShape(const std::map> &surfaces, const std::string &algebra, - std::vector &boundingBox, Geometry::detail::ShapeInfo &&shapeInfo) { + const std::vector &boundingBox, Geometry::detail::ShapeInfo &&shapeInfo) { auto shape = std::make_unique(); shape->setObject(21, algebra); shape->populate(surfaces); diff --git a/Framework/Parallel/inc/MantidParallel/IO/EventsListsShmemStorage.h b/Framework/Parallel/inc/MantidParallel/IO/EventsListsShmemStorage.h index 016d70742a3b..8e20a1602b91 100644 --- a/Framework/Parallel/inc/MantidParallel/IO/EventsListsShmemStorage.h +++ b/Framework/Parallel/inc/MantidParallel/IO/EventsListsShmemStorage.h @@ -29,7 +29,6 @@ class MANTID_PARALLEL_DLL EventsListsShmemStorage : public EventsListsShmemManag public: EventsListsShmemStorage(const std::string &segmentName, const std::string &elName, size_t size, size_t chunksCnt, size_t pixelsCount); - virtual ~EventsListsShmemStorage() = default; void reserve(std::size_t chunkN, std::size_t pixelN, std::size_t size); diff --git a/Framework/PythonInterface/core/inc/MantidPythonInterface/core/DataServiceExporter.h b/Framework/PythonInterface/core/inc/MantidPythonInterface/core/DataServiceExporter.h index 7c557ab8f071..3b7b9bcf5328 100644 --- a/Framework/PythonInterface/core/inc/MantidPythonInterface/core/DataServiceExporter.h +++ b/Framework/PythonInterface/core/inc/MantidPythonInterface/core/DataServiceExporter.h @@ -157,12 +157,12 @@ template struct DataServiceExporter { * @return A shared_ptr to the named object. If the name does not exist it * sets a KeyError error indicator. */ - static WeakPtr retrieveOrKeyError(SvcType &self, const std::string &name) { + static WeakPtr retrieveOrKeyError(const SvcType *const self, const std::string &name) { using namespace Mantid::Kernel; SvcPtrType item; try { - item = self.retrieve(name); + item = self->retrieve(name); } catch (Exception::NotFoundError &) { // Translate into a Python KeyError std::string err = "'" + name + "' does not exist."; diff --git a/Framework/PythonInterface/core/inc/MantidPythonInterface/core/IsNone.h b/Framework/PythonInterface/core/inc/MantidPythonInterface/core/IsNone.h index 8d9a222ece49..cfb713566e2b 100644 --- a/Framework/PythonInterface/core/inc/MantidPythonInterface/core/IsNone.h +++ b/Framework/PythonInterface/core/inc/MantidPythonInterface/core/IsNone.h @@ -23,7 +23,7 @@ namespace PythonInterface { * @param ptr A * to a raw PyObject * @returns true if the given object is of type None */ -inline bool isNone(PyObject *ptr) { return (ptr == Py_None); } +inline bool isNone(const PyObject *ptr) { return (ptr == Py_None); } /** * @param obj A const reference to boost python object wrapper diff --git a/Framework/PythonInterface/core/src/Converters/CloneToNDArray.cpp b/Framework/PythonInterface/core/src/Converters/CloneToNDArray.cpp index d6e67ba6fb65..54499a904460 100644 --- a/Framework/PythonInterface/core/src/Converters/CloneToNDArray.cpp +++ b/Framework/PythonInterface/core/src/Converters/CloneToNDArray.cpp @@ -120,6 +120,10 @@ template PyObject *cloneND(const ElementType *carray, con * @param dims :: The length of the arrays in each dimension * @return */ +// cppcheck-suppress constParameterPointer +// Suppressed because one of the cloneND overloads calls +// PyArray_NewFromDescrclasses inside NumpyFunctions::func_PyArray_NewFromDescr, which +// requires the dim parameter to be non-const. template <> PyObject *cloneND(const std::string *carray, const int ndims, Py_intptr_t *dims) { boost::python::list pystrs; const std::string *iter = carray; diff --git a/Framework/PythonInterface/core/src/Converters/NDArrayToVector.cpp b/Framework/PythonInterface/core/src/Converters/NDArrayToVector.cpp index 54126201363c..bb809120de5e 100644 --- a/Framework/PythonInterface/core/src/Converters/NDArrayToVector.cpp +++ b/Framework/PythonInterface/core/src/Converters/NDArrayToVector.cpp @@ -123,7 +123,7 @@ NDArrayToVector::NDArrayToVector(const NDArray &value) : m_arr( */ template typename NDArrayToVector::TypedVector NDArrayToVector::operator()() { - std::vector cvector(PyArray_SIZE((PyArrayObject *)m_arr.ptr())); + std::vector cvector(PyArray_SIZE(reinterpret_cast(m_arr.ptr()))); copyTo(cvector); return cvector; } @@ -134,9 +134,9 @@ typename NDArrayToVector::TypedVector NDArrayToVector void NDArrayToVector::copyTo(TypedVector &dest) const { - if (PyArray_SIZE((PyArrayObject *)m_arr.ptr()) > 0) { + if (PyArray_SIZE(reinterpret_cast(m_arr.ptr())) > 0) { throwIfSizeMismatched(dest); - CopyToImpl()(std::begin(dest), (PyArrayObject *)m_arr.ptr()); + CopyToImpl()(std::begin(dest), reinterpret_cast(m_arr.ptr())); } } diff --git a/buildconfig/CMake/CppCheck_Suppressions.txt.in b/buildconfig/CMake/CppCheck_Suppressions.txt.in index 82adf19757a8..3d0964c89d37 100644 --- a/buildconfig/CMake/CppCheck_Suppressions.txt.in +++ b/buildconfig/CMake/CppCheck_Suppressions.txt.in @@ -638,21 +638,6 @@ missingOverride:${CMAKE_SOURCE_DIR}/Framework/Muon/inc/MantidMuon/MuonGroupingCo missingOverride:${CMAKE_SOURCE_DIR}/Framework/Muon/inc/MantidMuon/MuonPairingAsymmetry.h:22 missingOverride:${CMAKE_SOURCE_DIR}/Framework/Muon/inc/MantidMuon/MuonPreProcess.h:23 variableScope:${CMAKE_SOURCE_DIR}/Framework/Muon/src/EstimateMuonAsymmetryFromCounts.cpp:157 -constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/Muon/src/LoadMuonNexus2.cpp:87 -constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/Muon/src/PlotAsymmetryByLogValue.cpp:216 -constVariableReference:${CMAKE_SOURCE_DIR}/Framework/Muon/src/PlotAsymmetryByLogValue.cpp:452 -constVariableReference:${CMAKE_SOURCE_DIR}/Framework/Muon/src/PlotAsymmetryByLogValue.cpp:462 -constVariableReference:${CMAKE_SOURCE_DIR}/Framework/Muon/src/PlotAsymmetryByLogValue.cpp:497 -constVariableReference:${CMAKE_SOURCE_DIR}/Framework/Muon/src/PlotAsymmetryByLogValue.cpp:507 -constParameterReference:${CMAKE_SOURCE_DIR}/Framework/Muon/src/PlotAsymmetryByLogValue.cpp:868 -constParameterReference:${CMAKE_SOURCE_DIR}/Framework/NexusGeometry/src/NexusShapeFactory.cpp:33 -missingOverride:${CMAKE_SOURCE_DIR}/Framework/Parallel/inc/MantidParallel/IO/EventsListsShmemStorage.h:32 -constParameterCallback:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/core/inc/MantidPythonInterface/core/DataServiceExporter.h:160 -constParameterPointer:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/core/inc/MantidPythonInterface/core/IsNone.h:26 -constParameterPointer:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/core/src/Converters/CloneToNDArray.cpp:123 -cstyleCast:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/core/src/Converters/NDArrayToVector.cpp:126 -cstyleCast:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/core/src/Converters/NDArrayToVector.cpp:137 -cstyleCast:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/core/src/Converters/NDArrayToVector.cpp:139 cstyleCast:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/core/src/Converters/NDArrayToVector.cpp:151 cstyleCast:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/core/src/Converters/NDArrayToVector.cpp:156 cstyleCast:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/core/src/Converters/PyObjectToMatrix.cpp:44