From e7f3fc38e10cef5dd2c793a1f0201c5d45e6d73b Mon Sep 17 00:00:00 2001
From: Steven Hahn <hahnse@ornl.gov>
Date: Wed, 4 Jan 2017 21:47:47 -0500
Subject: [PATCH] Fix issues found with cppcheck 1.77

---
 .../src/DiffractionEventCalibrateDetectors.cpp   |  3 +--
 .../src/GetTimeSeriesLogInformation.cpp          |  7 +------
 .../Crystal/src/IntegratePeakTimeSlices.cpp      | 16 ----------------
 .../CurveFitting/src/Algorithms/LeBailFit.cpp    |  3 +--
 .../RefinePowderInstrumentParameters3.cpp        |  2 --
 .../src/CostFunctions/CostFuncFitting.cpp        |  2 --
 .../src/ImggAggregateWavelengths.cpp             |  4 ++--
 Framework/DataHandling/src/LoadDetectorInfo.cpp  |  2 ++
 Framework/DataHandling/src/LoadNexusLogs.cpp     |  3 ---
 Framework/DataHandling/src/LoadTBL.cpp           |  3 ---
 .../src/ModifyDetectorDotDatFile.cpp             |  4 ----
 Framework/DataHandling/src/SaveNXTomo.cpp        |  3 ---
 .../DataHandling/src/SaveToSNSHistogramNexus.cpp |  4 +---
 Framework/Geometry/src/Crystal/IndexingUtils.cpp |  2 --
 Framework/Geometry/src/Objects/Object.cpp        |  2 --
 Framework/Kernel/src/DeltaEMode.cpp              |  2 --
 Framework/Kernel/src/PropertyManager.cpp         |  2 --
 Framework/Kernel/src/TimeSeriesProperty.cpp      |  1 +
 .../src/ConvertCWSDExpToMomentum.cpp             |  3 +--
 Framework/Nexus/src/MuonNexusReader.cpp          |  2 --
 MantidPlot/src/Graph.cpp                         |  2 --
 MantidPlot/src/SetColValuesDialog.cpp            |  3 +++
 MantidQt/MantidWidgets/src/PropertyHandler.cpp   |  3 +--
 MantidQt/SliceViewer/src/SliceViewer.cpp         |  3 +--
 Vates/VatesAPI/src/vtkSplatterPlotFactory.cpp    | 12 +++---------
 .../src/RebinAlgorithmDialogProvider.cpp         |  4 +---
 26 files changed, 19 insertions(+), 78 deletions(-)

diff --git a/Framework/Algorithms/src/DiffractionEventCalibrateDetectors.cpp b/Framework/Algorithms/src/DiffractionEventCalibrateDetectors.cpp
index f4b9a526b8e..28fddc32801 100644
--- a/Framework/Algorithms/src/DiffractionEventCalibrateDetectors.cpp
+++ b/Framework/Algorithms/src/DiffractionEventCalibrateDetectors.cpp
@@ -408,7 +408,6 @@ void DiffractionEventCalibrateDetectors::exec() {
     std::cout << tim << " to CreateGroupingWorkspace\n";
 
     const gsl_multimin_fminimizer_type *T = gsl_multimin_fminimizer_nmsimplex;
-    gsl_multimin_fminimizer *s = nullptr;
     gsl_vector *ss, *x;
     gsl_multimin_function minex_func;
 
@@ -436,7 +435,7 @@ void DiffractionEventCalibrateDetectors::exec() {
     minex_func.f = &Mantid::Algorithms::gsl_costFunction;
     minex_func.params = &par;
 
-    s = gsl_multimin_fminimizer_alloc(T, nopt);
+    gsl_multimin_fminimizer *s = gsl_multimin_fminimizer_alloc(T, nopt);
     gsl_multimin_fminimizer_set(s, &minex_func, x, ss);
 
     do {
diff --git a/Framework/Algorithms/src/GetTimeSeriesLogInformation.cpp b/Framework/Algorithms/src/GetTimeSeriesLogInformation.cpp
index e4356839281..c6a1ad414e5 100644
--- a/Framework/Algorithms/src/GetTimeSeriesLogInformation.cpp
+++ b/Framework/Algorithms/src/GetTimeSeriesLogInformation.cpp
@@ -302,7 +302,6 @@ void GetTimeSeriesLogInformation::exportErrorLog(MatrixWorkspace_sptr ws,
   std::ofstream ofs;
   ofs.open(ofilename.c_str(), std::ios::out);
 
-  size_t numbaddt = 0;
   Kernel::DateAndTime t0(ws->run().getProperty("run_start")->value());
 
   for (size_t i = 1; i < abstimevec.size(); i++) {
@@ -310,12 +309,8 @@ void GetTimeSeriesLogInformation::exportErrorLog(MatrixWorkspace_sptr ws,
                                          abstimevec[i - 1].totalNanoseconds()) *
                      1.0E-9;
     double dev = (tempdts - dts) / dts;
-    bool baddt = false;
-    if (fabs(dev) > 0.5)
-      baddt = true;
 
-    if (baddt) {
-      numbaddt++;
+    if (fabs(dev) > 0.5) {
       double deltapulsetimeSec1 =
           static_cast<double>(abstimevec[i - 1].totalNanoseconds() -
                               t0.totalNanoseconds()) *
diff --git a/Framework/Crystal/src/IntegratePeakTimeSlices.cpp b/Framework/Crystal/src/IntegratePeakTimeSlices.cpp
index 1d7cce4ce18..233e13cf0b7 100644
--- a/Framework/Crystal/src/IntegratePeakTimeSlices.cpp
+++ b/Framework/Crystal/src/IntegratePeakTimeSlices.cpp
@@ -1335,10 +1335,6 @@ void DataModeHandler::setHeightHalfWidthInfo(
   double offset = std::max<double>(.2, (maxCount - minCount) / 20);
   double TotR_max = 0;
   double TotR_min = 0;
-  int nedge1Cells = 0;
-  int nintCells = 0;
-  int nBoundEdge1Cells = 0;
-  int nBoundIntCells = 0;
   double TotRx0 = 0;
   double TotRy0 = 0;
   double TotCx = 0;
@@ -1361,16 +1357,6 @@ void DataModeHandler::setHeightHalfWidthInfo(
                               (Y[i] - MaxY) * (Y[i] - MaxY));
     }
 
-    if (X[i] >= lowX && X[i] <= highX && Y[i] >= lowY && Y[i] <= highY) {
-      nedge1Cells++;
-      if (C[i] < minCount + offset)
-        nBoundEdge1Cells++;
-    }
-    if (fabs(MaxX - X[i]) < IntOffset && fabs(MaxY - Y[i]) < IntOffset) {
-      nintCells++;
-      if (C[i] < minCount + offset)
-        nBoundIntCells++;
-    }
     if (fabs(MaxY - Y[i]) < 1.2 && fabs(MaxX - X[i]) > 1.2 &&
         C[i] >= CountLow && C[i] <= CountUp && fabs(MaxX - X[i]) < dSpanx) {
       TotRx0 += (C[i] - minCount) * (X[i] - MaxX) * (X[i] - MaxX);
@@ -1578,7 +1564,6 @@ void IntegratePeakTimeSlices::SetUpData1(
   int nBoundaryCells = 0;
   double TotBoundaryVariances = 0;
 
-  int N = 0;
   double BoundaryRadius = min<double>(
       .90 * Radius, Radius - 1.5 * max<double>(m_cellWidth, m_cellHeight));
   double minRow = 20000, maxRow = -1, minCol = 20000, maxCol = -1;
@@ -1633,7 +1618,6 @@ void IntegratePeakTimeSlices::SetUpData1(
           variance += histoerrs[chan] * histoerrs[chan];
         }
 
-        N++;
         yvalB.push_back(intensity);
         double sigma = 1;
 
diff --git a/Framework/CurveFitting/src/Algorithms/LeBailFit.cpp b/Framework/CurveFitting/src/Algorithms/LeBailFit.cpp
index bf9914cf6e1..a0c4ed162b0 100644
--- a/Framework/CurveFitting/src/Algorithms/LeBailFit.cpp
+++ b/Framework/CurveFitting/src/Algorithms/LeBailFit.cpp
@@ -1406,8 +1406,7 @@ void LeBailFit::createOutputDataWorkspace() {
   // 4. Set axis
   m_outputWS->getAxis(0)->setUnit("TOF");
 
-  API::TextAxis *tAxis = nullptr;
-  tAxis = new API::TextAxis(nspec);
+  API::TextAxis *tAxis = new API::TextAxis(nspec);
   tAxis->setLabel(0, "Data");
   tAxis->setLabel(1, "Calc");
   tAxis->setLabel(2, "Diff");
diff --git a/Framework/CurveFitting/src/Algorithms/RefinePowderInstrumentParameters3.cpp b/Framework/CurveFitting/src/Algorithms/RefinePowderInstrumentParameters3.cpp
index 69288d58376..0e7aec07c44 100644
--- a/Framework/CurveFitting/src/Algorithms/RefinePowderInstrumentParameters3.cpp
+++ b/Framework/CurveFitting/src/Algorithms/RefinePowderInstrumentParameters3.cpp
@@ -375,7 +375,6 @@ double RefinePowderInstrumentParameters3::doSimulatedAnnealing(
 
   // 3. Monte Carlo starts
   double chisqx = chisq0;
-  int numtotalacceptance = 0;
   int numrecentacceptance = 0;
   int numrecentsteps = 0;
 
@@ -420,7 +419,6 @@ double RefinePowderInstrumentParameters3::doSimulatedAnnealing(
       }
 
       // e) MC strategy control
-      ++numtotalacceptance;
       ++numrecentacceptance;
       ++numrecentsteps;
     }
diff --git a/Framework/CurveFitting/src/CostFunctions/CostFuncFitting.cpp b/Framework/CurveFitting/src/CostFunctions/CostFuncFitting.cpp
index 5385275d165..aaa5aef879b 100644
--- a/Framework/CurveFitting/src/CostFunctions/CostFuncFitting.cpp
+++ b/Framework/CurveFitting/src/CostFunctions/CostFuncFitting.cpp
@@ -131,14 +131,12 @@ void CostFuncFitting::calCovarianceMatrix(GSLMatrix &covar, double epsrel) {
   size_t np = m_function->nParams();
 
   bool isTransformationIdentity = true;
-  size_t ii = 0;
   for (size_t i = 0; i < np; ++i) {
     if (!m_function->isActive(i))
       continue;
     isTransformationIdentity =
         isTransformationIdentity &&
         (m_function->activeParameter(i) == m_function->getParameter(i));
-    ++ii;
   }
 
   if (isTransformationIdentity) {
diff --git a/Framework/DataHandling/src/ImggAggregateWavelengths.cpp b/Framework/DataHandling/src/ImggAggregateWavelengths.cpp
index 3d85d49a950..3b1bd81eb31 100644
--- a/Framework/DataHandling/src/ImggAggregateWavelengths.cpp
+++ b/Framework/DataHandling/src/ImggAggregateWavelengths.cpp
@@ -743,10 +743,10 @@ bool ImggAggregateWavelengths::isSupportedExtension(
   const std::vector<std::string> formatExtensionsShort{"fit"};
   const std::vector<std::string> formatExtensionsLong{"fits"};
 
-  bool found = (formatExtensionsShort.end() !=
+  bool found = (formatExtensionsShort.cend() !=
                 std::find(formatExtensionsShort.cbegin(),
                           formatExtensionsShort.cend(), extShort)) ||
-               (formatExtensionsLong.end() !=
+               (formatExtensionsLong.cend() !=
                 std::find(formatExtensionsLong.cbegin(),
                           formatExtensionsLong.cend(), extLong));
   return found;
diff --git a/Framework/DataHandling/src/LoadDetectorInfo.cpp b/Framework/DataHandling/src/LoadDetectorInfo.cpp
index e72c71f5ef9..332325caa18 100644
--- a/Framework/DataHandling/src/LoadDetectorInfo.cpp
+++ b/Framework/DataHandling/src/LoadDetectorInfo.cpp
@@ -310,11 +310,13 @@ void LoadDetectorInfo::readLibisisNxs(::NeXus::File &nxsFile,
   nxsFile.readData<double>("gas_pressure", pressure);
   nxsFile.readData<double>("wall_thickness", thickness);
   nxsFile.closeGroup();
+  // cppcheck-suppress knownConditionTrueFalse
   if (pressure <= 0.0) {
     g_log.warning("The data file does not contain correct He3 pressure, "
                   "default value of 10 bar is used instead");
     pressure = 10.0;
   }
+  // cppcheck-suppress knownConditionTrueFalse
   if (thickness <= 0.0) {
     g_log.warning("The data file does not contain correct detector's wall "
                   "thickness, default value of 0.8mm is used instead");
diff --git a/Framework/DataHandling/src/LoadNexusLogs.cpp b/Framework/DataHandling/src/LoadNexusLogs.cpp
index de96a1ff276..339c3b467ca 100644
--- a/Framework/DataHandling/src/LoadNexusLogs.cpp
+++ b/Framework/DataHandling/src/LoadNexusLogs.cpp
@@ -391,9 +391,6 @@ void LoadNexusLogs::loadLogs(
       loadNXLog(file, itr->first, log_class, workspace);
     } else if (log_class == "IXseblock") {
       loadSELog(file, itr->first, workspace);
-    } else if (log_class == "NXcollection") {
-      int jj = 0;
-      ++jj;
     }
   }
   loadVetoPulses(file, workspace);
diff --git a/Framework/DataHandling/src/LoadTBL.cpp b/Framework/DataHandling/src/LoadTBL.cpp
index 2e357abae96..0bb459acbb7 100644
--- a/Framework/DataHandling/src/LoadTBL.cpp
+++ b/Framework/DataHandling/src/LoadTBL.cpp
@@ -130,7 +130,6 @@ void LoadTBL::csvParse(std::string line, std::vector<std::string> &cols,
                        std::vector<std::vector<size_t>> &quoteBounds,
                        size_t expectedCommas) const {
   size_t pairID = 0;
-  size_t valsFound = 0;
   size_t lastComma = 0;
   size_t pos = 0;
   bool firstCheck = true;
@@ -153,7 +152,6 @@ void LoadTBL::csvParse(std::string line, std::vector<std::string> &cols,
                                      quoteBounds.at(pairID).at(1) -
                                          (quoteBounds.at(pairID).at(0) + 1)));
           ++pairID;
-          ++valsFound;
         }
       } else {
         if (firstCell) {
@@ -163,7 +161,6 @@ void LoadTBL::csvParse(std::string line, std::vector<std::string> &cols,
           auto colVal = line.substr(lastComma + 1, pos - (lastComma + 1));
           cols.push_back(line.substr(lastComma + 1, pos - (lastComma + 1)));
         }
-        ++valsFound;
       }
       lastComma = pos;
     } else {
diff --git a/Framework/DataHandling/src/ModifyDetectorDotDatFile.cpp b/Framework/DataHandling/src/ModifyDetectorDotDatFile.cpp
index 9112b6a1abc..21f440fdd90 100644
--- a/Framework/DataHandling/src/ModifyDetectorDotDatFile.cpp
+++ b/Framework/DataHandling/src/ModifyDetectorDotDatFile.cpp
@@ -100,9 +100,6 @@ void ModifyDetectorDotDatFile::exec() {
   // Copy column title line
   getline(in, str);
   out << str << "\n";
-
-  int i = 0;
-
   // Format details
   int pOffset = 3; // Precision of Offset
   int pOther = 5;  // Precision of Other floats
@@ -159,7 +156,6 @@ void ModifyDetectorDotDatFile::exec() {
         std::string prefix = oss.str();
         std::string suffix = str.substr(width, std::string::npos);
         out << prefix << suffix << "\n";
-        i++;
       } catch (std::out_of_range &) { // Detector not found, don't modify
         out << str << "\n";
       }
diff --git a/Framework/DataHandling/src/SaveNXTomo.cpp b/Framework/DataHandling/src/SaveNXTomo.cpp
index 134e8ebf033..ea46a1b95e3 100644
--- a/Framework/DataHandling/src/SaveNXTomo.cpp
+++ b/Framework/DataHandling/src/SaveNXTomo.cpp
@@ -369,9 +369,6 @@ void SaveNXTomo::writeSingleWorkspace(const Workspace2D_sptr workspace,
   writeLogValues(workspace, nxFile, numFiles);
   writeIntensityValue(workspace, nxFile, numFiles);
   writeImageKeyValue(workspace, nxFile, numFiles);
-
-  ++numFiles;
-
   delete[] dataArr;
 }
 
diff --git a/Framework/DataHandling/src/SaveToSNSHistogramNexus.cpp b/Framework/DataHandling/src/SaveToSNSHistogramNexus.cpp
index 67c9dc75f64..5cc7dd9dbd6 100644
--- a/Framework/DataHandling/src/SaveToSNSHistogramNexus.cpp
+++ b/Framework/DataHandling/src/SaveToSNSHistogramNexus.cpp
@@ -647,7 +647,7 @@ int SaveToSNSHistogramNexus::WriteGroup(int is_definition) {
 int SaveToSNSHistogramNexus::WriteAttributes(int is_definition) {
   (void)is_definition;
 
-  int status, i, attrLen, attrType;
+  int status, attrLen, attrType;
 #ifndef NEXUS43
   int rank;
   int dims[4];
@@ -655,7 +655,6 @@ int SaveToSNSHistogramNexus::WriteAttributes(int is_definition) {
   NXname attrName;
   void *attrBuffer;
 
-  i = 0;
   do {
 #ifdef NEXUS43
     status = NXgetnextattr(inId, attrName, &attrLen, &attrType);
@@ -684,7 +683,6 @@ int SaveToSNSHistogramNexus::WriteAttributes(int is_definition) {
         if (NXfree(&attrBuffer) != NX_OK)
           return NX_ERROR;
       }
-      i++;
     }
   } while (status != NX_EOD);
   return NX_OK;
diff --git a/Framework/Geometry/src/Crystal/IndexingUtils.cpp b/Framework/Geometry/src/Crystal/IndexingUtils.cpp
index 318e8058865..676619bb1fe 100644
--- a/Framework/Geometry/src/Crystal/IndexingUtils.cpp
+++ b/Framework/Geometry/src/Crystal/IndexingUtils.cpp
@@ -165,9 +165,7 @@ double IndexingUtils::Find_UB(DblMatrix &UB, const std::vector<V3D> &q_vectors,
   // now gradually bring in the remaining
   // peaks and re-optimize the UB to index
   // them as well
-  size_t count = 0;
   while (!fixAll && num_initial < sorted_qs.size()) {
-    count++;
     num_initial = std::lround(1.5 * static_cast<double>(num_initial + 3));
     // add 3, in case we started with
     // a very small number of peaks!
diff --git a/Framework/Geometry/src/Objects/Object.cpp b/Framework/Geometry/src/Objects/Object.cpp
index d3237b51f77..ae4818b0615 100644
--- a/Framework/Geometry/src/Objects/Object.cpp
+++ b/Framework/Geometry/src/Objects/Object.cpp
@@ -262,7 +262,6 @@ int Object::hasComplement() const {
 int Object::populate(const std::map<int, boost::shared_ptr<Surface>> &Smap) {
   std::deque<Rule *> Rst;
   Rst.push_back(TopRule.get());
-  int Rcount(0);
   while (!Rst.empty()) {
     Rule *T1 = Rst.front();
     Rst.pop_front();
@@ -274,7 +273,6 @@ int Object::populate(const std::map<int, boost::shared_ptr<Surface>> &Smap) {
         auto mf = Smap.find(KV->getKeyN());
         if (mf != Smap.end()) {
           KV->setKey(mf->second);
-          Rcount++;
         } else {
           throw Kernel::Exception::NotFoundError("Object::populate",
                                                  KV->getKeyN());
diff --git a/Framework/Kernel/src/DeltaEMode.cpp b/Framework/Kernel/src/DeltaEMode.cpp
index 5a9181b96c2..e802a147dde 100644
--- a/Framework/Kernel/src/DeltaEMode.cpp
+++ b/Framework/Kernel/src/DeltaEMode.cpp
@@ -32,12 +32,10 @@ const std::vector<std::string> DeltaEMode::availableTypes() {
   const ModeIndex &lookup = typeStringLookup();
   std::vector<std::string> modes;
   modes.reserve(lookup.index.size());
-  size_t index(0);
   for (const auto &iter : lookup.index) {
     if (iter.first == DeltaEMode::Undefined)
       continue;
     modes.push_back(iter.second);
-    ++index;
   }
   return modes;
 }
diff --git a/Framework/Kernel/src/PropertyManager.cpp b/Framework/Kernel/src/PropertyManager.cpp
index 11c59cf54bf..a61700e8e71 100644
--- a/Framework/Kernel/src/PropertyManager.cpp
+++ b/Framework/Kernel/src/PropertyManager.cpp
@@ -351,7 +351,6 @@ void PropertyManager::setPropertiesWithSimpleString(
   boost::char_separator<char> sep(";");
   tokenizer propPairs(propertiesString, ";",
                       Mantid::Kernel::StringTokenizer::TOK_TRIM);
-  int index = 0;
   // Iterate over the properties
   for (const auto &pair : propPairs) {
     size_t n = pair.find('=');
@@ -372,7 +371,6 @@ void PropertyManager::setPropertiesWithSimpleString(
       // Set it
       propertyJson[propName] = value;
     }
-    index++;
   }
   setProperties(propertyJson, ignoreProperties);
 }
diff --git a/Framework/Kernel/src/TimeSeriesProperty.cpp b/Framework/Kernel/src/TimeSeriesProperty.cpp
index 4f079f3a1d1..898f13ed8f9 100644
--- a/Framework/Kernel/src/TimeSeriesProperty.cpp
+++ b/Framework/Kernel/src/TimeSeriesProperty.cpp
@@ -2289,6 +2289,7 @@ TimeSeriesProperty<TYPE>::getSplittingIntervals() const {
   size_t index = 0;
   while (index < m_filter.size()) {
     DateAndTime start, stop;
+    // cppcheck-suppress knownConditionTrueFalse
     if (index == 0) {
       if (m_filter[0].second) {
         start = m_filter[0].first;
diff --git a/Framework/MDAlgorithms/src/ConvertCWSDExpToMomentum.cpp b/Framework/MDAlgorithms/src/ConvertCWSDExpToMomentum.cpp
index 5d631601941..bb767538aaa 100644
--- a/Framework/MDAlgorithms/src/ConvertCWSDExpToMomentum.cpp
+++ b/Framework/MDAlgorithms/src/ConvertCWSDExpToMomentum.cpp
@@ -245,6 +245,7 @@ void ConvertCWSDExpToMomentum::addMDEvents(bool usevirtual) {
 
     if (isWindows && *m_dataDir.rbegin() != '\\') {
       sep = "\\";
+      // cppcheck-suppress knownConditionTrueFalse
     } else if (!isWindows && *m_dataDir.rbegin() != '/')
       sep = "/";
   }
@@ -255,7 +256,6 @@ void ConvertCWSDExpToMomentum::addMDEvents(bool usevirtual) {
     g_log.warning("There are more than 1 experiment to import. "
                   "Make sure that all of them have the same instrument.");
   }
-  size_t numFileNotLoaded(0);
 
   // Loop through all data files in the experiment
   for (size_t ir = 0; ir < numrows; ++ir) {
@@ -279,7 +279,6 @@ void ConvertCWSDExpToMomentum::addMDEvents(bool usevirtual) {
     spicews = loadSpiceData(filename, loaded, errmsg);
     if (!loaded) {
       g_log.error(errmsg);
-      ++numFileNotLoaded;
       continue;
     }
     if (m_removeBackground) {
diff --git a/Framework/Nexus/src/MuonNexusReader.cpp b/Framework/Nexus/src/MuonNexusReader.cpp
index eb509e51478..8b70f026931 100644
--- a/Framework/Nexus/src/MuonNexusReader.cpp
+++ b/Framework/Nexus/src/MuonNexusReader.cpp
@@ -175,7 +175,6 @@ string MuonNexusReader::getInstrumentName() const {
 void MuonNexusReader::readLogData(const string &filename) {
   // reset the count of logs
   nexusLogCount = 0;
-  int nexusSampleCount = 0; // debug
 
   NeXus::File handle(filename, NXACC_READ);
   openFirstNXentry(handle);
@@ -203,7 +202,6 @@ void MuonNexusReader::readLogData(const string &filename) {
       handle.openGroup(nxname, nxclass);
       handle.readData("name", nexus_samplename);
       handle.closeGroup();
-      nexusSampleCount++; // debug
     }
     if (nxname == START_TIME) {
       handle.readData(START_TIME, startTime);
diff --git a/MantidPlot/src/Graph.cpp b/MantidPlot/src/Graph.cpp
index ffb3cc405c8..f0b393b600b 100644
--- a/MantidPlot/src/Graph.cpp
+++ b/MantidPlot/src/Graph.cpp
@@ -4384,10 +4384,8 @@ void Graph::copy(Graph *g) {
       if (pie)
         pie->addLabel(dynamic_cast<PieLabel *>(t), true);
       else
-        // cppcheck-suppress leakReturnValNotUsed
         insertText(t);
     } else
-      // cppcheck-suppress leakReturnValNotUsed
       insertText(t);
   }
 
diff --git a/MantidPlot/src/SetColValuesDialog.cpp b/MantidPlot/src/SetColValuesDialog.cpp
index fac8cbe2eef..fc58c61f7c2 100644
--- a/MantidPlot/src/SetColValuesDialog.cpp
+++ b/MantidPlot/src/SetColValuesDialog.cpp
@@ -68,6 +68,9 @@ SetColValuesDialog::SetColValuesDialog(ScriptingEnv *env, Table *t,
   end->setMinimum(1);
   hbox1->addWidget(end);
 
+  // Ideally this would be checked at compile time. Until we have 'constexpr if`
+  // on all platforms, the added complexity and minimal cost isn't worthwhile.
+  // cppcheck-suppress knownConditionTrueFalse
   if (sizeof(int) == 2) { // 16 bit signed integer
     start->setMaximum(0x7fff);
     end->setMaximum(0x7fff);
diff --git a/MantidQt/MantidWidgets/src/PropertyHandler.cpp b/MantidQt/MantidWidgets/src/PropertyHandler.cpp
index 370f86eec31..15e60bc50cf 100644
--- a/MantidQt/MantidWidgets/src/PropertyHandler.cpp
+++ b/MantidQt/MantidWidgets/src/PropertyHandler.cpp
@@ -136,8 +136,7 @@ public:
 protected:
   /// Create string property
   QtProperty *apply(const std::string &str) const override {
-    QtProperty *prop = NULL;
-    prop = m_browser->addStringProperty(m_name);
+    QtProperty *prop = m_browser->addStringProperty(m_name);
     m_browser->setStringPropertyValue(prop, QString::fromStdString(str));
     return prop;
   }
diff --git a/MantidQt/SliceViewer/src/SliceViewer.cpp b/MantidQt/SliceViewer/src/SliceViewer.cpp
index 248f90eab33..77e1a4aa7a1 100644
--- a/MantidQt/SliceViewer/src/SliceViewer.cpp
+++ b/MantidQt/SliceViewer/src/SliceViewer.cpp
@@ -1987,8 +1987,7 @@ void SliceViewer::openFromXML(const QString &xml) {
         "SliceViewer::openFromXML(): No root element in XML string.");
 
   // ------- Find the workspace ------------
-  Poco::XML::Element *cur = NULL;
-  cur = pRootElem->getChildElement("MDWorkspaceName");
+  Poco::XML::Element *cur = pRootElem->getChildElement("MDWorkspaceName");
   if (!cur)
     throw std::runtime_error(
         "SliceViewer::openFromXML(): No MDWorkspaceName element.");
diff --git a/Vates/VatesAPI/src/vtkSplatterPlotFactory.cpp b/Vates/VatesAPI/src/vtkSplatterPlotFactory.cpp
index b3434c11d02..c5c5343fc41 100644
--- a/Vates/VatesAPI/src/vtkSplatterPlotFactory.cpp
+++ b/Vates/VatesAPI/src/vtkSplatterPlotFactory.cpp
@@ -297,17 +297,14 @@ void vtkSplatterPlotFactory::doCreateMDHisto(
   Mantid::coord_t in[3];
   Mantid::coord_t out[3];
 
-  signal_t signalScalar;
-
-  size_t index = 0;
-
   for (int z = 0; z < nBinsZ; z++) {
     in[2] = (minZ + (static_cast<coord_t>(z) + 0.5f) * incrementZ);
     for (int y = 0; y < nBinsY; y++) {
       in[1] = (minY + (static_cast<coord_t>(y) + 0.5f) * incrementY);
       for (int x = 0; x < nBinsX; x++) {
         // Get the signalScalar
-        signalScalar = this->extractScalarSignal(workspace, do4D, x, y, z);
+        signal_t signalScalar =
+            this->extractScalarSignal(workspace, do4D, x, y, z);
 
         // Make sure that the signal is not bad and is in the range and larger
         // than 0
@@ -330,7 +327,6 @@ void vtkSplatterPlotFactory::doCreateMDHisto(
 
           visualDataSet->InsertNextCell(VTK_VERTEX, vertex->GetPointIds());
         }
-        index++;
       }
     }
   }
@@ -518,9 +514,7 @@ void vtkSplatterPlotFactory::addMetadata() const {
   const double defaultValue = 0.1;
 
   if (this->dataSet) {
-    double *range = nullptr;
-    range = dataSet->GetScalarRange();
-
+    double *range = dataSet->GetScalarRange();
     if (range) {
       m_minValue = range[0];
       m_maxValue = range[1];
diff --git a/Vates/VatesSimpleGui/ViewWidgets/src/RebinAlgorithmDialogProvider.cpp b/Vates/VatesSimpleGui/ViewWidgets/src/RebinAlgorithmDialogProvider.cpp
index 88896543cc2..f198abd3ab1 100644
--- a/Vates/VatesSimpleGui/ViewWidgets/src/RebinAlgorithmDialogProvider.cpp
+++ b/Vates/VatesSimpleGui/ViewWidgets/src/RebinAlgorithmDialogProvider.cpp
@@ -132,13 +132,11 @@ MantidQt::API::AlgorithmDialog *RebinAlgorithmDialogProvider::createDialog(
   // This is an optional message displayed at the top of the GUI.
   QString optional_msg(algorithm->summary().c_str());
 
-  MantidQt::API::AlgorithmDialog *dialog = nullptr;
-
   MantidQt::API::InterfaceManager interfaceManager;
   presets.insert(m_lblInputWorkspace, QString::fromStdString(inputWorkspace));
   presets.insert(m_lblOutputWorkspace, QString::fromStdString(outputWorkspace));
 
-  dialog = interfaceManager.createDialogFromName(
+  auto dialog = interfaceManager.createDialogFromName(
       QString::fromStdString(algorithmType), -1, m_parent, false, presets);
 
   // The parent so that the dialog appears on top of it
-- 
GitLab