Unverified Commit 0bc884fc authored by DannyHindson's avatar DannyHindson Committed by GitHub
Browse files

Merge pull request #32531 from DavidFair/cppcheck_cache

Cppcheck cache
parents 3ee31c71 30f7d72e
......@@ -22,6 +22,10 @@ public:
TestDataListener();
~TestDataListener() override;
// Cannot copy the RNG so implicitly we delete ours
TestDataListener(const TestDataListener &) = delete;
TestDataListener &operator=(TestDataListener) = delete;
std::string name() const override { return "TestDataListener"; }
bool supportsHistory() const override { return false; }
bool buffersEvents() const override { return true; }
......
......@@ -190,7 +190,7 @@ void ApplyDetailedBalanceMD::applyDetailedBalance(typename Mantid::DataObjects::
// Add the boxes in parallel. They should be spread out enough on each
// core to avoid stepping on each other.
// cppcheck-suppress syntaxError
PRAGMA_OMP( parallel for if (!ws->isFileBacked()))
for (int i = 0; i < numBoxes; ++i) {
PARALLEL_START_INTERUPT_REGION
......
......@@ -270,7 +270,7 @@ template <typename MDE, size_t nd> void BinMD::binByIterating(typename MDEventWo
// Run the chunks in parallel. There is no overlap in the output workspace so
// it is thread safe to write to it..
// cppcheck-suppress syntaxError
PRAGMA_OMP( parallel for schedule(dynamic,1) if (doParallel) )
for (int chunk = 0; chunk < int(m_binDimensions[chunkDimension]->getNBins()); chunk += chunkNumBins) {
PARALLEL_START_INTERUPT_REGION
......
......@@ -84,7 +84,6 @@ template <typename MDE, size_t nd> void CentroidPeaksMD::integrate(typename MDEv
/// Radius to use around peaks
double PeakRadius = getProperty("PeakRadius");
// cppcheck-suppress syntaxError
PRAGMA_OMP(parallel for schedule(dynamic, 10) )
for (int i = 0; i < int(peakWS->getNumberPeaks()); ++i) {
Peak &p = peakWS->getPeak(i);
......
......@@ -69,7 +69,6 @@ template <typename MDE, size_t nd> void CentroidPeaksMD2::integrate(typename MDE
/// Radius to use around peaks
double PeakRadius = getProperty("PeakRadius");
// cppcheck-suppress syntaxError
PRAGMA_OMP(parallel for schedule(dynamic, 10) )
for (int i = 0; i < int(peakWS->getNumberPeaks()); ++i) {
// Get a direct ref to that peak.
......
......@@ -297,7 +297,6 @@ void CompareMDWorkspaces::compareMDEventWorkspaces(typename MDEventWorkspace<MDE
// segmentation fault is generated on Mac build
bool filebacked = ws1->isFileBacked() || ws2->isFileBacked();
// cppcheck-suppress syntaxError
PRAGMA_OMP( parallel for if (!filebacked))
for (int ibox = 0; ibox < num_boxes; ibox++) {
PARALLEL_START_INTERUPT_REGION
......
......@@ -144,7 +144,7 @@ void DgsScatteredTransmissionCorrectionMD::correctForTransmission(typename MDEve
auto numBoxes = int(boxes.size());
// Add the boxes in parallel. They should be spread out enough on each core to avoid stepping on each other.
// cppcheck-suppress syntaxError
PRAGMA_OMP( parallel for if (!ws->isFileBacked()))
for (int i = 0; i < numBoxes; ++i) {
PARALLEL_START_INTERUPT_REGION
......
......@@ -1523,7 +1523,6 @@ void MDNorm::calculateNormalization(const std::vector<coord_t> &otherValues, con
safe = Kernel::threadSafe(*integrFlux);
}
// cppcheck-suppress syntaxError
PRAGMA_OMP(parallel for private(intersections, xValues, yValues, pos, posNew) if (safe))
for (int64_t i = 0; i < ndets; i++) {
PARALLEL_START_INTERUPT_REGION
......
......@@ -462,7 +462,7 @@ void MDNormDirectSC::calculateNormalization(const std::vector<coord_t> &otherVal
double progStep = 0.7 / m_numExptInfos;
auto prog =
std::make_unique<API::Progress>(this, 0.3 + progStep * expInfoIndex, 0.3 + progStep * (expInfoIndex + 1.), ndets);
// cppcheck-suppress syntaxError
PRAGMA_OMP(parallel for private(intersections, pos, posNew))
for (int64_t i = 0; i < ndets; i++) {
PARALLEL_START_INTERUPT_REGION
......
......@@ -411,7 +411,7 @@ void MDNormSCD::calculateNormalization(const std::vector<coord_t> &otherValues,
double progStep = 0.7 / m_numExptInfos;
auto prog =
std::make_unique<API::Progress>(this, 0.3 + progStep * expInfoIndex, 0.3 + progStep * (expInfoIndex + 1.), ndets);
// cppcheck-suppress syntaxError
PRAGMA_OMP(parallel for private(intersections, xValues, yValues, pos, posNew) if (Kernel::threadSafe(*integrFlux)))
for (int64_t i = 0; i < ndets; i++) {
PARALLEL_START_INTERUPT_REGION
......
......@@ -212,7 +212,7 @@ template <typename MDE, size_t nd> void MergeMD::doPlus(typename MDEventWorkspac
// Add the boxes in parallel. They should be spread out enough on each
// core to avoid stepping on each other.
// cppcheck-suppress syntaxError
PRAGMA_OMP( parallel for if (!ws2->isFileBacked()) )
for (int i = 0; i < numBoxes; i++) {
PARALLEL_START_INTERUPT_REGION
......
......@@ -152,7 +152,7 @@ void PolarizationAngleCorrectionMD::applyPolarizationAngleCorrection(
// Add the boxes in parallel. They should be spread out enough on each
// core to avoid stepping on each other.
// cppcheck-suppress syntaxError
PRAGMA_OMP( parallel for if (!ws->isFileBacked()))
for (int i = 0; i < numBoxes; ++i) {
PARALLEL_START_INTERUPT_REGION
......
......@@ -102,7 +102,6 @@ PyObject *getValue(const Mantid::API::Column_const_sptr &column, const std::type
// -- Use the boost preprocessor to generate a list of else if clause to cut
// out copy and pasted code.
// cppcheck-suppress unreadVariable
PyObject *result(nullptr);
if (false) {
} // So that it always falls through to the list checking
......
......@@ -144,11 +144,12 @@ std::vector<double> getZscoreNumpyDeprecated(const NDArray &data, const bool sor
* arrays,
*/
std::vector<double> getModifiedZscoreNumpy(const NDArray &data, const bool sorted = false) {
UNUSED_ARG(sorted) // We explicitly check in the kernel now
using Converters::NDArrayToVector;
using Mantid::Kernel::getModifiedZscore;
if (isFloatArray(data.ptr())) {
return getModifiedZscore(NDArrayToVector<double>(data)(), sorted);
return getModifiedZscore(NDArrayToVector<double>(data)());
} else {
throw UnknownDataType();
}
......@@ -254,7 +255,7 @@ void export_Statistics() {
.def("getZscore", &getZscoreNumpy, arg("data"), "Determine the Z score for an array of data")
.def("getZscore", &getZscoreNumpyDeprecated, (arg("data"), arg("sorted")),
"Determine the Z score for an array of "
"data (deprecated sorted argument)")
"data (deprecated + ignored sorted argument)")
.staticmethod("getZscore")
.def("getModifiedZscore", &getModifiedZscoreNumpy,
......
......@@ -135,15 +135,12 @@ void export_V3D() {
.def(self * self)
.def(self *= self)
// cppcheck-suppress duplicateExpression
.def(self / self)
// cppcheck-suppress duplicateExpression
.def(self /= self)
.def(self * int())
.def(self *= int())
.def(self * double())
.def(self *= double())
// cppcheck-suppress duplicateExpression
.def(self < self)
.def(self == self)
.def(self != self) // must define != as Python's default is to compare
......
......@@ -103,9 +103,7 @@ void export_VMD() {
.def("__isub__", &VMD::operator-=, return_self<>(), (arg("self"), arg("other")))
.def(self * self)
.def(self *= self)
// cppcheck-suppress duplicateExpression
.def(self / self)
// cppcheck-suppress duplicateExpression
.def(self /= self);
}
......
......@@ -5,13 +5,16 @@ if ( CPPCHECK_EXECUTABLE )
# We must export the compile commands for cppcheck to be able to check
# everything correctly
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
configure_file(${CMAKE_SOURCE_DIR}/buildconfig/CMake/CppCheck_Suppressions.txt.in ${CMAKE_BINARY_DIR}/CppCheck_Suppressions.txt)
set ( CPPCHECK_BUILD_DIR "${CMAKE_BINARY_DIR}/cppcheck" )
file(MAKE_DIRECTORY "${CPPCHECK_BUILD_DIR}" "${CPPCHECK_BUILD_DIR}/cache")
configure_file(${CMAKE_SOURCE_DIR}/buildconfig/CMake/CppCheck_Suppressions.txt.in "${CPPCHECK_BUILD_DIR}/CppCheck_Suppressions.txt")
# setup the standard arguments
# --inline-suppr appears to be ignored if --suppresions-list is specified
set ( CPPCHECK_ARGS --enable=all --inline-suppr --max-configs=120
--std=c++${CMAKE_CXX_STANDARD} # use the standard from cmake
--suppressions-list=${CMAKE_BINARY_DIR}/CppCheck_Suppressions.txt
--cppcheck-build-dir="${CPPCHECK_BUILD_DIR}/cache"
--suppressions-list="${CPPCHECK_BUILD_DIR}/CppCheck_Suppressions.txt"
--project=${CMAKE_BINARY_DIR}/compile_commands.json
# Force cppcheck to check when we use project-wide macros
-DDLLExport=
......@@ -30,9 +33,9 @@ if ( CPPCHECK_EXECUTABLE )
# put the finishing bits on the final command call
set (_cppcheck_xml_args)
if (CPPCHECK_GENERATE_XML)
list( APPEND _cppcheck_xml_args --xml --xml-version=2 ${_cppcheck_source_dirs} 2> ${CMAKE_BINARY_DIR}/cppcheck.xml )
list( APPEND _cppcheck_xml_args --xml --xml-version=2 "${_cppcheck_source_dirs}" 2> ${CMAKE_BINARY_DIR}/cppcheck.xml )
else (CPPCHECK_GENERATE_XML)
list( APPEND _cppcheck_xml_args ${_cppcheck_source_dirs} )
list( APPEND _cppcheck_xml_args "${_cppcheck_source_dirs}" )
endif (CPPCHECK_GENERATE_XML)
......@@ -41,7 +44,7 @@ if ( CPPCHECK_EXECUTABLE )
if (NOT TARGET cppcheck)
add_custom_target ( cppcheck
COMMAND ${CPPCHECK_EXECUTABLE} ${_cppcheck_args} ${_cppcheck_xml_args}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
COMMENT "Running cppcheck"
)
set_target_properties(cppcheck PROPERTIES EXCLUDE_FROM_ALL TRUE)
......
......@@ -11,6 +11,10 @@ noExplicitConstructor
// Hide warnings about shadowed members for inheritance. Typically "m_log" with Algorithm
duplInheritedMember
// Hide unused functions, cppcheck does not consider headers, so many Qt overrides
// called by Qt will be marked as unused
unusedFunction
// We have some potentially uninitialized member vars but too many to fix at the moment
uninitMemberVar
......@@ -20,45 +24,12 @@ noConstructor
// Pre-processor Directives, such as #error, which are upstream anyway
preprocessorErrorDirective
// ---------- cppcheck 1.90 Transition -------
unmatchedSuppression
// If-init not supported
syntaxError:${CMAKE_SOURCE_DIR}/Framework/API/src/MatrixWorkspace.cpp
// --- To be added back ------
//cstyleCase:*${CMAKE_SOURCE_DIR}/MantidPlot
// A large number of copying instead of pass by ref were picked up by clang-tidy, but around 200 remain
//passedByValue
// Cppcheck struggles with some inheritance chains, some of these might be true though
unusedPrivateFunction
// Nice to have, not need to have at the moment
//useInitializationList
// Libs we have in-source
// *:${CMAKE_SOURCE_DIR}/Framework/DataObjects/inc/MantidDataObjects/MortonIndex/*
// ---------- Individual suppressions -----------------
pureVirtualCall:${CMAKE_SOURCE_DIR}/qt/scientific_interfaces/Indirect/IndirectBayesTab.cpp
pureVirtualCall:${CMAKE_SOURCE_DIR}/qt/scientific_interfaces/Indirect/IndirectBayesTab.h
// Macro expansion means this is incorrectly flagged on Unix
redundantAssignment:${CMAKE_SOURCE_DIR}/Framework/DataHandling/src/LoadRaw/isisraw.cpp
// Ref binding means Cppcheck can't see these are used
unreadVariable:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/MaskBinsIf.cpp
// the mru-list is intentionally not altered
operatorEqVarError:${CMAKE_SOURCE_DIR}/Framework/DataObjects/src/EventList.cpp:309
// false positives from checking a second time using a mutex for multi-threading
identicalConditionAfterEarlyExit:${CMAKE_SOURCE_DIR}/Framework/DataObjects/src/EventList.cpp:950
identicalConditionAfterEarlyExit:${CMAKE_SOURCE_DIR}/Framework/DataObjects/src/EventList.cpp:1016
identicalConditionAfterEarlyExit:${CMAKE_SOURCE_DIR}/Framework/DataObjects/src/EventList.cpp:1046
// --------- Missing copy assignment / constructors -------------------
// We don't want more creeping in so just mark these one by one
......@@ -92,8 +63,3 @@ noCopyConstructor:${CMAKE_SOURCE_DIR}/Framework/Geometry/inc/MantidGeometry/Rend
// All ANN files as they are upstream anyway
*:*${CMAKE_SOURCE_DIR}/Framework/Kernel/src/ANN/*
// Libs we have in-source
*:${CMAKE_SOURCE_DIR}/Framework/ICat/src/GSoap/*
*:${CMAKE_SOURCE_DIR}/Framework/ICat/src/ICat3/GSoapGenerated/*
*:${CMAKE_SOURCE_DIR}/Framework/ICat/src/ICat4/GSoapGenerated/*
......@@ -4,7 +4,7 @@ SCRIPT_DIR=$(dirname "$0")
# If errors slip through to master this can be used to set a non-zero
# allowed count while those errors are dealt with. This avoids breaking all
# builds for all developers
ALLOWED_ERRORS_COUNT=1095
ALLOWED_ERRORS_COUNT=1069
if [[ ${JOB_NAME} == *pull_requests* ]]; then
# This relies on the fact pull requests use pull/$PR-NAME
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment