diff --git a/Framework/API/src/Expression.cpp b/Framework/API/src/Expression.cpp index 67df10cc2af04decf18d62663aed50dd0abcf56e..5308ca5283ba369cc646dd73151157d8c03bec93 100644 --- a/Framework/API/src/Expression.cpp +++ b/Framework/API/src/Expression.cpp @@ -117,8 +117,8 @@ Expression &Expression::operator=(const Expression &expr) { m_funct = expr.m_funct; m_op = expr.m_op; m_terms = expr.m_terms; - // m_expr = expr.m_expr; - // m_tokens = expr.m_tokens; + m_expr = expr.m_expr; + m_tokens = expr.m_tokens; return *this; } diff --git a/Framework/API/src/IFunction.cpp b/Framework/API/src/IFunction.cpp index 43c5e4b1e69667f868acc6958a6cccb22ef2dd74..3e8ca78315aac17ff9ea33bed8a31017de6571b8 100644 --- a/Framework/API/src/IFunction.cpp +++ b/Framework/API/src/IFunction.cpp @@ -559,10 +559,11 @@ std::vector<std::string> IFunction::getParameterNames() const { * @param handler :: A new handler */ void IFunction::setHandler(std::unique_ptr<FunctionHandler> handler) { - m_handler = std::move(handler); if (handler && handler->function().get() != this) { throw std::runtime_error("Function handler points to a different function"); } + + m_handler = std::move(handler); m_handler->init(); } @@ -661,6 +662,7 @@ private: /// @param attr :: The attribute to copy from. IFunction::Attribute &IFunction::Attribute::operator=(const Attribute &attr) { m_data = attr.m_data; + m_quoteValue = attr.m_quoteValue; return *this; } diff --git a/Framework/API/src/IndexProperty.cpp b/Framework/API/src/IndexProperty.cpp index e1b5e3b54995bcf8ca4ea45bd5d0b3129366ca78..9ea0c194546d58b1beba0c1e5d4b7cd06feb5616 100644 --- a/Framework/API/src/IndexProperty.cpp +++ b/Framework/API/src/IndexProperty.cpp @@ -78,7 +78,6 @@ Indexing::SpectrumIndexSet IndexProperty::getIndices() const { static_cast<Indexing::SpectrumNumber>(static_cast<int32_t>(max))); } } else { - // cppcheck-suppress constArgument MSVC_DIAG_OFF(4244); switch (type) { case IndexType::WorkspaceIndex: diff --git a/Framework/API/src/MatrixWorkspace.cpp b/Framework/API/src/MatrixWorkspace.cpp index 479adf454d05c541c7ae059c38e1c29164d320ca..931023650ac4fefae7823f772d9242242ac184e0 100644 --- a/Framework/API/src/MatrixWorkspace.cpp +++ b/Framework/API/src/MatrixWorkspace.cpp @@ -1940,8 +1940,6 @@ MatrixWorkspace::findY(double value, if (std::isnan(value)) { for (int64_t i = idx.first; i < numHists; ++i) { const auto &Y = this->y(i); - // https://trac.cppcheck.net/ticket/9237 if init buggy with cppcheck - // cppcheck-suppress stlIfFind if (auto it = std::find_if(std::next(Y.begin(), idx.second), Y.end(), [](double v) { return std::isnan(v); }); it != Y.end()) { @@ -1952,7 +1950,6 @@ MatrixWorkspace::findY(double value, } else { for (int64_t i = idx.first; i < numHists; ++i) { const auto &Y = this->y(i); - // cppcheck-suppress stlIfFind if (auto it = std::find(std::next(Y.begin(), idx.second), Y.end(), value); it != Y.end()) { out = {i, std::distance(Y.begin(), it)}; diff --git a/Framework/API/src/ParamFunction.cpp b/Framework/API/src/ParamFunction.cpp index b59894b305c8775e11ffa596aa3b09c0d3a61fd3..66b2b282edab56dc13d64b68a5df86d1a99562b2 100644 --- a/Framework/API/src/ParamFunction.cpp +++ b/Framework/API/src/ParamFunction.cpp @@ -150,7 +150,7 @@ double ParamFunction::getParameter(const std::string &name) const { */ bool ParamFunction::hasParameter(const std::string &name) const { return std::find(m_parameterNames.cbegin(), m_parameterNames.cend(), name) != - m_parameterNames.end(); + m_parameterNames.cend(); } /** diff --git a/Framework/API/test/AlgorithmFactoryTest.h b/Framework/API/test/AlgorithmFactoryTest.h index cb2bfc1dd6433704ed4b06cc95cf092e09c3789a..4dea1a5f303d1e1f3b6981985fcc5ec8b7eb8eed 100644 --- a/Framework/API/test/AlgorithmFactoryTest.h +++ b/Framework/API/test/AlgorithmFactoryTest.h @@ -186,7 +186,7 @@ public: foundAlg = ("Cat" == descItr->category) && ("ToyAlgorithm" == descItr->name) && ("Dog" == descItr->alias) && (1 == descItr->version); - descItr++; + ++descItr; } TS_ASSERT(foundAlg); diff --git a/Framework/API/test/FunctionPropertyTest.h b/Framework/API/test/FunctionPropertyTest.h index 05c0417a61a322a93093b6c25e075a6e3c668023..92b15eb6192ac8e7e17e49d229e87d41521d6a63 100644 --- a/Framework/API/test/FunctionPropertyTest.h +++ b/Framework/API/test/FunctionPropertyTest.h @@ -104,7 +104,6 @@ public: void test_Shared_Pointer() { FunctionProperty prop("fun"); - std::string error; boost::shared_ptr<FunctionPropertyTest_Function> fun_p( new FunctionPropertyTest_Function); TS_ASSERT(fun_p); diff --git a/Framework/API/test/LogManagerTest.h b/Framework/API/test/LogManagerTest.h index fbcb69b8112365dbb894701ee39c29947344b842..c047bd8e1e057e7196d78b95760644e810fd1ff1 100644 --- a/Framework/API/test/LogManagerTest.h +++ b/Framework/API/test/LogManagerTest.h @@ -555,8 +555,7 @@ private: LogManager runInfo; const std::string name = "T_prop"; runInfo.addProperty<T>(name, value); - int result(-1); - result = runInfo.getPropertyAsIntegerValue(name); + int result = runInfo.getPropertyAsIntegerValue(name); TS_ASSERT_THROWS_NOTHING(result = runInfo.getPropertyAsIntegerValue(name)); TS_ASSERT_EQUALS(value, static_cast<T>(result)); } @@ -580,12 +579,11 @@ public: } void test_Accessing_Single_Value_From_Times_Series_A_Large_Number_Of_Times() { - double value(0.0); for (size_t i = 0; i < 20000; ++i) { - value = m_testRun.getPropertyAsSingleValue(m_propName); + // This has an observable side-effect of calling, so we don't need + // to store its return value + m_testRun.getPropertyAsSingleValue(m_propName); } - // Enure variable is used so that it is not optimised away by the compiler - value += 1.0; } LogManager m_testRun; diff --git a/Framework/API/test/MultiDomainFunctionTest.h b/Framework/API/test/MultiDomainFunctionTest.h index 141e3ce8591116f00b38d672f52fb7d2716fffd4..31f604a5c32308830875da2e9ddbf8e00eb70e4a 100644 --- a/Framework/API/test/MultiDomainFunctionTest.h +++ b/Framework/API/test/MultiDomainFunctionTest.h @@ -324,7 +324,6 @@ public: void test_attribute_domain_range() { multi.clearDomainIndices(); multi.setLocalAttributeValue(0, "domains", "0-2"); - return; multi.setLocalAttributeValue(1, "domains", "i"); multi.setLocalAttributeValue(2, "domains", "i"); diff --git a/Framework/API/test/RunTest.h b/Framework/API/test/RunTest.h index 288ee1643e191765a5ec6a9651ada6561951b116..caaf5d0a9dbb0fb1f7f8776784e6b89ae554bd8c 100644 --- a/Framework/API/test/RunTest.h +++ b/Framework/API/test/RunTest.h @@ -632,10 +632,8 @@ public: void test_Accessing_Single_Value_From_Times_Series_A_Large_Number_Of_Times() { double value(0.0); for (size_t i = 0; i < 20000; ++i) { - value = m_testRun.getPropertyAsSingleValue(m_propName); + m_testRun.getPropertyAsSingleValue(m_propName); } - // Enure variable is used so that it is not optimised away by the compiler - value += 1.0; } Run m_testRun; diff --git a/Framework/Algorithms/src/ConjoinXRuns.cpp b/Framework/Algorithms/src/ConjoinXRuns.cpp index 0378cc1110100093ecd06c1e7a1053c883f8728a..aa1ef64161227ec8ee7f330b940102d32d64689b 100644 --- a/Framework/Algorithms/src/ConjoinXRuns.cpp +++ b/Framework/Algorithms/src/ConjoinXRuns.cpp @@ -404,7 +404,7 @@ void ConjoinXRuns::exec() { << ". Reason: \"" << e.what() << "\". Skipping.\n"; sampleLogsBehaviour.resetSampleLogs(temp); // remove the skipped one from the list - m_inputWS.erase(it); + it = m_inputWS.erase(it); --it; } else { throw std::invalid_argument(e); diff --git a/Framework/Algorithms/src/CorrectKiKf.cpp b/Framework/Algorithms/src/CorrectKiKf.cpp index 492a047143adf2a1020dda3af83cc1e81da88727..c4b97099dc2fc3dc5c0859667971677049fc0ba6 100644 --- a/Framework/Algorithms/src/CorrectKiKf.cpp +++ b/Framework/Algorithms/src/CorrectKiKf.cpp @@ -220,11 +220,10 @@ void CorrectKiKf::execEvent() { PARALLEL_FOR_IF(Kernel::threadSafe(*outputWS)) for (int64_t i = 0; i < numHistograms; ++i) { PARALLEL_START_INTERUPT_REGION - - double Efi = 0; // Now get the detector object for this histogram to check if monitor // or to get Ef for indirect geometry if (emodeStr == "Indirect") { + double Efi = 0; if (efixedProp != EMPTY_DBL()) { Efi = efixedProp; // If a DetectorGroup is present should provide a value as a property diff --git a/Framework/Algorithms/src/CreateGroupingWorkspace.cpp b/Framework/Algorithms/src/CreateGroupingWorkspace.cpp index 63eea8809ca28d90709ec116a6d283afccd611ca..14db984fea74fc7e7ca82163aa94aa3494488eb7 100644 --- a/Framework/Algorithms/src/CreateGroupingWorkspace.cpp +++ b/Framework/Algorithms/src/CreateGroupingWorkspace.cpp @@ -432,7 +432,6 @@ void CreateGroupingWorkspace::exec() { sortnames = true; GroupNames = ""; int maxRecurseDepth = this->getProperty("MaxRecursionDepth"); - // cppcheck-suppress syntaxError PRAGMA_OMP(parallel for schedule(dynamic, 1) ) for (int num = 0; num < 300; ++num) { diff --git a/Framework/Algorithms/src/DiffractionFocussing2.cpp b/Framework/Algorithms/src/DiffractionFocussing2.cpp index 8c204e9af1314722ed368c1d36617d2fbda4dc55..9444e68fa4a1f5bafa614f234e02e9047297eeae 100644 --- a/Framework/Algorithms/src/DiffractionFocussing2.cpp +++ b/Framework/Algorithms/src/DiffractionFocussing2.cpp @@ -590,11 +590,10 @@ void DiffractionFocussing2::determineRebinParameters() { nGroups = group2minmax.size(); // Number of unique groups - double Xmin, Xmax, step; const int64_t xPoints = nPoints + 1; - // Iterator over all groups to create the new X vectors - for (gpit = group2minmax.begin(); gpit != group2minmax.end(); gpit++) { + for (gpit = group2minmax.begin(); gpit != group2minmax.end(); ++gpit) { + double Xmin, Xmax, step; Xmin = (gpit->second).first; Xmax = (gpit->second).second; diff --git a/Framework/Algorithms/src/FitPeaks.cpp b/Framework/Algorithms/src/FitPeaks.cpp index c1d1fce015488b4182b795d9b9449202e8ef3095..17a439ef3d196662fdb83562f5fc85ece8f2e052 100644 --- a/Framework/Algorithms/src/FitPeaks.cpp +++ b/Framework/Algorithms/src/FitPeaks.cpp @@ -1771,7 +1771,6 @@ double FitPeaks::fitFunctionSD( errorid << ": " << e.what(); g_log.warning() << "While fitting " + errorid.str(); return DBL_MAX; // probably the wrong thing to do - throw std::runtime_error("While fitting " + errorid.str()); } // Retrieve result @@ -1847,7 +1846,6 @@ double FitPeaks::fitFunctionMD(API::IFunction_sptr fit_function, double chi2 = DBL_MAX; if (fitStatus == "success") { chi2 = fit->getProperty("OutputChi2overDoF"); - fit_function = fit->getProperty("Function"); } return chi2; @@ -1883,9 +1881,8 @@ double FitPeaks::fitFunctionHighBackground( createMatrixWorkspace(vec_x, vec_y, vec_e); // Fit peak with background - double cost = fitFunctionSD(fit, peakfunction, bkgdfunc, reduced_bkgd_ws, 0, - vec_x.front(), vec_x.back(), expected_peak_center, - observe_peak_shape, false); + fitFunctionSD(fit, peakfunction, bkgdfunc, reduced_bkgd_ws, 0, vec_x.front(), + vec_x.back(), expected_peak_center, observe_peak_shape, false); // add the reduced background back bkgdfunc->setParameter(0, bkgdfunc->getParameter(0) + @@ -1893,9 +1890,9 @@ double FitPeaks::fitFunctionHighBackground( bkgdfunc->setParameter(1, bkgdfunc->getParameter(1) + high_bkgd_function->getParameter(1)); - cost = fitFunctionSD(fit, peakfunction, bkgdfunc, m_inputMatrixWS, ws_index, - vec_x.front(), vec_x.back(), expected_peak_center, false, - false); + double cost = fitFunctionSD(fit, peakfunction, bkgdfunc, m_inputMatrixWS, + ws_index, vec_x.front(), vec_x.back(), + expected_peak_center, false, false); return cost; } diff --git a/Framework/Algorithms/src/GenerateEventsFilter.cpp b/Framework/Algorithms/src/GenerateEventsFilter.cpp index d0be0289a76b9d895528d4c181e365f718bec960..2e0de3025f26870196ec34f3889188d602cddaa4 100644 --- a/Framework/Algorithms/src/GenerateEventsFilter.cpp +++ b/Framework/Algorithms/src/GenerateEventsFilter.cpp @@ -456,10 +456,9 @@ void GenerateEventsFilter::setFilterByTimeOnly() { int64_t curtime_ns = m_startTime.totalNanoseconds(); int wsindex = 0; while (curtime_ns < m_stopTime.totalNanoseconds()) { - int64_t deltatime_ns; for (size_t id = 0; id < numtimeintervals; ++id) { // get next time interval value - deltatime_ns = vec_dtimens[id]; + int64_t deltatime_ns = vec_dtimens[id]; // Calculate next.time int64_t nexttime_ns = curtime_ns + deltatime_ns; bool breaklater = false; @@ -831,7 +830,6 @@ void GenerateEventsFilter::makeFilterBySingleValue( // Initialize control parameters bool lastGood = false; - bool isGood = false; time_duration tol = DateAndTime::durationFromSeconds(TimeTolerance); int numgood = 0; DateAndTime lastTime, currT; @@ -844,8 +842,8 @@ void GenerateEventsFilter::makeFilterBySingleValue( currT = m_dblLog->nthTime(i); // A good value? - isGood = identifyLogEntry(i, currT, lastGood, min, max, startTime, stopTime, - filterIncrease, filterDecrease); + bool isGood = identifyLogEntry(i, currT, lastGood, min, max, startTime, + stopTime, filterIncrease, filterDecrease); if (isGood) numgood++; @@ -1219,7 +1217,6 @@ void GenerateEventsFilter::makeMultipleFiltersByValuesPartialLog( double currValue = m_dblLog->nthValue(i); // Filter out by time and direction (optional) - bool intime = true; if (currTime < startTime) { // case i. Too early, do nothing createsplitter = false; @@ -1254,130 +1251,127 @@ void GenerateEventsFilter::makeMultipleFiltersByValuesPartialLog( prevDirection = direction; // Examine log value for filter - if (intime) { - // Determine whether direction is fine - bool correctdir = true; - if (filterIncrease && filterDecrease) { - // Both direction is fine + // Determine whether direction is fine + bool correctdir = true; + if (filterIncrease && filterDecrease) { + // Both direction is fine + correctdir = true; + } else { + // Filter out one direction + if (filterIncrease && direction > 0) correctdir = true; - } else { - // Filter out one direction - if (filterIncrease && direction > 0) - correctdir = true; - else if (filterDecrease && direction < 0) - correctdir = true; - else if (direction == 0) - throw runtime_error("Direction is not determined."); - else - correctdir = false; - } // END-IF-ELSE: Direction - - // Treat the log entry based on: changing direction (+ time range) - if (correctdir) { - // Check this value whether it falls into any range - size_t index = searchValue(logvalueranges, currValue); - - bool valueWithinMinMax = true; - if (index > logvalueranges.size()) { - // Out of range - valueWithinMinMax = false; - } + else if (filterDecrease && direction < 0) + correctdir = true; + else if (direction == 0) + throw runtime_error("Direction is not determined."); + else + correctdir = false; + } // END-IF-ELSE: Direction + + // Treat the log entry based on: changing direction (+ time range) + if (correctdir) { + // Check this value whether it falls into any range + size_t index = searchValue(logvalueranges, currValue); + + bool valueWithinMinMax = true; + if (index > logvalueranges.size()) { + // Out of range + valueWithinMinMax = false; + } - if (g_log.is(Logger::Priority::PRIO_DEBUG)) { - stringstream dbss; - dbss << "[DBx257] Examine Log Index " << i - << ", Value = " << currValue << ", Data Range Index = " << index - << "; " - << "Group Index = " << indexwsindexmap[index / 2] - << " (log value range vector size = " << logvalueranges.size() - << "): "; - if (index == 0) - dbss << logvalueranges[index] << ", " << logvalueranges[index + 1]; - else if (index == logvalueranges.size()) - dbss << logvalueranges[index - 1] << ", " << logvalueranges[index]; - else if (valueWithinMinMax) - dbss << logvalueranges[index - 1] << ", " << logvalueranges[index] - << ", " << logvalueranges[index + 1]; - g_log.debug(dbss.str()); - } + if (g_log.is(Logger::Priority::PRIO_DEBUG)) { + stringstream dbss; + dbss << "[DBx257] Examine Log Index " << i << ", Value = " << currValue + << ", Data Range Index = " << index << "; " + << "Group Index = " << indexwsindexmap[index / 2] + << " (log value range vector size = " << logvalueranges.size() + << "): "; + if (index == 0) + dbss << logvalueranges[index] << ", " << logvalueranges[index + 1]; + else if (index == logvalueranges.size()) + dbss << logvalueranges[index - 1] << ", " << logvalueranges[index]; + else if (valueWithinMinMax) + dbss << logvalueranges[index - 1] << ", " << logvalueranges[index] + << ", " << logvalueranges[index + 1]; + g_log.debug(dbss.str()); + } - if (valueWithinMinMax) { - if (index % 2 == 0) { - // [Situation] Falls in the interval - currindex = indexwsindexmap[index / 2]; - - if (currindex != lastindex && start.totalNanoseconds() == 0) { - // Group index is different from last and start is not set up: new - // a region! - newsplitter = true; - } else if (currindex != lastindex && start.totalNanoseconds() > 0) { - // Group index is different from last and start is set up: close - // a region and new a region + if (valueWithinMinMax) { + if (index % 2 == 0) { + // [Situation] Falls in the interval + currindex = indexwsindexmap[index / 2]; + + if (currindex != lastindex && start.totalNanoseconds() == 0) { + // Group index is different from last and start is not set up: new + // a region! + newsplitter = true; + } else if (currindex != lastindex && start.totalNanoseconds() > 0) { + // Group index is different from last and start is set up: close + // a region and new a region + stop = currTime; + createsplitter = true; + newsplitter = true; + } else if (currindex == lastindex && start.totalNanoseconds() > 0) { + // Still of the group index + if (i == iend) { + // Last entry in this section of log. Need to flag to close the + // pair stop = currTime; createsplitter = true; - newsplitter = true; - } else if (currindex == lastindex && start.totalNanoseconds() > 0) { - // Still of the group index - if (i == iend) { - // Last entry in this section of log. Need to flag to close the - // pair - stop = currTime; - createsplitter = true; - newsplitter = false; - } else { - // Do nothing - ; - } + newsplitter = false; } else { - // An impossible situation - std::stringstream errmsg; - double lastvalue = m_dblLog->nthValue(i - 1); - errmsg << "Impossible to have currindex == lastindex == " - << currindex - << ", while start is not init. Log Index = " << i - << "\t value = " << currValue << "\t, Index = " << index - << " in range " << logvalueranges[index] << ", " - << logvalueranges[index + 1] - << "; Last value = " << lastvalue; - throw std::runtime_error(errmsg.str()); + // Do nothing + ; } - } // [In-bound: Inside interval] - else { - // [Situation] Fall between interval (which is not likley happen) - currindex = -1; - g_log.warning() - << "Not likely to happen! Current value = " << currValue - << " is within value range but its index = " << index - << " has no map to group index. " - << "\n"; - if (start.totalNanoseconds() > 0) { - // Close the interval pair if it has been started. - stop = currTime; - createsplitter = true; - } - } // [In-bound: Between interval] - } else { - // Out of a range: check whether there is a splitter started + } else { + // An impossible situation + std::stringstream errmsg; + double lastvalue = m_dblLog->nthValue(i - 1); + errmsg << "Impossible to have currindex == lastindex == " + << currindex + << ", while start is not init. Log Index = " << i + << "\t value = " << currValue << "\t, Index = " << index + << " in range " << logvalueranges[index] << ", " + << logvalueranges[index + 1] + << "; Last value = " << lastvalue; + throw std::runtime_error(errmsg.str()); + } + } // [In-bound: Inside interval] + else { + // [Situation] Fall between interval (which is not likley happen) currindex = -1; + g_log.warning() << "Not likely to happen! Current value = " + << currValue + << " is within value range but its index = " << index + << " has no map to group index. " + << "\n"; if (start.totalNanoseconds() > 0) { - // End situation + // Close the interval pair if it has been started. stop = currTime; createsplitter = true; } - } // [Out-bound] - - } // [CORRECT DIRECTION] - else { - // Log Index i falls out b/c out of wrong direction + } // [In-bound: Between interval] + } else { + // Out of a range: check whether there is a splitter started currindex = -1; - - // Condition to generate a Splitter (close parenthesis) - if (!correctdir && start.totalNanoseconds() > 0) { + if (start.totalNanoseconds() > 0) { + // End situation stop = currTime; createsplitter = true; } + } // [Out-bound] + + } // [CORRECT DIRECTION] + else { + // Log Index i falls out b/c out of wrong direction + currindex = -1; + + // Condition to generate a Splitter (close parenthesis) + if (!correctdir && start.totalNanoseconds() > 0) { + stop = currTime; + createsplitter = true; } - } // ENDIF (log entry in specified time) + } // d) Create Splitter if (createsplitter) { diff --git a/Framework/Algorithms/src/GetDetOffsetsMultiPeaks.cpp b/Framework/Algorithms/src/GetDetOffsetsMultiPeaks.cpp index 75a9b6a0e228dc1ab2f1470664a0c593117419b3..d0aae901fc3ad91d3e187ad89837cad9e9043fd7 100644 --- a/Framework/Algorithms/src/GetDetOffsetsMultiPeaks.cpp +++ b/Framework/Algorithms/src/GetDetOffsetsMultiPeaks.cpp @@ -721,7 +721,7 @@ void GetDetOffsetsMultiPeaks::fitPeaksOffset( // Set up GSL minimzer const gsl_multimin_fminimizer_type *T = gsl_multimin_fminimizer_nmsimplex; - gsl_multimin_fminimizer *s = nullptr; + gsl_vector *ss, *x; gsl_multimin_function minex_func; @@ -729,7 +729,6 @@ void GetDetOffsetsMultiPeaks::fitPeaksOffset( size_t nopt = 1; size_t iter = 0; int status = 0; - double size; /* Starting point */ x = gsl_vector_alloc(nopt); @@ -744,7 +743,7 @@ void GetDetOffsetsMultiPeaks::fitPeaksOffset( minex_func.f = &gsl_costFunction; minex_func.params = ¶ms; - 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 { @@ -753,7 +752,7 @@ void GetDetOffsetsMultiPeaks::fitPeaksOffset( if (status) break; - size = gsl_multimin_fminimizer_size(s); + double size = gsl_multimin_fminimizer_size(s); status = gsl_multimin_test_size(size, 1e-4); } while (status == GSL_CONTINUE && iter < 50); diff --git a/Framework/Algorithms/src/PDCalibration.cpp b/Framework/Algorithms/src/PDCalibration.cpp index e0ea9546981a1e70761e2faed9a73af8e311fe75..a5de2509c4725be4aa58f533c5bfa965497156f3 100644 --- a/Framework/Algorithms/src/PDCalibration.cpp +++ b/Framework/Algorithms/src/PDCalibration.cpp @@ -755,14 +755,13 @@ double fitDIFCtZeroDIFA(std::vector<double> &peaks, double &difc, double &t0, size_t iter = 0; // number of iterations const size_t MAX_ITER = 75 * numParams; int status = 0; - double size; do { iter++; status = gsl_multimin_fminimizer_iterate(minimizer); if (status) break; - size = gsl_multimin_fminimizer_size(minimizer); + double size = gsl_multimin_fminimizer_size(minimizer); status = gsl_multimin_test_size(size, 1e-4); } while (status == GSL_CONTINUE && iter < MAX_ITER); diff --git a/Framework/Algorithms/src/PolarizationCorrectionWildes.cpp b/Framework/Algorithms/src/PolarizationCorrectionWildes.cpp index 328054b34486d1fcaedd1f801cb472ac3910944f..95cb7c112f6b7b999c5db21c7b929323d6e0b8dd 100644 --- a/Framework/Algorithms/src/PolarizationCorrectionWildes.cpp +++ b/Framework/Algorithms/src/PolarizationCorrectionWildes.cpp @@ -96,30 +96,22 @@ void fourInputsCorrectedAndErrors( const auto diag1 = 1. / f1; const auto off1 = (f1 - 1.) / f1; Eigen::Matrix4d F1m; - // Suppress warnings about suspicious init with Eigen - // cppcheck-suppress constStatement F1m << 1., 0., 0., 0., 0., 1., 0., 0., off1, 0., diag1, 0., 0., off1, 0., diag1; const auto diag2 = 1. / f2; const auto off2 = (f2 - 1.) / f2; Eigen::Matrix4d F2m; - - // cppcheck-suppress constStatement F2m << 1., 0., 0., 0., off2, diag2, 0., 0., 0., 0., 1., 0., 0., 0., off2, diag2; const auto diag3 = (p1 - 1.) / (2. * p1 - 1.); const auto off3 = p1 / (2. * p1 - 1); Eigen::Matrix4d P1m; - - // cppcheck-suppress constStatement P1m << diag3, 0, off3, 0, 0, diag3, 0, off3, off3, 0, diag3, 0, 0, off3, 0, diag3; const auto diag4 = (p2 - 1.) / (2. * p2 - 1.); const auto off4 = p2 / (2. * p2 - 1.); Eigen::Matrix4d P2m; - - // cppcheck-suppress constStatement P2m << diag4, off4, 0., 0., off4, diag4, 0., 0., 0., 0., diag4, off4, 0., 0., off4, diag4; const Eigen::Vector4d intensities(ppy, pmy, mpy, mmy); @@ -131,26 +123,18 @@ void fourInputsCorrectedAndErrors( // the matrices above, multiplied by the error. const auto elemE1 = -1. / pow<2>(f1) * f1E; Eigen::Matrix4d F1Em; - - // cppcheck-suppress constStatement F1Em << 0., 0., 0., 0., 0., 0., 0., 0., -elemE1, 0., elemE1, 0., 0., -elemE1, 0., elemE1; const auto elemE2 = -1. / pow<2>(f2) * f2E; Eigen::Matrix4d F2Em; - - // cppcheck-suppress constStatement F2Em << 0., 0., 0., 0., -elemE2, elemE2, 0., 0., 0., 0., 0., 0., 0., 0., -elemE2, elemE2; const auto elemE3 = 1. / pow<2>(2. * p1 - 1.) * p1E; Eigen::Matrix4d P1Em; - - // cppcheck-suppress constStatement P1Em << elemE3, 0., -elemE3, 0., 0., elemE3, 0., -elemE3, -elemE3, 0., elemE3, 0., 0., -elemE3, 0., elemE3; const auto elemE4 = 1. / pow<2>(2. * p2 - 1.) * p2E; Eigen::Matrix4d P2Em; - - // cppcheck-suppress constStatement P2Em << elemE4, -elemE4, 0., 0., -elemE4, elemE4, 0., 0., 0., 0., elemE4, -elemE4, 0., 0., -elemE4, elemE4; const Eigen::Vector4d yErrors(ppyE, pmyE, mpyE, mmyE); diff --git a/Framework/Algorithms/test/AnyShapeAbsorptionTest.h b/Framework/Algorithms/test/AnyShapeAbsorptionTest.h index 89f511c9ebf2443a269e06e937c7b91e30807ad2..00416e4ad487fde80e1613c6d4b4ea7b5d32e804 100644 --- a/Framework/Algorithms/test/AnyShapeAbsorptionTest.h +++ b/Framework/Algorithms/test/AnyShapeAbsorptionTest.h @@ -257,7 +257,6 @@ public: constexpr double WL_DELTA = (2.9 - WL_MIN) / static_cast<double>(NUM_VALS); // create the input workspace - const std::string IN_WS{"AbsorptionCorrection_Input"}; auto inputWS = WorkspaceCreationHelper::create2DWorkspaceBinned( 1, NUM_VALS, WL_MIN, WL_DELTA); auto testInst = diff --git a/Framework/Algorithms/test/ApplyCalibrationTest.h b/Framework/Algorithms/test/ApplyCalibrationTest.h index c666885b977991da9672de2b0e2ac0c41591055a..fb596ef039a72c7add3b78fe715ad46eff55ef56 100644 --- a/Framework/Algorithms/test/ApplyCalibrationTest.h +++ b/Framework/Algorithms/test/ApplyCalibrationTest.h @@ -82,11 +82,9 @@ public: TS_ASSERT(appCalib.isExecuted()); const auto &spectrumInfo = ws->spectrumInfo(); - const auto &componentInfo = ws->componentInfo(); int id = spectrumInfo.detector(0).getID(); V3D newPos = spectrumInfo.position(0); - V3D scaleFactor = componentInfo.scaleFactor(0); TS_ASSERT_EQUALS(id, 1); TS_ASSERT_DELTA(newPos.X(), 1.0, 0.0001); @@ -95,7 +93,6 @@ public: id = spectrumInfo.detector(ndets - 1).getID(); newPos = spectrumInfo.position(ndets - 1); - scaleFactor = componentInfo.scaleFactor(0); TS_ASSERT_EQUALS(id, ndets); TS_ASSERT_DELTA(newPos.X(), 1.0, 0.0001); diff --git a/Framework/Algorithms/test/CalculateFlatBackgroundTest.h b/Framework/Algorithms/test/CalculateFlatBackgroundTest.h index 4ef353d997bd4a53e3e0ca39f11c85ec201cff59..7c65acff010c91d5b4600d49e7bbc0c1f47f6966 100644 --- a/Framework/Algorithms/test/CalculateFlatBackgroundTest.h +++ b/Framework/Algorithms/test/CalculateFlatBackgroundTest.h @@ -763,6 +763,7 @@ private: AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>( "Removed1"); for (size_t j = 0; j < spectraCount; ++j) { + // cppcheck-suppress unreadVariable const double expected = (movingAverageSpecialY(j) + (static_cast<double>(windowWidth) - 1) * movingAverageStandardY(j)) / diff --git a/Framework/Algorithms/test/CalculateTransmissionTest.h b/Framework/Algorithms/test/CalculateTransmissionTest.h index 238ab958c5f0683bd41b4a8abc6cb8fa44ba0511..f440374c3394b48968779ce29a492e780b275fcb 100644 --- a/Framework/Algorithms/test/CalculateTransmissionTest.h +++ b/Framework/Algorithms/test/CalculateTransmissionTest.h @@ -361,10 +361,9 @@ public: auto &fitted_x = fitted->x(0); // TS_ASSERT_EQUALS(fitted_y.size(), unfitted_y.size()); - double x; for (unsigned int i = 0; i < fitted_y.size(); ++i) { - x = fitted_x[i]; //(fitted_x[i] + fitted_x[i+1])* 0.5; + double x = fitted_x[i]; //(fitted_x[i] + fitted_x[i+1])* 0.5; TS_ASSERT_DELTA(fitted_y[i], 26.6936 - 9.31494 * x + 1.11532 * x * x - 0.044502 * x * x * x, @@ -405,10 +404,9 @@ public: auto &fitted_x = fitted->x(0); // TS_ASSERT_EQUALS(fitted_y.size(), unfitted_y.size()); - double x; for (unsigned int i = 0; i < fitted_y.size(); ++i) { - x = (fitted_x[i] + fitted_x[i + 1]) * 0.5; + double x = (fitted_x[i] + fitted_x[i + 1]) * 0.5; TS_ASSERT_DELTA(fitted_y[i], 26.6936 - 9.31494 * x + 1.11532 * x * x - 0.044502 * x * x * x, diff --git a/Framework/Algorithms/test/CreateEPPTest.h b/Framework/Algorithms/test/CreateEPPTest.h index 7938d581ad0cc1b15571b2a6c43796b0d217ceb8..2ed9d6e0c6da0fd7052f1a377b71532b324d381f 100644 --- a/Framework/Algorithms/test/CreateEPPTest.h +++ b/Framework/Algorithms/test/CreateEPPTest.h @@ -177,7 +177,7 @@ private: return false; } for (const auto &columnName : columnNames) { - if (std::find(names.cbegin(), names.cend(), columnName) == names.end()) { + if (std::find(names.cbegin(), names.cend(), columnName) == names.cend()) { return false; } } diff --git a/Framework/Algorithms/test/DetectorEfficiencyCorTest.h b/Framework/Algorithms/test/DetectorEfficiencyCorTest.h index 4c851cdcf73b865dc4e5040cfb8d6d1820f3b7a5..9bf3cae230d0ba3431ad16f87655a3bb3e5d2150 100644 --- a/Framework/Algorithms/test/DetectorEfficiencyCorTest.h +++ b/Framework/Algorithms/test/DetectorEfficiencyCorTest.h @@ -41,7 +41,6 @@ public: WorkspaceCreationHelper::create2DWorkspaceWithFullInstrument(2, 1); dummyWS->getAxis(0)->unit() = Mantid::Kernel::UnitFactory::Instance().create("DeltaE"); - const std::string inputWS = "testInput"; Mantid::Algorithms::DetectorEfficiencyCor corrector; TS_ASSERT_THROWS_NOTHING(corrector.initialize()); diff --git a/Framework/Algorithms/test/FFTSmooth2Test.h b/Framework/Algorithms/test/FFTSmooth2Test.h index a0a85cac67090cdd44900be723a63b2832ea2104..ffae4ce2e45f2d8b32393fe359b2adb78fffa89e 100644 --- a/Framework/Algorithms/test/FFTSmooth2Test.h +++ b/Framework/Algorithms/test/FFTSmooth2Test.h @@ -277,9 +277,11 @@ public: } if (!AllSpectra) { + bool allSpectraGtZero = false; + for (int WorkspaceIndex = 0; WorkspaceIndex < 10; WorkspaceIndex++) { - performTest((event > 0), filter, params, (AllSpectra > 0), + performTest((event > 0), filter, params, allSpectraGtZero, WorkspaceIndex, (inPlace > 0)); } } else { diff --git a/Framework/Algorithms/test/FindCenterOfMassPosition2Test.h b/Framework/Algorithms/test/FindCenterOfMassPosition2Test.h index 31e925bc196f2003ad4eb837e77b7098413b16e6..b914e7e6c0ff804c0fd79d320df11ec938498118 100644 --- a/Framework/Algorithms/test/FindCenterOfMassPosition2Test.h +++ b/Framework/Algorithms/test/FindCenterOfMassPosition2Test.h @@ -58,7 +58,7 @@ public: // Set tube extrema to special values if (iy == 0 || iy == SANSInstrumentCreationHelper::nBins - 1) Y[0] = - iy % 2 ? std::nan("") : std::numeric_limits<double>::infinity(); + (iy % 2) ? std::nan("") : std::numeric_limits<double>::infinity(); E[0] = 1; } } diff --git a/Framework/Algorithms/test/FitPeaksTest.h b/Framework/Algorithms/test/FitPeaksTest.h index 2af2633483f38bd7589b3070747a55ffb8976901..f4849daa7e74041dc0f17b229c559538138714aa 100644 --- a/Framework/Algorithms/test/FitPeaksTest.h +++ b/Framework/Algorithms/test/FitPeaksTest.h @@ -411,7 +411,6 @@ public: // std::string input_ws_name = loadVulcanHighAngleData(); // Generate peak and background parameters - std::vector<string> peakparnames{"Mixing"}; std::vector<double> peakparvalues{0.5}; // Initialize FitPeak diff --git a/Framework/Algorithms/test/LineProfileTest.h b/Framework/Algorithms/test/LineProfileTest.h index ec4e372c533d4adffb45670f906476d1c70ab5ec..61fda4391b0f455b5a6a7c34919b96f61510610f 100644 --- a/Framework/Algorithms/test/LineProfileTest.h +++ b/Framework/Algorithms/test/LineProfileTest.h @@ -568,9 +568,9 @@ public: TS_ASSERT_EQUALS(axis->getMax(), edges.back()) const auto binHeight = axis->getMax() - axis->getMin(); TS_ASSERT_EQUALS(outputWS->getNumberHistograms(), 1) - const auto &Xs = outputWS->x(0); + // cppcheck-suppress unreadVariable const std::vector<double> profilePoints{{1., 2., 3., 4.}}; - TS_ASSERT_EQUALS(Xs.rawData(), profilePoints) + TS_ASSERT_EQUALS(outputWS->x(0).rawData(), profilePoints) const auto &Ys = outputWS->y(0); const auto horizontalIntegral = (3. * 0.1 + 2. * 1. + 1. * 10.) / binHeight; for (const auto y : Ys) { diff --git a/Framework/Algorithms/test/MergeRunsTest.h b/Framework/Algorithms/test/MergeRunsTest.h index 3e696152726b57bee9bf44ce6083dfaca4cbfe99..8bead92a85e57b3350a4ca4aed4cb394c45ab109 100644 --- a/Framework/Algorithms/test/MergeRunsTest.h +++ b/Framework/Algorithms/test/MergeRunsTest.h @@ -373,6 +373,7 @@ public: va_start(vl, num); for (int i = 0; i < num; i++) retVal.emplace_back(va_arg(vl, int)); + va_end(vl); return retVal; } diff --git a/Framework/Algorithms/test/MonteCarloAbsorptionTest.h b/Framework/Algorithms/test/MonteCarloAbsorptionTest.h index 2754ce990002e6de98d665405ce6ff4b98f748e4..bff3d16341a5d6ef07ad65287aefc93667f8fa21 100644 --- a/Framework/Algorithms/test/MonteCarloAbsorptionTest.h +++ b/Framework/Algorithms/test/MonteCarloAbsorptionTest.h @@ -87,7 +87,6 @@ void addSample(const Mantid::API::MatrixWorkspace_sptr &ws, ws->mutableSample().setShape(sampleShape); if (environment == Environment::SamplePlusContainer) { - const std::string id("container"); constexpr double containerWallThickness{0.002}; constexpr double containerInnerRadius{1.2 * sampleHeight}; constexpr double containerOuterRadius{containerInnerRadius + diff --git a/Framework/Algorithms/test/MultiplyDivideTest.in.h b/Framework/Algorithms/test/MultiplyDivideTest.in.h index 44f71c607c1a82d1fc1b924b24c69fd1675a1773..2a2c6270760499f02ed155b95fe6fd9c004edd1e 100644 --- a/Framework/Algorithms/test/MultiplyDivideTest.in.h +++ b/Framework/Algorithms/test/MultiplyDivideTest.in.h @@ -9,6 +9,7 @@ #include <cxxtest/TestSuite.h> #include <cmath> +#include <stdexcept> #include "MantidTestHelpers/WorkspaceCreationHelper.h" #include "MantidAlgorithms/Divide.h" @@ -602,6 +603,10 @@ public: mess << "; RHS: grouping=" << rhs_grouping << ", 2D=" << rhs2D; message = mess.str(); + if (lhs_grouping == 0 || rhs_grouping == 0){ + throw std::runtime_error("Attempted div by zero in test"); + } + int numpix = 12; std::vector< std::vector<int> > lhs(numpix/lhs_grouping), rhs(numpix/rhs_grouping); for (int i=0; i<numpix; i++) diff --git a/Framework/Algorithms/test/NormaliseByDetectorTest.h b/Framework/Algorithms/test/NormaliseByDetectorTest.h index 8aa3652fe166a4dcad79c6de4af4b7cd9631f280..be35738086039d1563ae01164aed81b963a18421 100644 --- a/Framework/Algorithms/test/NormaliseByDetectorTest.h +++ b/Framework/Algorithms/test/NormaliseByDetectorTest.h @@ -400,10 +400,11 @@ public: MatrixWorkspace_sptr inputWS = create_workspace_with_fitting_functions(); // Extract the output workspace so that we can verify the normalisation. const bool parallel = true; + const bool sequential = false; MatrixWorkspace_sptr outWS_parallel = do_test_doesnt_throw_on_execution( inputWS, parallel); // EXECUTES THE ALG IN PARALLEL. MatrixWorkspace_sptr outWS_sequential = do_test_doesnt_throw_on_execution( - inputWS, !parallel); // EXECUTES THE ALG SEQUENTIALLY. + inputWS, sequential); // EXECUTES THE ALG SEQUENTIALLY. // Output workspaces should have same number of histograms. TS_ASSERT_EQUALS(2, outWS_parallel->getNumberHistograms()); diff --git a/Framework/Algorithms/test/NormaliseToMonitorTest.h b/Framework/Algorithms/test/NormaliseToMonitorTest.h index b3a9a9c345bd44bed43f805fa52a194c9a4d69ad..1642311c5f7f475c8fed8ecf1a88e6aaf571a0c8 100644 --- a/Framework/Algorithms/test/NormaliseToMonitorTest.h +++ b/Framework/Algorithms/test/NormaliseToMonitorTest.h @@ -468,10 +468,11 @@ public: for (size_t i = 0; i < specOutInfo.size(); ++i) { const auto &yValues = outWS->histogram(i).y(); for (size_t j = 0; j < yValues.size(); ++j) { - if (specOutInfo.isMonitor(i)) + if (specOutInfo.isMonitor(i)) { TS_ASSERT_DELTA(yValues[j], 3.0, 1e-12) - else + } else { TS_ASSERT_DELTA(yValues[j], 6.0 / double(j + 1), 1e-12) + } } } } @@ -497,6 +498,7 @@ public: const auto &yValues = outWS->histogram(i).y(); for (size_t j = 0; j < yValues.size(); ++j) { if (specOutInfo.isMonitor(i)) + // cppcheck-suppress syntaxError TS_ASSERT_DELTA(yValues[j], double(j + 1) / 15.0, 1e-12) else TS_ASSERT_DELTA(yValues[j], 2.0 / 15.0, 1e-12) diff --git a/Framework/Algorithms/test/PlusMinusTest.in.h b/Framework/Algorithms/test/PlusMinusTest.in.h index e264d7048f50e004d1b7c1f2ce5fe0218269cec7..68a6515f889fa24b782667cd68ef98bec308a93e 100644 --- a/Framework/Algorithms/test/PlusMinusTest.in.h +++ b/Framework/Algorithms/test/PlusMinusTest.in.h @@ -392,7 +392,7 @@ public: MatrixWorkspace_sptr work_in2 = eventWS_5x10_50; // You have to specify the expected output value because in1 gets changed. performTest(work_in1,work_in2, true, false /*not event out*/, - DO_PLUS ? 4.0 : 0.0, DO_PLUS ? 2.0 : 2.0); + DO_PLUS ? 4.0 : 0.0, 2.0); } void test_Event_2D() @@ -468,7 +468,7 @@ public: MatrixWorkspace_sptr work_in1 = eventWS_5x10_50; MatrixWorkspace_sptr work_in2 = eventWS_5x10_50; MatrixWorkspace_sptr work_out = performTest(work_in1,work_in2, false /*inPlace*/, true /*outputIsEvent*/, - DO_PLUS ? 4.0 : 0.0, DO_PLUS ? 2.0 : 2.0); + DO_PLUS ? 4.0 : 0.0, 2.0); } void test_Event_Event_inPlace() @@ -477,7 +477,7 @@ public: MatrixWorkspace_sptr work_in1 = WorkspaceCreationHelper::createEventWorkspace(nHist,nBins,50,0.0,1.0,2); MatrixWorkspace_sptr work_in2 = eventWS_5x10_50; MatrixWorkspace_sptr work_out = performTest(work_in1,work_in2, true, true /*outputIsEvent*/, - DO_PLUS ? 4.0 : 0.0, DO_PLUS ? 2.0 : 2.0); + DO_PLUS ? 4.0 : 0.0, 2.0); } void test_Event_EventSingleSpectrum_fails() @@ -502,7 +502,7 @@ public: MatrixWorkspace_sptr work_in1 = WorkspaceCreationHelper::createEventWorkspace(nHist,nBins,50,0.0,1.0,2); MatrixWorkspace_sptr work_in2 = WorkspaceCreationHelper::createEventWorkspace(nHist,nBins,50,0.0,1.0,2); MatrixWorkspace_sptr work_out = performTest(work_in1,work_in2, inplace!=0, true /*outputIsEvent*/, - DO_PLUS ? 4.0 : 0.0, DO_PLUS ? 2.0 : 2.0); + DO_PLUS ? 4.0 : 0.0, 2.0); } } @@ -514,7 +514,7 @@ public: MatrixWorkspace_sptr work_in1 = WorkspaceCreationHelper::createEventWorkspace(nHist,nBins,50,0.0,1.0,2); MatrixWorkspace_sptr work_in2 = WorkspaceCreationHelper::createEventWorkspace(nHist,1,50,0.0,1.0,2); MatrixWorkspace_sptr work_out = performTest(work_in1,work_in2, inplace!=0, true /*outputIsEvent*/, - DO_PLUS ? 4.0 : 0.0, DO_PLUS ? 2.0 : 2.0); + DO_PLUS ? 4.0 : 0.0, 2.0); } } @@ -525,7 +525,7 @@ public: MatrixWorkspace_sptr work_in1 = WorkspaceCreationHelper::createEventWorkspace(5,1,50,0.0,1.0,2); MatrixWorkspace_sptr work_in2 = eventWS_5x10_50; MatrixWorkspace_sptr work_out = performTest(work_in1,work_in2, inplace!=0, true /*outputIsEvent*/, - DO_PLUS ? 4.0 : 0.0, DO_PLUS ? 2.0 : 2.0); + DO_PLUS ? 4.0 : 0.0, 2.0); } } @@ -537,7 +537,7 @@ public: MatrixWorkspace_sptr work_in1 = WorkspaceCreationHelper::createEventWorkspace(nHist,nBins,50,0.0,1.0,2); MatrixWorkspace_sptr work_in2 = WorkspaceCreationHelper::createEventWorkspace(nHist,nBins,50,0.0,1.0,2); MatrixWorkspace_sptr work_out = performTest(work_in1,work_in2, inplace!=0, true /*outputIsEvent*/, - DO_PLUS ? 4.0 : 0.0, DO_PLUS ? 2.0 : 2.0); + DO_PLUS ? 4.0 : 0.0, 2.0); } } @@ -567,7 +567,7 @@ public: TS_ASSERT( work_in2->getSpectrum(0).hasDetectorID(100) ); MatrixWorkspace_sptr work_out = performTest(work_in1,work_in2, inplace!=0, true /*outputIsEvent*/, - DO_PLUS ? 3.0 : -1.0, DO_PLUS ? 1.7320 : 1.7320); + DO_PLUS ? 3.0 : -1.0, 1.7320); //Ya, its an event workspace TS_ASSERT(work_out); diff --git a/Framework/Algorithms/test/ReflectometryMomentumTransferTest.h b/Framework/Algorithms/test/ReflectometryMomentumTransferTest.h index d4c076943fbff006e40ab3464168ea7efd551247..1c79b75e5dd4d31d3fc878343669733291f93799 100644 --- a/Framework/Algorithms/test/ReflectometryMomentumTransferTest.h +++ b/Framework/Algorithms/test/ReflectometryMomentumTransferTest.h @@ -119,8 +119,7 @@ public: TS_ASSERT_EQUALS(outXs.size(), inXs.size()) TS_ASSERT(outputWS->hasDx(0)) const auto &inYs = inputWS->y(0); - const auto &outYs = outputWS->y(0); - TS_ASSERT_EQUALS(outYs.rawData(), inYs.rawData()) + TS_ASSERT_EQUALS(outputWS->y(0).rawData(), inYs.rawData()) const auto &inEs = inputWS->e(0); const auto &outEs = outputWS->e(0); TS_ASSERT_EQUALS(outEs.rawData(), inEs.rawData()) diff --git a/Framework/Algorithms/test/ResampleXTest.h b/Framework/Algorithms/test/ResampleXTest.h index 10eca45e800be2f7659d376bde8deccfee183d00..bb64a2500391e63add5f7ab23d0c17b0ca0125db 100644 --- a/Framework/Algorithms/test/ResampleXTest.h +++ b/Framework/Algorithms/test/ResampleXTest.h @@ -221,7 +221,6 @@ public: vector<double> xmins = alg.getProperty("XMin"); vector<double> xmaxs = alg.getProperty("XMax"); int nBins = alg.getProperty("NumberBins"); - double deltaBin; // Define tolerance for ASSERT_DELTA double tolerance = 1.0e-10; @@ -230,7 +229,8 @@ public: for (int yIndex = 0; yIndex < ylen; ++yIndex) { // The bin width for the current spectrum - deltaBin = (xmaxs[yIndex] - xmins[yIndex]) / static_cast<double>(nBins); + double deltaBin = + (xmaxs[yIndex] - xmins[yIndex]) / static_cast<double>(nBins); // Check the axes lengths TS_ASSERT_EQUALS(outWS->x(yIndex).size(), nBins + 1); @@ -344,7 +344,6 @@ public: vector<double> xmins = alg.getProperty("XMin"); vector<double> xmaxs = alg.getProperty("XMax"); int nBins = alg.getProperty("NumberBins"); - double deltaBin; // Define tolerance for ASSERT_DELTA double tolerance = 1.0e-10; @@ -354,7 +353,8 @@ public: for (int yIndex = 0; yIndex < ylen; ++yIndex) { // The bin width for the current spectrum - deltaBin = (xmaxs[yIndex] - xmins[yIndex]) / static_cast<double>(nBins); + double deltaBin = + (xmaxs[yIndex] - xmins[yIndex]) / static_cast<double>(nBins); // Check the axes lengths TS_ASSERT_EQUALS(outWS->x(yIndex).size(), nBins + 1); diff --git a/Framework/Algorithms/test/RingProfileTest.h b/Framework/Algorithms/test/RingProfileTest.h index 5eef8b18169bbb410979341208ed6fe74e542885..6081a76e993d90b2bbac0274bee8d79df6a4cca4 100644 --- a/Framework/Algorithms/test/RingProfileTest.h +++ b/Framework/Algorithms/test/RingProfileTest.h @@ -39,14 +39,6 @@ public: const std::invalid_argument &); // centre must be 2 or 3 values (x,y) or (x,y,z) - std::vector<double> justOne(1); - justOne[0] = -0.35; - // TS_ASSERT_THROWS(alg.setProperty("Centre",justOne), - // const std::invalid_argument &); - - std::vector<double> fourInputs(4, -0.45); - // TS_ASSERT_THROWS(alg.setProperty("Centre", fourInputs), - // const std::invalid_argument &); TS_ASSERT_THROWS_NOTHING( alg.setPropertyValue("OutputWorkspace", outWSName)); diff --git a/Framework/Algorithms/test/SassenaFFTTest.h b/Framework/Algorithms/test/SassenaFFTTest.h index 02725308399d37568b37fa9f3652ea1f7f16c211..575614655df6803eaef1c98dc986764b04012675 100644 --- a/Framework/Algorithms/test/SassenaFFTTest.h +++ b/Framework/Algorithms/test/SassenaFFTTest.h @@ -176,7 +176,6 @@ private: const double frErr = 1E-03; // allowed fractional error const size_t nspectra = ws->getNumberHistograms(); MantidVec yv, xv; - double factor; // remove the detailed balance condition for (size_t i = 0; i < nspectra; i++) { double goldStandard = ps2meV * (1 + static_cast<double>(i)) * @@ -186,7 +185,7 @@ private: size_t index = nbins / 2; // This position should yield ws->readX(i).at(index)==0.0 double x = ws->readX(i).at(index); - factor = exp(exponentFactor * x); + double factor = exp(exponentFactor * x); double h = yv.at(index) * exp(x); xv = ws->readX(i); MantidVec::iterator itx = xv.begin(); @@ -212,9 +211,8 @@ private: */ void Gaussian(MantidVec &xv, MantidVec &yv, const double &Heigth, const double &sigma) { - double z; for (size_t i = 0; i < xv.size(); i++) { - z = xv[i] / sigma; + double z = xv[i] / sigma; yv[i] = Heigth * exp(-z * z / 2.0); } } // void Gaussian @@ -250,12 +248,11 @@ private: xv.emplace_back(dt * static_cast<double>(j)); } - double sigma; MantidVec yv(nbins); // each spectra is a gaussian of same Height but different stdev for (size_t i = 0; i < nspectra; i++) { ws->mutableX(i) = xv; - sigma = sigma0 / (1 + static_cast<double>(i)); + double sigma = sigma0 / (1 + static_cast<double>(i)); this->Gaussian(xv, yv, Heigth, sigma); ws->mutableY(i) = yv; } diff --git a/Framework/Algorithms/test/SofQWNormalisedPolygonTest.h b/Framework/Algorithms/test/SofQWNormalisedPolygonTest.h index 9e9ca636f2815ec47f28fcfb99b7d010622ee124..88c965eb97bc846e232c37df3b48f81cd5eba9c1 100644 --- a/Framework/Algorithms/test/SofQWNormalisedPolygonTest.h +++ b/Framework/Algorithms/test/SofQWNormalisedPolygonTest.h @@ -236,6 +236,7 @@ public: TS_ASSERT_THROWS_NOTHING(alg.setProperty("EMode", "Indirect")) TS_ASSERT_THROWS_NOTHING(alg.setProperty("EFixed", 1.84)) const double dE{0.3}; + // cppcheck-suppress unreadVariable const std::vector<double> eBinParams{dE}; std::vector<double> expectedEBinEdges; const auto firstEdge = inWS->x(0).front(); diff --git a/Framework/Algorithms/test/SolidAngleTest.h b/Framework/Algorithms/test/SolidAngleTest.h index 649d35707bb3a2fd7cff740ca3ac5207a276c9ac..dc64b47dd9d8f3e508f2be42440b17c5824b4f40 100644 --- a/Framework/Algorithms/test/SolidAngleTest.h +++ b/Framework/Algorithms/test/SolidAngleTest.h @@ -213,7 +213,7 @@ public: auto spectrumInfo2 = output2D_2->spectrumInfo(); for (size_t i = 0; i < numberOfSpectra1; i++) { // all values after the start point of the second workspace should match - if (!(spectrumInfo2.isMasked(i) || spectrumInfo2.isMasked(i))) { + if (!(spectrumInfo1.isMasked(i) || spectrumInfo2.isMasked(i))) { TS_ASSERT_EQUALS(output2D_1->y(i)[0], output2D_2->y(i)[0]); } } diff --git a/Framework/Algorithms/test/SumOverlappingTubesTest.h b/Framework/Algorithms/test/SumOverlappingTubesTest.h index 191555ab6fac3c436eefbf23cb666b10d151c0d3..af23cd66dd389bfadb652d3b4a486ed105a7e09c 100644 --- a/Framework/Algorithms/test/SumOverlappingTubesTest.h +++ b/Framework/Algorithms/test/SumOverlappingTubesTest.h @@ -697,9 +697,8 @@ public: auto outWS = boost::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>( AnalysisDataService::Instance().retrieve("outWS")); - const auto &xAxis = outWS->getAxis(0); - TS_ASSERT_EQUALS(xAxis->length(), 296) - const auto &yAxis = outWS->getAxis(1); + auto yAxis = outWS->getAxis(1); + TS_ASSERT_EQUALS(outWS->getAxis(0)->length(), 296) TS_ASSERT_EQUALS(yAxis->length(), 256) for (size_t i = 0; i < 256; i++) { @@ -735,9 +734,8 @@ public: auto outWS = boost::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>( AnalysisDataService::Instance().retrieve("outWS")); - const auto &xAxis = outWS->getAxis(0); - TS_ASSERT_EQUALS(xAxis->length(), 296) - const auto &yAxis = outWS->getAxis(1); + auto yAxis = outWS->getAxis(1); + TS_ASSERT_EQUALS(outWS->getAxis(0)->length(), 296) TS_ASSERT_EQUALS(yAxis->length(), 256) for (size_t i = 0; i < 256; i++) { diff --git a/Framework/Algorithms/test/SumSpectraTest.h b/Framework/Algorithms/test/SumSpectraTest.h index ebbbb6cffb67c155072490e9fa7906c040a3d154..664c39b90ea42fbdb745a723d4a78c058fc439cc 100644 --- a/Framework/Algorithms/test/SumSpectraTest.h +++ b/Framework/Algorithms/test/SumSpectraTest.h @@ -568,7 +568,6 @@ public: testSig = std::sqrt(testSig); // Set the properties alg2.setProperty("InputWorkspace", tws); - const std::string outputSpace2 = "SumSpectraOut2"; alg2.setPropertyValue("OutputWorkspace", outName); alg2.setProperty("IncludeMonitors", false); alg2.setProperty("WeightedSum", true); diff --git a/Framework/Crystal/inc/MantidCrystal/IndexSXPeaks.h b/Framework/Crystal/inc/MantidCrystal/IndexSXPeaks.h index 2cb20904b9f2dac28c596c1d47e1f34c569d00f1..1698015e4c99d208f0af9536a9e0c1d0e81a0a5b 100644 --- a/Framework/Crystal/inc/MantidCrystal/IndexSXPeaks.h +++ b/Framework/Crystal/inc/MantidCrystal/IndexSXPeaks.h @@ -99,10 +99,10 @@ public: std::set<index> s1; std::set<index> s2; for (it1 = _hkls.begin(); it1 != _hkls.end(); - it1++) // All possible vectors for hkl on current instance + ++it1) // All possible vectors for hkl on current instance { for (it2 = rhs._hkls.begin(); it2 != rhs._hkls.end(); - it2++) // All possible vectors for hkl on other + ++it2) // All possible vectors for hkl on other { const index &index1 = *it1; const index &index2 = *it2; diff --git a/Framework/Crystal/test/PeaksInRegionTest.h b/Framework/Crystal/test/PeaksInRegionTest.h index 2e5510a1f62c0d67e2a4bbf8588873a110512790..e3bca14a6c9f2e8d90f69b80bbcf639c9c9650cb 100644 --- a/Framework/Crystal/test/PeaksInRegionTest.h +++ b/Framework/Crystal/test/PeaksInRegionTest.h @@ -304,14 +304,12 @@ public: double peakRadius = 0.49; // not enough for the sphere to penetrate the // bounding box. Expect failure do_test_bounds_check_extents(coordinateFrame, -wallDistanceFromPeakCenter, - 1, 1, 1, 1, 1, peakRadius, - peakRadius > wallDistanceFromPeakCenter); + 1, 1, 1, 1, 1, peakRadius, false); peakRadius = 0.51; // just enough for the sphere to penetrate the bounding // box. Expect pass. do_test_bounds_check_extents(coordinateFrame, -wallDistanceFromPeakCenter, - 1, 1, 1, 1, 1, peakRadius, - peakRadius > wallDistanceFromPeakCenter); + 1, 1, 1, 1, 1, peakRadius, true); } void test_peak_intersects_xmax_boundary_when_radius_large_enough() { @@ -320,15 +318,15 @@ public: double peakRadius = 0.49; // not enough for the sphere to penetrate the // bounding box. Expect failure - do_test_bounds_check_extents( - coordinateFrame, 1, -wallDistanceFromPeakCenter, 1, 1, 1, 1, peakRadius, - peakRadius > wallDistanceFromPeakCenter); + do_test_bounds_check_extents(coordinateFrame, 1, + -wallDistanceFromPeakCenter, 1, 1, 1, 1, + peakRadius, false); peakRadius = 0.51; // just enough for the sphere to penetrate the bounding // box. Expect pass. - do_test_bounds_check_extents( - coordinateFrame, 1, -wallDistanceFromPeakCenter, 1, 1, 1, 1, peakRadius, - peakRadius > wallDistanceFromPeakCenter); + do_test_bounds_check_extents(coordinateFrame, 1, + -wallDistanceFromPeakCenter, 1, 1, 1, 1, + peakRadius, true); } void test_peak_intersects_ymin_boundary_when_radius_large_enough() { @@ -337,15 +335,15 @@ public: double peakRadius = 0.49; // not enough for the sphere to penetrate the // bounding box. Expect failure - do_test_bounds_check_extents( - coordinateFrame, 1, 1, -wallDistanceFromPeakCenter, 1, 1, 1, peakRadius, - peakRadius > wallDistanceFromPeakCenter); + do_test_bounds_check_extents(coordinateFrame, 1, 1, + -wallDistanceFromPeakCenter, 1, 1, 1, + peakRadius, false); peakRadius = 0.51; // just enough for the sphere to penetrate the bounding // box. Expect pass. - do_test_bounds_check_extents( - coordinateFrame, 1, 1, -wallDistanceFromPeakCenter, 1, 1, 1, peakRadius, - peakRadius > wallDistanceFromPeakCenter); + do_test_bounds_check_extents(coordinateFrame, 1, 1, + -wallDistanceFromPeakCenter, 1, 1, 1, + peakRadius, true); } void test_peak_intersects_ymax_boundary_when_radius_large_enough() { @@ -356,13 +354,13 @@ public: // bounding box. Expect failure do_test_bounds_check_extents(coordinateFrame, 1, 1, 1, -wallDistanceFromPeakCenter, 1, 1, peakRadius, - peakRadius > wallDistanceFromPeakCenter); + false); peakRadius = 0.51; // just enough for the sphere to penetrate the bounding // box. Expect pass. do_test_bounds_check_extents(coordinateFrame, 1, 1, 1, -wallDistanceFromPeakCenter, 1, 1, peakRadius, - peakRadius > wallDistanceFromPeakCenter); + true); } void test_peak_intersects_zmin_boundary_when_radius_large_enough() { @@ -373,13 +371,13 @@ public: // bounding box. Expect failure do_test_bounds_check_extents(coordinateFrame, 1, 1, 1, 1, -wallDistanceFromPeakCenter, 1, peakRadius, - peakRadius > wallDistanceFromPeakCenter); + false); peakRadius = 0.51; // just enough for the sphere to penetrate the bounding // box. Expect pass. do_test_bounds_check_extents(coordinateFrame, 1, 1, 1, 1, -wallDistanceFromPeakCenter, 1, peakRadius, - peakRadius > wallDistanceFromPeakCenter); + true); } void test_peak_intersects_zmax_boundary_when_radius_large_enough() { @@ -390,13 +388,12 @@ public: // bounding box. Expect failure do_test_bounds_check_extents(coordinateFrame, 1, 1, 1, 1, 1, -wallDistanceFromPeakCenter, peakRadius, - peakRadius > wallDistanceFromPeakCenter); + false); peakRadius = 0.51; // just enough for the sphere to penetrate the bounding // box. Expect pass. do_test_bounds_check_extents(coordinateFrame, 1, 1, 1, 1, 1, - -wallDistanceFromPeakCenter, peakRadius, - peakRadius > wallDistanceFromPeakCenter); + -wallDistanceFromPeakCenter, peakRadius, true); } void test_false_intersection_when_check_peak_extents() { diff --git a/Framework/Crystal/test/SaveIsawUBTest.h b/Framework/Crystal/test/SaveIsawUBTest.h index 2f3394f32adf258721b14e3cd155ed25f7805944..e7cbf2bd73192d9a9382bfa6808208b3441283d0 100644 --- a/Framework/Crystal/test/SaveIsawUBTest.h +++ b/Framework/Crystal/test/SaveIsawUBTest.h @@ -90,15 +90,13 @@ public: F1.open(File1.c_str()); F2.open(File2.c_str()); - int line = 1; std::string s; - double val1, val2; - double tolerance; - if (F1.good() && F2.good()) + if (F1.good() && F2.good()) { + int line = 1; for (int row = 0; row < 5; row++) { int NNums = 3; - tolerance = .0000003; + double tolerance = .0000003; if (line > 3) { NNums = 7; tolerance = .0003; @@ -107,6 +105,7 @@ public: for (int N = 0; N < NNums; N++) { s = Mantid::Kernel::Strings::getWord(F1, false); + double val1, val2; if (!Mantid::Kernel::Strings::convert<double>(s, val1)) { stringstream message; message << "Characters on line " << line << " word " << N; @@ -128,7 +127,7 @@ public: Mantid::Kernel::Strings::readToEndOfLine(F2, true); line++; } - else { + } else { TS_ASSERT(F1.good()); TS_ASSERT(F2.good()); remove(File2.c_str()); diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/LeBailFit.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/LeBailFit.h index 8b44d19e3aaca1e8f8fe9b3e14ba37d7a7beeefc..0d881f945b04203bf9be092a08c0bb5d18836f70 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/LeBailFit.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/LeBailFit.h @@ -37,26 +37,26 @@ namespace Algorithms { struct Parameter { // Regular std::string name; - double curvalue; - double prevalue; - double minvalue; - double maxvalue; - bool fit; - double stepsize; - double fiterror; + double curvalue = 0; + double prevalue = 0; + double minvalue = 0; + double maxvalue = 0; + bool fit = false; + double stepsize = 0; + double fiterror = 0; // Monte Carlo - bool nonnegative; - double mcA0; - double mcA1; + bool nonnegative = false; + double mcA0 = 0; + double mcA1 = 0; // Monte Carlo record - double sumstepsize; - double maxabsstepsize; - double maxrecordvalue; - double minrecordvalue; - size_t numpositivemove; - size_t numnegativemove; - size_t numnomove; - int movedirection; + double sumstepsize = 0; + double maxabsstepsize = 0; + double maxrecordvalue = 0; + double minrecordvalue = 0; + size_t numpositivemove = 0; + size_t numnegativemove = 0; + size_t numnomove = 0; + int movedirection = 0; }; class MANTID_CURVEFITTING_DLL LeBailFit : public API::Algorithm { diff --git a/Framework/CurveFitting/src/CostFunctions/CostFuncFitting.cpp b/Framework/CurveFitting/src/CostFunctions/CostFuncFitting.cpp index 6beaae1204223bdaaeab1657a08f10ada8cad1a0..d458a539489e5b3d15bd4f175c6ea73d8c4d3627 100644 --- a/Framework/CurveFitting/src/CostFunctions/CostFuncFitting.cpp +++ b/Framework/CurveFitting/src/CostFunctions/CostFuncFitting.cpp @@ -128,7 +128,8 @@ void CostFuncFitting::calActiveCovarianceMatrix(GSLMatrix &covar, // construct the jacobian GSLJacobian J(*m_function, m_values->size()); size_t na = this->nParams(); // number of active parameters - assert(J.getJ()->size2 == na); + auto j = J.getJ(); + assert(j->size2 == na); covar.resize(na, na); // calculate the derivatives diff --git a/Framework/CurveFitting/src/MultiDomainCreator.cpp b/Framework/CurveFitting/src/MultiDomainCreator.cpp index 977cc3f0e5515924528b4b3c9fdface768991680..6e3f69ff2d8d7de395867537350733211e81b77f 100644 --- a/Framework/CurveFitting/src/MultiDomainCreator.cpp +++ b/Framework/CurveFitting/src/MultiDomainCreator.cpp @@ -15,6 +15,7 @@ #include "MantidAPI/WorkspaceProperty.h" #include "MantidKernel/Logger.h" +#include <memory> #include <sstream> #include <stdexcept> @@ -46,11 +47,12 @@ void MultiDomainCreator::createDomain( "Cannot create JointDomain: number of workspaces does not match " "the number of creators"); } - auto jointDomain = new API::JointDomain; + auto jointDomain = std::make_unique<API::JointDomain>(); API::FunctionValues_sptr values; i0 = 0; for (auto &creator : m_creators) { if (!creator) { + throw std::runtime_error("Missing domain creator"); } API::FunctionDomain_sptr domain; @@ -58,7 +60,7 @@ void MultiDomainCreator::createDomain( jointDomain->addDomain(domain); i0 += domain->size(); } - domain.reset(jointDomain); + domain.reset(jointDomain.release()); ivalues = values; } diff --git a/Framework/CurveFitting/test/Algorithms/FitTest.h b/Framework/CurveFitting/test/Algorithms/FitTest.h index e0b16441c01ce1ca18cbb2fc6a29a384300ea5c8..48a3e74d71ce679d4ce7e2cc324b71070baebfcb 100644 --- a/Framework/CurveFitting/test/Algorithms/FitTest.h +++ b/Framework/CurveFitting/test/Algorithms/FitTest.h @@ -1029,7 +1029,6 @@ public: TS_ASSERT(alg2.isInitialized()); // create mock data to test against - const std::string wsName = "ExpDecayMockData"; const int histogramNumber = 1; const int timechannels = 20; Workspace_sptr ws = WorkspaceFactory::Instance().create( diff --git a/Framework/CurveFitting/test/Algorithms/LeBailFitTest.h b/Framework/CurveFitting/test/Algorithms/LeBailFitTest.h index c409cc7084ebacd9a37f42615507852b1da5a5eb..1977a54d00df4fa38490b93b4e7a196afb47fb6b 100644 --- a/Framework/CurveFitting/test/Algorithms/LeBailFitTest.h +++ b/Framework/CurveFitting/test/Algorithms/LeBailFitTest.h @@ -500,17 +500,9 @@ API::MatrixWorkspace_sptr createInputDataWorkspace(int option) { break; } - } else if (option == 4) { + } else { // Load from column file throw runtime_error("Using .dat file is not allowed for committing. "); - string datafilename("PG3_4862_Bank7.dat"); - string wsname("Data"); - importDataFromColumnFile(datafilename, wsname); - dataws = boost::dynamic_pointer_cast<MatrixWorkspace>( - AnalysisDataService::Instance().retrieve(wsname)); - } else { - // not supported - throw std::invalid_argument("Logic error. "); } return dataws; diff --git a/Framework/CurveFitting/test/Algorithms/LeBailFunctionTest.h b/Framework/CurveFitting/test/Algorithms/LeBailFunctionTest.h index cecfffc5b4b93ba29c6888b09f0e6a59f96223c9..b8b8ab8d8a392ef556ec797d1e665d4de0a639d8 100644 --- a/Framework/CurveFitting/test/Algorithms/LeBailFunctionTest.h +++ b/Framework/CurveFitting/test/Algorithms/LeBailFunctionTest.h @@ -216,7 +216,7 @@ public: << imax111 << "-th points.\n"; // Calculate diffraction patters - auto out = lebailfunction.function(vecX, true, false); + lebailfunction.function(vecX, true, false); TS_ASSERT_THROWS_ANYTHING(lebailfunction.function(vecX, true, true)); vector<string> vecbkgdparnames(2); @@ -228,7 +228,7 @@ public: lebailfunction.addBackgroundFunction("Polynomial", 2, vecbkgdparnames, bkgdvec, vecX.front(), vecX.back()); - out = lebailfunction.function(vecX, true, true); + auto out = lebailfunction.function(vecX, true, true); double v1 = out[imax111]; double v2 = out[imax110]; @@ -441,7 +441,6 @@ public: if (line[0] != '#') { double x, y; std::stringstream ss; - std::string dataline(line); ss.str(line); ss >> x >> y; vecX.emplace_back(x); diff --git a/Framework/CurveFitting/test/Algorithms/PlotPeakByLogValueTest.h b/Framework/CurveFitting/test/Algorithms/PlotPeakByLogValueTest.h index df033698c0bcb8006e1a55f943594dc5483f245f..5376a94005d77960d582dfee9c40685925a068fa 100644 --- a/Framework/CurveFitting/test/Algorithms/PlotPeakByLogValueTest.h +++ b/Framework/CurveFitting/test/Algorithms/PlotPeakByLogValueTest.h @@ -625,8 +625,6 @@ private: ws->setSharedX(1, ws->sharedX(0)); ws->setSharedX(2, ws->sharedX(0)); - std::vector<double> amps{20.0, 30.0, 25.0}; - std::vector<double> cents{0.0, 0.1, -1.0}; std::vector<double> fwhms{1.0, 1.1, 0.6}; for (size_t i = 0; i < 3; ++i) { std::string fun = "name=FlatBackground,A0=" + std::to_string(fwhms[i]); diff --git a/Framework/CurveFitting/test/Algorithms/RefinePowderInstrumentParametersTest.h b/Framework/CurveFitting/test/Algorithms/RefinePowderInstrumentParametersTest.h index e77dff704c4548c7e8a631f7b5c06719c5391047..487a1b787c4d1637629e03648415c6916b6081b4 100644 --- a/Framework/CurveFitting/test/Algorithms/RefinePowderInstrumentParametersTest.h +++ b/Framework/CurveFitting/test/Algorithms/RefinePowderInstrumentParametersTest.h @@ -462,14 +462,14 @@ public: while (ins.getline(line, 256)) { if (line[0] != '#') { std::string parname; - double parvalue, parmin, parmax, parstepsize; - + double parvalue; std::stringstream ss; ss.str(line); ss >> parname >> parvalue; parameters.emplace(parname, parvalue); try { + double parmin, parmax, parstepsize; ss >> parmin >> parmax >> parstepsize; vector<double> mcpars; mcpars.emplace_back(parmin); diff --git a/Framework/CurveFitting/test/FitMWTest.h b/Framework/CurveFitting/test/FitMWTest.h index 17aff569670c5a3273d45792ddb6f54e059038ed..7e170fb5a74d035901b9797dd0ccb050eb719ed6 100644 --- a/Framework/CurveFitting/test/FitMWTest.h +++ b/Framework/CurveFitting/test/FitMWTest.h @@ -497,8 +497,6 @@ public: test_Composite_Function_With_SeparateMembers_Option_On_FitMW_Outputs_Composite_Values_Plus_Each_Member() { const bool histogram = true; auto ws2 = createTestWorkspace(histogram); - const std::string inputWSName = "FitMWTest_CompositeTest"; - // AnalysisDataService::Instance().add(inputWSName, ws2); auto composite = boost::make_shared<API::CompositeFunction>(); API::IFunction_sptr expDecay(new ExpDecay); diff --git a/Framework/CurveFitting/test/Functions/ComptonPeakProfileTest.h b/Framework/CurveFitting/test/Functions/ComptonPeakProfileTest.h index 04247920fe6b37a572a9c2f9ad9f5c9c9340d5d9..26dde36728e84ed9d9850b243b84898b2b6107a6 100644 --- a/Framework/CurveFitting/test/Functions/ComptonPeakProfileTest.h +++ b/Framework/CurveFitting/test/Functions/ComptonPeakProfileTest.h @@ -31,13 +31,13 @@ public: void test_initialized_object_has_expected_attributes() { auto profile = createFunction(); static const size_t nattrs(3); - const char *expectedAttrs[nattrs] = {"WorkspaceIndex", "Mass", - "VoigtEnergyCutOff"}; TS_ASSERT_EQUALS(nattrs, profile->nAttributes()); // Test names as they are used in scripts if (profile->nAttributes() > 0) { + const char *expectedAttrs[nattrs] = {"WorkspaceIndex", "Mass", + "VoigtEnergyCutOff"}; std::unordered_set<std::string> expectedAttrSet(expectedAttrs, expectedAttrs + nattrs); std::vector<std::string> actualNames = profile->getAttributeNames(); diff --git a/Framework/CurveFitting/test/Functions/ComptonProfileTest.h b/Framework/CurveFitting/test/Functions/ComptonProfileTest.h index 2e4458bacbd7f6eb1edb2fe850e1d6a3b62a9637..cadb3838c6a86b4a9e095993dffaa2a7b2928dc2 100644 --- a/Framework/CurveFitting/test/Functions/ComptonProfileTest.h +++ b/Framework/CurveFitting/test/Functions/ComptonProfileTest.h @@ -30,12 +30,12 @@ public: void test_initialized_object_has_expected_parameters() { auto profile = createFunction(); static const size_t nparams(1); - const char *expectedParams[nparams] = {"Mass"}; TS_ASSERT_EQUALS(nparams, profile->nParams()); // Test names as they are used in scripts if (profile->nParams() > 0) { + const char *expectedParams[nparams] = {"Mass"}; std::unordered_set<std::string> expectedParamStr( expectedParams, expectedParams + nparams); std::vector<std::string> actualNames = profile->getParameterNames(); diff --git a/Framework/CurveFitting/test/Functions/ConvolutionTest.h b/Framework/CurveFitting/test/Functions/ConvolutionTest.h index a3c0ecac4f951103b1c209eae9059900eefd60b9..22e235d588f81cf1fd7be2a2f4d06e0fcc4e49a6 100644 --- a/Framework/CurveFitting/test/Functions/ConvolutionTest.h +++ b/Framework/CurveFitting/test/Functions/ConvolutionTest.h @@ -180,8 +180,7 @@ public: linear->setParameter(0, 0.1); linear->setParameter(1, 0.2); - size_t iFun = 10000; - iFun = conv.addFunction(linear); + size_t iFun = conv.addFunction(linear); TS_ASSERT_EQUALS(iFun, 0); iFun = conv.addFunction(gauss1); TS_ASSERT_EQUALS(iFun, 1); diff --git a/Framework/CurveFitting/test/Functions/GaussianComptonProfileTest.h b/Framework/CurveFitting/test/Functions/GaussianComptonProfileTest.h index c3e722502b5f1f03591bd802095a473346a0f5be..805d3b956f9de8bcf9a2b5decdd4b12d7323ebe1 100644 --- a/Framework/CurveFitting/test/Functions/GaussianComptonProfileTest.h +++ b/Framework/CurveFitting/test/Functions/GaussianComptonProfileTest.h @@ -33,12 +33,13 @@ public: void test_Initialized_Function_Has_Expected_Parameters_In_Right_Order() { Mantid::API::IFunction_sptr profile = createFunction(); static const size_t nparams(3); - const char *expectedParams[nparams] = {"Mass", "Width", "Intensity"}; auto currentNames = profile->getParameterNames(); const size_t nnames = currentNames.size(); TS_ASSERT_EQUALS(nparams, nnames); + if (nnames == nparams) { + const char *expectedParams[nparams] = {"Mass", "Width", "Intensity"}; for (size_t i = 0; i < nnames; ++i) { TS_ASSERT_EQUALS(expectedParams[i], currentNames[i]); } diff --git a/Framework/CurveFitting/test/Functions/GramCharlierComptonProfileTest.h b/Framework/CurveFitting/test/Functions/GramCharlierComptonProfileTest.h index 1ca51c7a7ca236916e227fb1d504da9f6c11a866..5a03d55af9c25b45b38d3cd347728896fa03826e 100644 --- a/Framework/CurveFitting/test/Functions/GramCharlierComptonProfileTest.h +++ b/Framework/CurveFitting/test/Functions/GramCharlierComptonProfileTest.h @@ -152,12 +152,12 @@ private: void checkDefaultParametersExist(const Mantid::API::IFunction &profile) { static const size_t nparams(3); - const char *expectedParams[nparams] = {"Mass", "Width", "FSECoeff"}; auto currentNames = profile.getParameterNames(); const size_t nnames = currentNames.size(); TS_ASSERT_LESS_THAN_EQUALS(nparams, nnames); if (nnames <= nparams) { + const char *expectedParams[nparams] = {"Mass", "Width", "FSECoeff"}; for (size_t i = 0; i < nnames; ++i) { TS_ASSERT_EQUALS(expectedParams[i], currentNames[i]); } diff --git a/Framework/CurveFitting/test/Functions/MultivariateGaussianComptonProfileTest.h b/Framework/CurveFitting/test/Functions/MultivariateGaussianComptonProfileTest.h index 6a05454222ed3e6066dab20e16dd2d59e51531cb..aa73d35207f35a8368c210c8585e6094da5efeb4 100644 --- a/Framework/CurveFitting/test/Functions/MultivariateGaussianComptonProfileTest.h +++ b/Framework/CurveFitting/test/Functions/MultivariateGaussianComptonProfileTest.h @@ -33,12 +33,12 @@ public: void test_Initialized_Function_Has_Expected_Parameters_In_Right_Order() { Mantid::API::IFunction_sptr profile = createFunction(); static const size_t nparams(5); - const char *expectedParams[nparams] = {"Mass", "Intensity", "SigmaX", - "SigmaY", "SigmaZ"}; auto currentNames = profile->getParameterNames(); const size_t nnames = currentNames.size(); TS_ASSERT_EQUALS(nparams, nnames); if (nnames == nparams) { + const char *expectedParams[nparams] = {"Mass", "Intensity", "SigmaX", + "SigmaY", "SigmaZ"}; for (size_t i = 0; i < nnames; ++i) { TS_ASSERT_EQUALS(expectedParams[i], currentNames[i]); } @@ -48,12 +48,12 @@ public: void test_Initialized_Function_Has_Expected_Attributes() { Mantid::API::IFunction_sptr profile = createFunction(); static const size_t nattrs(1); - const char *expectedAttrs[nattrs] = {"IntegrationSteps"}; TS_ASSERT_EQUALS(nattrs, profile->nAttributes()); // Test names as they are used in scripts if (profile->nAttributes() > 0) { + const char *expectedAttrs[nattrs] = {"IntegrationSteps"}; std::set<std::string> expectedAttrSet(expectedAttrs, expectedAttrs + nattrs); std::vector<std::string> actualNames = profile->getAttributeNames(); diff --git a/Framework/CurveFitting/test/Functions/ProductFunctionTest.h b/Framework/CurveFitting/test/Functions/ProductFunctionTest.h index b6c4459276e2b73dd2ea4cdd03d16eb79474b8d7..8596d48dad3f5b078384f26a78c6af78bf8d393e 100644 --- a/Framework/CurveFitting/test/Functions/ProductFunctionTest.h +++ b/Framework/CurveFitting/test/Functions/ProductFunctionTest.h @@ -116,8 +116,7 @@ public: linear->setParameter(0, 0.1); linear->setParameter(1, 0.2); - size_t iFun = 100000; - iFun = prodF.addFunction(linear); + size_t iFun = prodF.addFunction(linear); TS_ASSERT_EQUALS(iFun, 0); iFun = prodF.addFunction(gauss1); TS_ASSERT_EQUALS(iFun, 1); diff --git a/Framework/DataHandling/src/FilterEventsByLogValuePreNexus.cpp b/Framework/DataHandling/src/FilterEventsByLogValuePreNexus.cpp index 813d39664b66513c2351d7355750427783efd7ce..b1ee58199cd933414d235b1e1e19863538ef326a 100644 --- a/Framework/DataHandling/src/FilterEventsByLogValuePreNexus.cpp +++ b/Framework/DataHandling/src/FilterEventsByLogValuePreNexus.cpp @@ -931,7 +931,6 @@ void FilterEventsByLogValuePreNexus::procEvents( << " threads" << " in " << numBlocks << " blocks. " << "\n"; - // cppcheck-suppress syntaxError PRAGMA_OMP( parallel for schedule(dynamic, 1) if (m_parallelProcessing) ) for (int i = 0; i < int(numThreads); i++) { @@ -955,7 +954,7 @@ void FilterEventsByLogValuePreNexus::procEvents( // value = pointer to the events vector eventVectors[i] = new EventVector_pt[m_detid_max + 1]; EventVector_pt *theseEventVectors = eventVectors[i]; - for (detid_t j = 0; j < m_detid_max + 1; j++) { + for (detid_t j = 0; j < m_detid_max + 1; ++j) { size_t wi = m_pixelToWkspindex[j]; // Save a POINTER to the vector<tofEvent> theseEventVectors[j] = &partWS->getSpectrum(wi).getEvents(); @@ -1134,15 +1133,13 @@ void FilterEventsByLogValuePreNexus::procEventsLinear( << m_maxNumEvents << "\n"; maxeventid = m_maxNumEvents + 1; - size_t numbadeventindex = 0; - int numeventswritten = 0; // Declare local statistic parameters size_t local_numErrorEvents = 0; size_t local_numBadEvents = 0; - size_t local_numWrongdetidEvents = 0; size_t local_numIgnoredEvents = 0; + size_t local_numWrongdetidEvents = 0; size_t local_numGoodEvents = 0; double local_m_shortestTof = static_cast<double>(MAX_TOF_UINT32) * TOF_CONVERSION; @@ -1162,8 +1159,6 @@ void FilterEventsByLogValuePreNexus::procEventsLinear( int64_t i_pulse = 0; for (size_t ievent = 0; ievent < current_event_buffer_size; ++ievent) { - bool iswrongdetid = false; - // Load DasEvent DasEvent &tempevent = *(event_buffer + ievent); @@ -1187,6 +1182,7 @@ void FilterEventsByLogValuePreNexus::procEventsLinear( pixelid = this->m_pixelmap[unmapped_pid]; } + bool iswrongdetid = false; // Check special/wrong pixel IDs against max Detector ID if (pixelid > static_cast<PixelType>(m_detid_max)) { // Record the wrong/special ID @@ -1368,12 +1364,6 @@ void FilterEventsByLogValuePreNexus::procEventsLinear( if (local_m_longestTof > m_longestTof) m_longestTof = local_m_longestTof; } - - if (numbadeventindex > 0) { - g_log.notice() << "Single block: Encountered " << numbadeventindex - << " bad event indexes" - << "\n"; - } } //---------------------------------------------------------------------------------------------- @@ -1559,7 +1549,7 @@ void FilterEventsByLogValuePreNexus::filterEvents() { // value = pointer to the events vector eventVectors[i] = new EventVector_pt[m_detid_max + 1]; EventVector_pt *theseEventVectors = eventVectors[i]; - for (detid_t j = 0; j < m_detid_max + 1; j++) { + for (detid_t j = 0; j < m_detid_max + 1; ++j) { size_t wi = m_pixelToWkspindex[j]; // Save a POINTER to the vector<tofEvent> if (wi != static_cast<size_t>(-1)) @@ -1738,8 +1728,6 @@ void FilterEventsByLogValuePreNexus::filterEventsLinear( << m_maxNumEvents << "\n"; maxeventid = m_maxNumEvents + 1; - size_t numbadeventindex = 0; - // Declare local statistic parameters size_t local_numErrorEvents = 0; size_t local_numBadEvents = 0; @@ -1825,8 +1813,6 @@ void FilterEventsByLogValuePreNexus::filterEventsLinear( g_log.notice() << "[DB] L1 = " << l1 << "\n"; for (size_t ievent = 0; ievent < current_event_buffer_size; ++ievent) { - bool iswrongdetid = false; - bool islogevent = false; // Load DasEvent DasEvent &tempevent = *(event_buffer + ievent); @@ -1841,6 +1827,9 @@ void FilterEventsByLogValuePreNexus::filterEventsLinear( local_numBadEvents++; continue; } else { + bool islogevent = false; + bool iswrongdetid = false; + // Covert DAS Pixel ID to Mantid Pixel ID if (pixelid == 1073741843) { // downstream monitor pixel for SNAP @@ -2108,8 +2097,6 @@ void FilterEventsByLogValuePreNexus::filterEventsLinear( m_longestTof = local_m_longestTof; } - g_log.notice() << "Encountered " << numbadeventindex << " bad event indexes" - << "\n"; } // FilterEventsLinearly //---------------------------------------------------------------------------------------------- @@ -2369,8 +2356,6 @@ void FilterEventsByLogValuePreNexus::readPulseidFile( } } - double temp; - if (m_numPulses > 0) { DateAndTime lastPulseDateTime(0, 0); this->pulsetimes.reserve(m_numPulses); @@ -2385,7 +2370,7 @@ void FilterEventsByLogValuePreNexus::readPulseidFile( else lastPulseDateTime = pulseDateTime; - temp = pulse.pCurrent; + double temp = pulse.pCurrent; this->m_protonCharge.emplace_back(temp); if (temp < 0.) this->g_log.warning("Individual proton charge < 0 being ignored"); diff --git a/Framework/DataHandling/src/GroupDetectors2.cpp b/Framework/DataHandling/src/GroupDetectors2.cpp index 573a4c4d4e039e75761300da691445bdc096acab..85655ee45d91a091f8557b1146c8a514bfbee58c 100644 --- a/Framework/DataHandling/src/GroupDetectors2.cpp +++ b/Framework/DataHandling/src/GroupDetectors2.cpp @@ -646,7 +646,6 @@ void GroupDetectors2::processGroupingWorkspace( size_t groupid = static_cast<int>(groupWS->y(i)[0]); // group 0 is are unused spectra - don't process them if (groupid > 0) { - // cppcheck-suppress stlFindInsert if (group2WSIndexSetmap.find(groupid) == group2WSIndexSetmap.end()) { // not found - create an empty set group2WSIndexSetmap.emplace(groupid, std::set<size_t>()); @@ -697,8 +696,6 @@ void GroupDetectors2::processMatrixWorkspace( for (size_t i = 0; i < spectrumInfo.size(); ++i) { // read spectra from groupingws size_t groupid = i; - - // cppcheck-suppress stlFindInsert if (group2WSIndexSetmap.find(groupid) == group2WSIndexSetmap.end()) { // not found - create an empty set group2WSIndexSetmap.emplace(groupid, std::set<size_t>()); diff --git a/Framework/DataHandling/src/LoadEMU.cpp b/Framework/DataHandling/src/LoadEMU.cpp index 99f65416e8314f7ca124ae359d4e30a808f6bcde..24443dec1cbed536bb6d8059bee27b62f3896c84 100644 --- a/Framework/DataHandling/src/LoadEMU.cpp +++ b/Framework/DataHandling/src/LoadEMU.cpp @@ -690,7 +690,7 @@ void LoadEMU<FD>::exec(const std::string &hdfFile, // double sampleAnalyser = iparam("SampleAnalyser"); auto endID = static_cast<detid_t>(DETECTOR_TUBES * PIXELS_PER_TUBE); - for (detid_t detID = 0; detID < endID; detID++) + for (detid_t detID = 0; detID < endID; ++detID) updateNeutronicPostions(detID, sampleAnalyser); // get the detector map from raw input to a physical detector diff --git a/Framework/DataHandling/src/LoadEventPreNexus2.cpp b/Framework/DataHandling/src/LoadEventPreNexus2.cpp index 09bca136ffdd8845c6224bc14efa96d5e02ee674..447ae3efef5c428fc26df9a69020bdf5283c27c6 100644 --- a/Framework/DataHandling/src/LoadEventPreNexus2.cpp +++ b/Framework/DataHandling/src/LoadEventPreNexus2.cpp @@ -758,7 +758,6 @@ void LoadEventPreNexus2::procEvents( partWorkspaces.resize(numThreads); buffers.resize(numThreads); eventVectors = new EventVector_pt *[numThreads]; - // cppcheck-suppress syntaxError PRAGMA_OMP( parallel for if (parallelProcessing) ) for (int i = 0; i < int(numThreads); i++) { @@ -781,7 +780,7 @@ void LoadEventPreNexus2::procEvents( // value = pointer to the events vector eventVectors[i] = new EventVector_pt[detid_max + 1]; EventVector_pt *theseEventVectors = eventVectors[i]; - for (detid_t j = 0; j < detid_max + 1; j++) { + for (detid_t j = 0; j < detid_max + 1; ++j) { size_t wi = pixel_to_wkspindex[j]; // Save a POINTER to the vector<tofEvent> if (wi != static_cast<size_t>(-1)) @@ -1323,7 +1322,6 @@ void LoadEventPreNexus2::readPulseidFile(const std::string &filename, } if (num_pulses > 0) { - double temp; DateAndTime lastPulseDateTime(0, 0); this->pulsetimes.reserve(num_pulses); for (const auto &pulse : pulses) { @@ -1337,7 +1335,7 @@ void LoadEventPreNexus2::readPulseidFile(const std::string &filename, else lastPulseDateTime = pulseDateTime; - temp = pulse.pCurrent; + double temp = pulse.pCurrent; this->proton_charge.emplace_back(temp); if (temp < 0.) this->g_log.warning("Individual proton charge < 0 being ignored"); diff --git a/Framework/DataHandling/src/LoadGSASInstrumentFile.cpp b/Framework/DataHandling/src/LoadGSASInstrumentFile.cpp index c72b0bda3f223a7c5bfdd7881d14812abac012d2..e5174ebb212284c9e6c338c5620b925fcc701482 100644 --- a/Framework/DataHandling/src/LoadGSASInstrumentFile.cpp +++ b/Framework/DataHandling/src/LoadGSASInstrumentFile.cpp @@ -255,7 +255,7 @@ LoadGSASInstrumentFile::getHistogramType(const vector<string> &lines) { // We assume there is just one HTYPE line, look for it from beginning and // return its value. std::string lookFor = "INS HTYPE"; - for (size_t i = 0; i <= lines.size(); ++i) { + for (size_t i = 0; i < lines.size(); ++i) { if (lines[i].substr(0, lookFor.size()) == lookFor) { if (lines[i].size() < lookFor.size() + 7) { // line too short @@ -275,7 +275,7 @@ size_t LoadGSASInstrumentFile::getNumberOfBanks(const vector<string> &lines) { // We assume there is just one BANK line, look for it from beginning and // return its value. std::string lookFor = "INS BANK"; - for (size_t i = 0; i <= lines.size(); ++i) { + for (size_t i = 0; i < lines.size(); ++i) { if (lines[i].substr(0, lookFor.size()) == lookFor) { if (lines[i].size() < lookFor.size() + 3) { // line too short diff --git a/Framework/DataHandling/src/LoadNXSPE.cpp b/Framework/DataHandling/src/LoadNXSPE.cpp index 3835e25d6ad81e2c1813830c369207072e8d0362..d574160974ec110053d45bc50f15e4d6f149e02a 100644 --- a/Framework/DataHandling/src/LoadNXSPE.cpp +++ b/Framework/DataHandling/src/LoadNXSPE.cpp @@ -353,10 +353,13 @@ void LoadNXSPE::exec() { boost::shared_ptr<Geometry::CSGObject> LoadNXSPE::createCuboid(double dx, double dy, double dz) { + UNUSED_ARG(dx) + UNUSED_ARG(dy) + UNUSED_ARG(dz) - dx = 0.5 * std::fabs(dx); - dy = 0.5 * std::fabs(dy); - dz = 0.5 * std::fabs(dz); + // dx = 0.5 * std::fabs(dx); + // dy = 0.5 * std::fabs(dy); + // dz = 0.5 * std::fabs(dz); /* std::stringstream planeName; diff --git a/Framework/DataHandling/src/LoadSpiceXML2DDet.cpp b/Framework/DataHandling/src/LoadSpiceXML2DDet.cpp index 5efadb955db9087b94c295d663f3601a3ada2c97..d1d6d36bc5cb1a99486c6cde3a45e57180ee2a8d 100644 --- a/Framework/DataHandling/src/LoadSpiceXML2DDet.cpp +++ b/Framework/DataHandling/src/LoadSpiceXML2DDet.cpp @@ -1076,9 +1076,7 @@ void LoadSpiceXML2DDet::loadInstrument(API::MatrixWorkspace_sptr matrixws, loadinst->setProperty("RewriteSpectraMap", Mantid::Kernel::OptionalBool(true)); loadinst->execute(); - if (loadinst->isExecuted()) - matrixws = loadinst->getProperty("Workspace"); - else + if (!loadinst->isExecuted()) g_log.error("Unable to load instrument to output workspace"); } diff --git a/Framework/DataHandling/src/ProcessBankData.cpp b/Framework/DataHandling/src/ProcessBankData.cpp index c75481df46e0261a34e264f2097e1fa43ea9ab86..120fcf64becde776c121ddcb8baebed4e5c9d95d 100644 --- a/Framework/DataHandling/src/ProcessBankData.cpp +++ b/Framework/DataHandling/src/ProcessBankData.cpp @@ -92,7 +92,7 @@ void ProcessBankData::run() { // override { // Now we pre-allocate (reserve) the vectors of events in each pixel // counted const size_t numEventLists = outputWS.getNumberHistograms(); - for (detid_t pixID = m_min_id; pixID <= m_max_id; pixID++) { + for (detid_t pixID = m_min_id; pixID <= m_max_id; ++pixID) { if (counts[pixID - m_min_id] > 0) { size_t wi = getWorkspaceIndexFromPixelID(pixID); // Find the the workspace index corresponding to that pixel ID @@ -224,7 +224,7 @@ void ProcessBankData::run() { // override { //------------ Compress Events (or set sort order) ------------------ // Do it on all the detector IDs we touched if (compress) { - for (detid_t pixID = m_min_id; pixID <= m_max_id; pixID++) { + for (detid_t pixID = m_min_id; pixID <= m_max_id; ++pixID) { if (usedDetIds[pixID - m_min_id]) { // Find the the workspace index corresponding to that pixel ID size_t wi = getWorkspaceIndexFromPixelID(pixID); diff --git a/Framework/DataHandling/src/ReadMaterial.cpp b/Framework/DataHandling/src/ReadMaterial.cpp index 3a3543c83872a7cff9c46077c4064d2498047a77..b65fb49728f9292cc93344f159c4c3ed27d813af 100644 --- a/Framework/DataHandling/src/ReadMaterial.cpp +++ b/Framework/DataHandling/src/ReadMaterial.cpp @@ -79,8 +79,6 @@ ReadMaterial::validateInputs(const MaterialParameters ¶ms) { if (canCalculateMassDensity) { result["SampleMassDensity"] = "Cannot give SampleMassDensity with SampleNumberDensity set"; - result["SampleMassDensity"] = - "Cannot give SampleMassDensity with SampleNumberDensity set"; } } return result; diff --git a/Framework/DataHandling/src/SaveDiffCal.cpp b/Framework/DataHandling/src/SaveDiffCal.cpp index e97d3afb9b111016f54b7859386e946fa2b2316f..1911d8a18894b7cd8dbb9279dc9f9617ca1ea520 100644 --- a/Framework/DataHandling/src/SaveDiffCal.cpp +++ b/Framework/DataHandling/src/SaveDiffCal.cpp @@ -107,6 +107,7 @@ std::map<std::string, std::string> SaveDiffCal::validateInputs() { void SaveDiffCal::writeDoubleFieldFromTable(H5::Group &group, const std::string &name) { auto column = m_calibrationWS->getColumn(name); + // cppcheck-suppress compareBoolExpressionWithInt auto data = column->numeric_fill<>(m_numValues); H5Util::writeArray1D(group, name, data); } diff --git a/Framework/DataHandling/src/SaveDspacemap.cpp b/Framework/DataHandling/src/SaveDspacemap.cpp index f52b3a59d441f9b9ab44f7053991eb87d1a9fbea..aec81df61090cf12ca9c730e716a1da2bb74b9dd 100644 --- a/Framework/DataHandling/src/SaveDspacemap.cpp +++ b/Framework/DataHandling/src/SaveDspacemap.cpp @@ -87,7 +87,7 @@ void SaveDspacemap::CalculateDspaceFromCal( std::ofstream fout(filename, std::ios_base::out | std::ios_base::binary); Progress prog(this, 0.0, 1.0, maxdetID); - for (detid_t i = 0; i != maxdetID; i++) { + for (detid_t i = 0; i != maxdetID; ++i) { // Compute the factor double factor; Geometry::IDetector_const_sptr det; diff --git a/Framework/DataHandling/src/SaveGSASInstrumentFile.cpp b/Framework/DataHandling/src/SaveGSASInstrumentFile.cpp index 7e69abfc123c694a90b541600427cce2646cd4dc..940ca4ab246527012b02f557c0ea07d04a08040e 100644 --- a/Framework/DataHandling/src/SaveGSASInstrumentFile.cpp +++ b/Framework/DataHandling/src/SaveGSASInstrumentFile.cpp @@ -896,74 +896,74 @@ void SaveGSASInstrumentFile::writePRMSingleBank( throw runtime_error(errss.str()); } - fprintf(pFile, "INS %2d ICONS%10.3f%10.3f%10.3f %10.3f%5d%10.3f\n", + fprintf(pFile, "INS %2u ICONS%10.3f%10.3f%10.3f %10.3f%5d%10.3f\n", bankid, instC * 1.00009, 0.0, zero, 0.0, 0, 0.0); - fprintf(pFile, "INS %2dBNKPAR%10.3f%10.3f%10.3f%10.3f%10.3f%5d%5d\n", bankid, + fprintf(pFile, "INS %2uBNKPAR%10.3f%10.3f%10.3f%10.3f%10.3f%5d%5d\n", bankid, m_L2, twotheta, 0., 0., 0.2, 1, 1); - fprintf(pFile, "INS %2dBAKGD 1 4 Y 0 Y\n", bankid); - fprintf(pFile, "INS %2dI HEAD %s\n", bankid, titleline.c_str()); - fprintf(pFile, "INS %2dI ITYP%5d%10.4f%10.4f%10i\n", bankid, 0, + fprintf(pFile, "INS %2uBAKGD 1 4 Y 0 Y\n", bankid); + fprintf(pFile, "INS %2uI HEAD %s\n", bankid, titleline.c_str()); + fprintf(pFile, "INS %2uI ITYP%5d%10.4f%10.4f%10i\n", bankid, 0, mindsp * 0.001 * instC, maxtof, randint); - fprintf(pFile, "INS %2dINAME %s \n", bankid, m_instrument.c_str()); - fprintf(pFile, "INS %2dPRCF1 %5d%5d%10.5f\n", bankid, -3, 21, 0.002); - fprintf(pFile, "INS %2dPRCF11%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, + fprintf(pFile, "INS %2uINAME %s \n", bankid, m_instrument.c_str()); + fprintf(pFile, "INS %2uPRCF1 %5d%5d%10.5f\n", bankid, -3, 21, 0.002); + fprintf(pFile, "INS %2uPRCF11%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, 0.0, sig0); - fprintf(pFile, "INS %2dPRCF12%15.6f%15.6f%15.6f%15.6f\n", bankid, sig1, sig2, + fprintf(pFile, "INS %2uPRCF12%15.6f%15.6f%15.6f%15.6f\n", bankid, sig1, sig2, gam0, gam1); - fprintf(pFile, "INS %2dPRCF13%15.6f%15.6f%15.6f%15.6f\n", bankid, gam2, 0.0, + fprintf(pFile, "INS %2uPRCF13%15.6f%15.6f%15.6f%15.6f\n", bankid, gam2, 0.0, 0.0, 0.0); - fprintf(pFile, "INS %2dPRCF14%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, + fprintf(pFile, "INS %2uPRCF14%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, 0.0, 0.0); - fprintf(pFile, "INS %2dPRCF15%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, + fprintf(pFile, "INS %2uPRCF15%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, 0.0, 0.0); - fprintf(pFile, "INS %2dPRCF16%15.6f\n", bankid, 0.0); - fprintf(pFile, "INS %2dPAB3 %3d\n", bankid, 90); + fprintf(pFile, "INS %2uPRCF16%15.6f\n", bankid, 0.0); + fprintf(pFile, "INS %2uPAB3 %3d\n", bankid, 90); for (size_t k = 0; k < 90; ++k) { - fprintf(pFile, "INS %2dPAB3%2d%10.5f%10.5f%10.5f%10.5f\n", bankid, + fprintf(pFile, "INS %2uPAB3%2d%10.5f%10.5f%10.5f%10.5f\n", bankid, static_cast<int>(k) + 1, m_gdsp[k], m_gdt[k], m_galpha[k], m_gbeta[k]); } - fprintf(pFile, "INS %2dPRCF2 %5i%5i%10.5f\n", bankid, -4, 27, 0.002); - fprintf(pFile, "INS %2dPRCF21%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, + fprintf(pFile, "INS %2uPRCF2 %5i%5i%10.5f\n", bankid, -4, 27, 0.002); + fprintf(pFile, "INS %2uPRCF21%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, 0.0, sig1); - fprintf(pFile, "INS %2dPRCF22%15.6f%15.6f%15.6f%15.6f\n", bankid, sig2, gam2, + fprintf(pFile, "INS %2uPRCF22%15.6f%15.6f%15.6f%15.6f\n", bankid, sig2, gam2, 0.0, 0.0); - fprintf(pFile, "INS %2dPRCF23%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, + fprintf(pFile, "INS %2uPRCF23%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, 0.0, 0.0); - fprintf(pFile, "INS %2dPRCF24%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, + fprintf(pFile, "INS %2uPRCF24%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, 0.0, 0.0); - fprintf(pFile, "INS %2dPRCF25%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, + fprintf(pFile, "INS %2uPRCF25%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, 0.0, 0.0); - fprintf(pFile, "INS %2dPRCF26%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, + fprintf(pFile, "INS %2uPRCF26%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, 0.0, 0.0); - fprintf(pFile, "INS %2dPRCF27%15.6f%15.6f%15.6f \n", bankid, 0.0, 0.0, 0.0); + fprintf(pFile, "INS %2uPRCF27%15.6f%15.6f%15.6f \n", bankid, 0.0, 0.0, 0.0); - fprintf(pFile, "INS %2dPAB4 %3i\n", bankid, 90); + fprintf(pFile, "INS %2uPAB4 %3i\n", bankid, 90); for (size_t k = 0; k < 90; ++k) { - fprintf(pFile, "INS %2dPAB4%2d%10.5f%10.5f%10.5f%10.5f\n", bankid, + fprintf(pFile, "INS %2uPAB4%2d%10.5f%10.5f%10.5f%10.5f\n", bankid, static_cast<int>(k) + 1, m_gdsp[k], m_gdt[k], m_galpha[k], m_gbeta[k]); } - fprintf(pFile, "INS %2dPRCF3 %5i%5i%10.5f\n", bankid, -5, 21, 0.002); - fprintf(pFile, "INS %2dPRCF31%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, + fprintf(pFile, "INS %2uPRCF3 %5i%5i%10.5f\n", bankid, -5, 21, 0.002); + fprintf(pFile, "INS %2uPRCF31%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, 0.0, sig0); - fprintf(pFile, "INS %2dPRCF32%15.6f%15.6f%15.6f%15.6f\n", bankid, sig1, sig2, + fprintf(pFile, "INS %2uPRCF32%15.6f%15.6f%15.6f%15.6f\n", bankid, sig1, sig2, gam0, gam1); - fprintf(pFile, "INS %2dPRCF33%15.6f%15.6f%15.6f%15.6f\n", bankid, gam2, 0.0, + fprintf(pFile, "INS %2uPRCF33%15.6f%15.6f%15.6f%15.6f\n", bankid, gam2, 0.0, 0.0, 0.0); - fprintf(pFile, "INS %2dPRCF34%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, + fprintf(pFile, "INS %2uPRCF34%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, 0.0, 0.0); - fprintf(pFile, "INS %2dPRCF35%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, + fprintf(pFile, "INS %2uPRCF35%15.6f%15.6f%15.6f%15.6f\n", bankid, 0.0, 0.0, 0.0, 0.0); - fprintf(pFile, "INS %2dPRCF36%15.6f\n", bankid, 0.0); + fprintf(pFile, "INS %2uPRCF36%15.6f\n", bankid, 0.0); - fprintf(pFile, "INS %2dPAB5 %3i\n", bankid, + fprintf(pFile, "INS %2uPAB5 %3i\n", bankid, 90); // 90 means there will be 90 lines of table for (size_t k = 0; k < 90; k++) { - fprintf(pFile, "INS %2dPAB5%2d%10.5f%10.5f%10.5f%10.5f\n", bankid, + fprintf(pFile, "INS %2uPAB5%2d%10.5f%10.5f%10.5f%10.5f\n", bankid, static_cast<int>(k) + 1, m_gdsp[k], m_gdt[k], m_galpha[k], m_gbeta[k]); } diff --git a/Framework/DataHandling/test/CheckMantidVersionTest.h b/Framework/DataHandling/test/CheckMantidVersionTest.h index a7478201a77f2af15f14530f09d83f65af2d0ca3..085fa054352d2e26ba6dbb02a2a6bc147facf70b 100644 --- a/Framework/DataHandling/test/CheckMantidVersionTest.h +++ b/Framework/DataHandling/test/CheckMantidVersionTest.h @@ -119,8 +119,7 @@ public: std::string currentVersion = alg.PropertyManagerOwner::getProperty("CurrentVersion"); - std::string mostRecentVersion = - alg.PropertyManagerOwner::getProperty("MostRecentVersion"); + alg.PropertyManagerOwner::getProperty("MostRecentVersion"); bool isNewVersionAvailable = alg.PropertyManagerOwner::getProperty("IsNewVersionAvailable"); diff --git a/Framework/DataHandling/test/CreateSimulationWorkspaceTest.h b/Framework/DataHandling/test/CreateSimulationWorkspaceTest.h index 35f68d49ddcc4ab6ca9f99d62d4f711d17d97669..f523688c52b2171b21b7ec27a477c532d326032e 100644 --- a/Framework/DataHandling/test/CreateSimulationWorkspaceTest.h +++ b/Framework/DataHandling/test/CreateSimulationWorkspaceTest.h @@ -235,10 +235,6 @@ private: class CreateSimulationWorkspaceTestPerformance : public CxxTest::TestSuite { public: void setUp() override { - - // Starting bin, bin width, last bin - const std::string binParams("-30,3,279"); - alg.initialize(); alg.setPropertyValue("Instrument", "HET"); diff --git a/Framework/DataHandling/test/DownloadInstrumentTest.h b/Framework/DataHandling/test/DownloadInstrumentTest.h index e8bea923d84c066b8c039e5d4d3f17ff41fbe1bf..5572bb93725bf144bf11f86c3c9f5e6edcd24a70 100644 --- a/Framework/DataHandling/test/DownloadInstrumentTest.h +++ b/Framework/DataHandling/test/DownloadInstrumentTest.h @@ -190,9 +190,6 @@ public: } int runDownloadInstrument() { - // Name of the output workspace. - std::string outWSName("DownloadInstrumentTest_OutputWS"); - MockedDownloadInstrument alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()) TS_ASSERT(alg.isInitialized()) diff --git a/Framework/DataHandling/test/GroupDetectors2Test.h b/Framework/DataHandling/test/GroupDetectors2Test.h index 9143e2e5ee809b4771204fba0c4d14818ecafd8d..d97897e4d44842fea9cf599b2341a8f754ef4513 100644 --- a/Framework/DataHandling/test/GroupDetectors2Test.h +++ b/Framework/DataHandling/test/GroupDetectors2Test.h @@ -560,21 +560,21 @@ public: TS_ASSERT_EQUALS(*specDet, 2); specDet = output2D1->getSpectrum(2).getDetectorIDs().begin(); TS_ASSERT_EQUALS(*specDet, 3); - specDet++; + ++specDet; TS_ASSERT_EQUALS(*specDet, 4); - specDet++; + ++specDet; TS_ASSERT_EQUALS(*specDet, 5); specDet = output2D1->getSpectrum(3).getDetectorIDs().begin(); TS_ASSERT_EQUALS(*specDet, 2); - specDet++; + ++specDet; TS_ASSERT_EQUALS(*specDet, 8); - specDet++; + ++specDet; TS_ASSERT_EQUALS(*specDet, 9); - specDet++; + ++specDet; TS_ASSERT_EQUALS(*specDet, 11); - specDet++; + ++specDet; TS_ASSERT_EQUALS(*specDet, 12); - specDet++; + ++specDet; TS_ASSERT_EQUALS(*specDet, 13); AnalysisDataService::Instance().remove(outputSpace); @@ -631,6 +631,7 @@ public: const auto &y = output->y(0); const auto &e = output->e(0); for (size_t i = 0; i < y.size(); ++i) { + // cppcheck-suppress unreadVariable const double expectedSignal = i == 0 ? 2. : (1. + 2.) / 2.; TS_ASSERT_EQUALS(y[i], expectedSignal) const double expectedError = i == 0 ? 1. : std::sqrt(2.) / 2.; @@ -659,6 +660,7 @@ public: const auto &y = output->y(0); const auto &e = output->e(0); for (size_t i = 0; i < y.size(); ++i) { + // cppcheck-suppress unreadVariable const double expectedSignal = i == 0 ? 2. : 1. + 2.; TS_ASSERT_EQUALS(y[i], expectedSignal) const double expectedError = i == 0 ? 1. : std::sqrt(2.); @@ -1122,7 +1124,7 @@ private: } Instrument_sptr instr(new Instrument); - for (detid_t i = 0; i < NHIST; i++) { + for (detid_t i = 0; i < NHIST; ++i) { Detector *d = new Detector("det", i, nullptr); d->setPos(1. + static_cast<double>(i) * 0.1, 0., 1.); instr->add(d); diff --git a/Framework/DataHandling/test/GroupDetectorsTest.h b/Framework/DataHandling/test/GroupDetectorsTest.h index 62d438f6607989152363c80844871759627d1f22..47ff0be4fca32510e463c54c48adf788896180c0 100644 --- a/Framework/DataHandling/test/GroupDetectorsTest.h +++ b/Framework/DataHandling/test/GroupDetectorsTest.h @@ -52,7 +52,7 @@ public: space2D->getSpectrum(j).setDetectorID(j); } Instrument_sptr instr(new Instrument); - for (detid_t i = 0; i < 5; i++) { + for (detid_t i = 0; i < 5; ++i) { Detector *d = new Detector("det", i, nullptr); instr->add(d); instr->markAsDetector(d); diff --git a/Framework/DataHandling/test/InstrumentRayTracerTest.h b/Framework/DataHandling/test/InstrumentRayTracerTest.h index f20863bd0f4146bb7fa2291d5dcb2ba6264b2eac..7ec49b9084a3838c01638a9bc69bd99555c39016 100644 --- a/Framework/DataHandling/test/InstrumentRayTracerTest.h +++ b/Framework/DataHandling/test/InstrumentRayTracerTest.h @@ -100,7 +100,7 @@ public: private: void showResults(Links &results, const Instrument_const_sptr &inst) { Links::const_iterator resultItr = results.begin(); - for (; resultItr != results.end(); resultItr++) { + for (; resultItr != results.end(); ++resultItr) { IComponent_const_sptr component = inst->getComponentByID(resultItr->componentID); std::cout << component->getName() << ", "; diff --git a/Framework/DataHandling/test/LoadDspacemapTest.h b/Framework/DataHandling/test/LoadDspacemapTest.h index f8c2843d60d1aca0c4d4f325df16ae686843b64f..c6b72d53cd1540c8eff1463efb9a7dcb3408bad3 100644 --- a/Framework/DataHandling/test/LoadDspacemapTest.h +++ b/Framework/DataHandling/test/LoadDspacemapTest.h @@ -60,8 +60,6 @@ public: void doTestVulcan(const std::string &dspaceFile, const std::string &fileType) { - std::string outputFile = "./VULCAN_dspacemaptocal_test.cal"; - LoadDspacemap testerDSP; TS_ASSERT_THROWS_NOTHING(testerDSP.initialize()); TS_ASSERT_THROWS_NOTHING(testerDSP.isInitialized()); diff --git a/Framework/DataHandling/test/LoadILLReflectometryTest.h b/Framework/DataHandling/test/LoadILLReflectometryTest.h index ee41277b477e1f6957f1e78ac236150670efd192..e282244fd77ce2e225e7860a0642270d60997648 100644 --- a/Framework/DataHandling/test/LoadILLReflectometryTest.h +++ b/Framework/DataHandling/test/LoadILLReflectometryTest.h @@ -696,10 +696,12 @@ public: auto instrument = output->getInstrument(); auto slit1 = instrument->getComponentByName("slit2"); auto slit2 = instrument->getComponentByName("slit3"); + // cppcheck-suppress unreadVariable const double S2z = -output->run().getPropertyValueAsType<double>("Distance.S2toSample") * 1e-3; TS_ASSERT_EQUALS(slit1->getPos(), V3D(0.0, 0.0, S2z)) + // cppcheck-suppress unreadVariable const double S3z = -output->run().getPropertyValueAsType<double>("Distance.S3toSample") * 1e-3; diff --git a/Framework/DataHandling/test/LoadMappingTableTest.h b/Framework/DataHandling/test/LoadMappingTableTest.h index 7c1fa34fb1e8192014bbb58d3fca20a13a171d81..9459270a3e8745cfc06b3a23b3a4d008ff70235e 100644 --- a/Framework/DataHandling/test/LoadMappingTableTest.h +++ b/Framework/DataHandling/test/LoadMappingTableTest.h @@ -80,7 +80,7 @@ public: detectorgroup = work1->getSpectrum(2083).getDetectorIDs(); std::set<detid_t>::const_iterator it; int pixnum = 101191; - for (it = detectorgroup.begin(); it != detectorgroup.end(); it++) + for (it = detectorgroup.begin(); it != detectorgroup.end(); ++it) TS_ASSERT_EQUALS(*it, pixnum++); AnalysisDataService::Instance().remove(outputSpace); diff --git a/Framework/DataHandling/test/LoadNexusLogsTest.h b/Framework/DataHandling/test/LoadNexusLogsTest.h index 579a1a79d202a533323a31565fe6c6090b22afd3..85aa8487e0ed19f07443919a42b354249279e6fd 100644 --- a/Framework/DataHandling/test/LoadNexusLogsTest.h +++ b/Framework/DataHandling/test/LoadNexusLogsTest.h @@ -272,7 +272,6 @@ public: void test_last_time_series_log_entry_equals_end_time() { LoadNexusLogs ld; - std::string outws_name = "REF_L_instrument"; ld.initialize(); ld.setPropertyValue("Filename", "REF_L_32035.nxs"); MatrixWorkspace_sptr ws = createTestWorkspace(); diff --git a/Framework/DataHandling/test/LoadRaw3Test.h b/Framework/DataHandling/test/LoadRaw3Test.h index 1918a73af950629bee1ce1717f75efdf2d037ffd..19f298d7286d2601c15d6c37b854f92a88b385bb 100644 --- a/Framework/DataHandling/test/LoadRaw3Test.h +++ b/Framework/DataHandling/test/LoadRaw3Test.h @@ -153,7 +153,7 @@ public: detectorgroup = output2D->getSpectrum(2083).getDetectorIDs(); std::set<detid_t>::const_iterator it; int pixnum = 101191; - for (it = detectorgroup.begin(); it != detectorgroup.end(); it++) + for (it = detectorgroup.begin(); it != detectorgroup.end(); ++it) TS_ASSERT_EQUALS(*it, pixnum++); AnalysisDataService::Instance().remove(outputSpace); @@ -375,7 +375,7 @@ public: wsNamevec = sptrWSGrp->getNames(); int period = 1; std::vector<std::string>::const_iterator it = wsNamevec.begin(); - for (; it != wsNamevec.end(); it++) { + for (; it != wsNamevec.end(); ++it) { std::stringstream count; count << period; std::string wsName = "multiperiod_" + count.str(); @@ -385,7 +385,7 @@ public: std::vector<std::string>::const_iterator itr1 = wsNamevec.begin(); int periodNumber = 0; const int nHistograms = 4; - for (; itr1 != wsNamevec.end(); itr1++) { + for (; itr1 != wsNamevec.end(); ++itr1) { MatrixWorkspace_sptr outsptr; TS_ASSERT_THROWS_NOTHING( outsptr = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>( @@ -581,7 +581,7 @@ public: detectorgroup = output2D->getSpectrum(2079).getDetectorIDs(); std::set<detid_t>::const_iterator it; int pixnum = 101191; - for (it = detectorgroup.begin(); it != detectorgroup.end(); it++) + for (it = detectorgroup.begin(); it != detectorgroup.end(); ++it) TS_ASSERT_EQUALS(*it, pixnum++); // Test if filename log is found in both monitor and sata workspace @@ -626,7 +626,7 @@ public: monitorsptrWSGrp->getNames(); int period = 1; std::vector<std::string>::const_iterator it = monitorwsNamevec.begin(); - for (; it != monitorwsNamevec.end(); it++) { + for (; it != monitorwsNamevec.end(); ++it) { std::stringstream count; count << period; std::string wsName = "multiperiod_monitors_" + count.str(); @@ -634,7 +634,7 @@ public: period++; } std::vector<std::string>::const_iterator itr1 = monitorwsNamevec.begin(); - for (; itr1 != monitorwsNamevec.end(); itr1++) { + for (; itr1 != monitorwsNamevec.end(); ++itr1) { MatrixWorkspace_sptr outsptr; TS_ASSERT_THROWS_NOTHING( outsptr = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>( @@ -674,7 +674,7 @@ public: const std::vector<std::string> wsNamevec = sptrWSGrp->getNames(); period = 1; it = wsNamevec.begin(); - for (; it != wsNamevec.end(); it++) { + for (; it != wsNamevec.end(); ++it) { std::stringstream count; count << period; std::string wsName = "multiperiod_" + count.str(); @@ -684,7 +684,7 @@ public: itr1 = wsNamevec.begin(); int periodNumber = 0; const int nHistograms = 2; - for (; itr1 != wsNamevec.end(); itr1++) { + for (; itr1 != wsNamevec.end(); ++itr1) { MatrixWorkspace_sptr outsptr; TS_ASSERT_THROWS_NOTHING( outsptr = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>( diff --git a/Framework/DataHandling/test/LoadRawBin0Test.h b/Framework/DataHandling/test/LoadRawBin0Test.h index 4bbe01e0775d3eed4cd8672c443308be18c359f9..b1c314f1c7aacf32c87eeedb8302d56e5425d2a8 100644 --- a/Framework/DataHandling/test/LoadRawBin0Test.h +++ b/Framework/DataHandling/test/LoadRawBin0Test.h @@ -108,7 +108,7 @@ public: wsNamevec = sptrWSGrp->getNames(); int period = 1; std::vector<std::string>::const_iterator it = wsNamevec.begin(); - for (; it != wsNamevec.end(); it++) { + for (; it != wsNamevec.end(); ++it) { std::stringstream count; count << period; std::string wsName = "multiperiod_" + count.str(); @@ -118,7 +118,7 @@ public: std::vector<std::string>::const_iterator itr1 = wsNamevec.begin(); int periodNumber = 0; const int nHistograms = 4; - for (; itr1 != wsNamevec.end(); itr1++) { + for (; itr1 != wsNamevec.end(); ++itr1) { MatrixWorkspace_sptr outsptr; TS_ASSERT_THROWS_NOTHING( outsptr = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>( diff --git a/Framework/DataHandling/test/LoadRawSaveNxsLoadNxsTest.h b/Framework/DataHandling/test/LoadRawSaveNxsLoadNxsTest.h index 101fc484ffa9f4c965e946c0043893d2098d3c6a..7af33edb978501176d9265d130fa18bb3d3b0302 100644 --- a/Framework/DataHandling/test/LoadRawSaveNxsLoadNxsTest.h +++ b/Framework/DataHandling/test/LoadRawSaveNxsLoadNxsTest.h @@ -72,7 +72,6 @@ public: // specify name of file to save workspace to outputFile = "testSaveLoadrawCSP.nxs"; remove(outputFile.c_str()); - std::string dataName = "spectra"; std::string title = "Workspace from Loadraw CSP78173"; saveNexusP.setPropertyValue("FileName", outputFile); outputFile = saveNexusP.getPropertyValue("Filename"); diff --git a/Framework/DataHandling/test/LoadRawSpectrum0Test.h b/Framework/DataHandling/test/LoadRawSpectrum0Test.h index f1a86ad09edba95d82a52c22fda3dd1c069eafc0..96a7f376aa8c278c2d8adf6c7e1e3062d381fd90 100644 --- a/Framework/DataHandling/test/LoadRawSpectrum0Test.h +++ b/Framework/DataHandling/test/LoadRawSpectrum0Test.h @@ -110,7 +110,7 @@ public: wsNamevec = sptrWSGrp->getNames(); int period = 1; std::vector<std::string>::const_iterator it = wsNamevec.begin(); - for (; it != wsNamevec.end(); it++) { + for (; it != wsNamevec.end(); ++it) { std::stringstream count; count << period; std::string wsName = "multiperiod_" + count.str(); @@ -119,7 +119,7 @@ public: } std::vector<std::string>::const_iterator itr1 = wsNamevec.begin(); int expectedPeriod = 0; - for (; itr1 != wsNamevec.end(); itr1++) { + for (; itr1 != wsNamevec.end(); ++itr1) { MatrixWorkspace_sptr outsptr; TS_ASSERT_THROWS_NOTHING( outsptr = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>( diff --git a/Framework/DataHandling/test/MaskDetectorsTest.h b/Framework/DataHandling/test/MaskDetectorsTest.h index 826fefab82959e6af67d138cfe4a739d95e3fa68..747f7e786ad4ab4ce7bf82ba074404283aba0d93 100644 --- a/Framework/DataHandling/test/MaskDetectorsTest.h +++ b/Framework/DataHandling/test/MaskDetectorsTest.h @@ -649,9 +649,9 @@ public: void test_MaskWithWorkspaceWithDetectorIDs() { auto &ads = AnalysisDataService::Instance(); - const std::string inputWSName("inputWS"), existingMaskName("existingMask"); const int numInputSpec(90); + const std::string inputWSName("inputWS"); setUpWS(false, inputWSName, false, numInputSpec); auto inputWS = ads.retrieveWS<MatrixWorkspace>(inputWSName); @@ -717,7 +717,7 @@ public: void test_MaskWithWorkspaceWithDetectorIDsAndWsIndexRange() { auto &ads = AnalysisDataService::Instance(); - const std::string inputWSName("inputWS"), existingMaskName("existingMask"); + const std::string inputWSName("inputWS"); const int numInputSpec(90); setUpWS(false, inputWSName, false, numInputSpec); diff --git a/Framework/DataHandling/test/SaveAscii2Test.h b/Framework/DataHandling/test/SaveAscii2Test.h index a13dba15dc31e09688656460bfef1cdfb81bccb5..d9f1c18952fa87ca84964ff883952d9bf2d615d5 100644 --- a/Framework/DataHandling/test/SaveAscii2Test.h +++ b/Framework/DataHandling/test/SaveAscii2Test.h @@ -114,7 +114,7 @@ public: } AnalysisDataService::Instance().add(m_name, wsToSave); SaveAscii2 save; - std::string filename = initSaveAscii2(save); + initSaveAscii2(save); TS_ASSERT_THROWS_NOTHING(save.setPropertyValue("WriteXError", "1")); TS_ASSERT_THROWS_ANYTHING(save.execute()); AnalysisDataService::Instance().remove(m_name); @@ -530,7 +530,7 @@ public: writeSampleWS(wsToSave, false); SaveAscii2 save; - std::string filename = initSaveAscii2(save); + initSaveAscii2(save); TS_ASSERT_THROWS_NOTHING( save.setProperty("SpectrumMetaData", "SpectrumNumber")); @@ -836,7 +836,7 @@ public: writeSampleWS(wsToSave); SaveAscii2 save; - std::string filename = initSaveAscii2(save); + initSaveAscii2(save); TS_ASSERT_THROWS_NOTHING( save.setPropertyValue("SpectrumMetaData", "NotAValidChoice")); diff --git a/Framework/DataHandling/test/SaveBankScatteringAnglesTest.h b/Framework/DataHandling/test/SaveBankScatteringAnglesTest.h index 45e667a4933e129be9f0dc8f22e59e7abc2dc5bb..ab924856da4df1c1aa5826f1d67ae087ed8a389a 100644 --- a/Framework/DataHandling/test/SaveBankScatteringAnglesTest.h +++ b/Framework/DataHandling/test/SaveBankScatteringAnglesTest.h @@ -62,9 +62,9 @@ public: std::ifstream file(tempFileName); std::string line; - int numLines = 0; if (file.is_open()) { + int numLines = 0; while (std::getline(file, line)) { numLines++; } diff --git a/Framework/DataHandling/test/SaveCalFileTest.h b/Framework/DataHandling/test/SaveCalFileTest.h index c00ec9eb1604624f1d97cc86ada45e06c5c569d5..d8ffb94aec8834a46a081466e5adeba6b079e1b5 100644 --- a/Framework/DataHandling/test/SaveCalFileTest.h +++ b/Framework/DataHandling/test/SaveCalFileTest.h @@ -51,9 +51,6 @@ public: maskWS->getSpectrum(0).clearData(); maskWS->mutableSpectrumInfo().setMasked(0, true); - // Name of the output workspace. - std::string outWSName("SaveCalFileTest_OutputWS"); - SaveCalFile alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()) TS_ASSERT(alg.isInitialized()) diff --git a/Framework/DataHandling/test/SaveGSASInstrumentFileTest.h b/Framework/DataHandling/test/SaveGSASInstrumentFileTest.h index 99b14d91ec4e93c69523ce10e275d7a37d70e283..641319f16a8906c980d4a8dab1df33863ba0040d 100644 --- a/Framework/DataHandling/test/SaveGSASInstrumentFileTest.h +++ b/Framework/DataHandling/test/SaveGSASInstrumentFileTest.h @@ -497,7 +497,6 @@ public: while (!file2.eof()) { getline(file2, str); - c2++; } // Reset file stream pointer diff --git a/Framework/DataHandling/test/SavePDFGuiTest.h b/Framework/DataHandling/test/SavePDFGuiTest.h index 07b5271a6b2dcbd379f658176a31f5552f498528..adea18d2e1b0ce8f715607b46b6a73a32e715d87 100644 --- a/Framework/DataHandling/test/SavePDFGuiTest.h +++ b/Framework/DataHandling/test/SavePDFGuiTest.h @@ -112,9 +112,6 @@ public: grpAlg->setPropertyValue("OutputWorkspace", groupName); grpAlg->execute(); - // name of the output file - const std::string outFilename("SavePDFGUIGroup.gr"); - // run the algorithm with a group SavePDFGui alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()); diff --git a/Framework/DataHandling/test/UpdateInstrumentFromFileTest.h b/Framework/DataHandling/test/UpdateInstrumentFromFileTest.h index d00bc48e599920c6f1b3e393cef63b783a113b57..f7ae6029178db8ecd996a98c8491064889e306eb 100644 --- a/Framework/DataHandling/test/UpdateInstrumentFromFileTest.h +++ b/Framework/DataHandling/test/UpdateInstrumentFromFileTest.h @@ -137,7 +137,6 @@ public: void test_DAT_Extension_Without_Header_Assumes_Detector_Calibration_File_And_Fails_If_Number_Of_Columns_Incorrect() { - const std::string colNames = "spectrum,theta,t0,-,R"; const std::string contents = "plik det t0 l0 l1\n" " 3 130.4653 -0.4157 11.0050 0.6708\n" " 4 131.9319 -0.5338 11.0050 0.6545"; diff --git a/Framework/DataObjects/test/AffineMatrixParameterTest.h b/Framework/DataObjects/test/AffineMatrixParameterTest.h index 74ca40581095fd1e44674a89e5da1254ec3b150c..58da4a15d11fc3ed309a41537df6a91c2b97cb57 100644 --- a/Framework/DataObjects/test/AffineMatrixParameterTest.h +++ b/Framework/DataObjects/test/AffineMatrixParameterTest.h @@ -111,7 +111,6 @@ public: } param.setMatrix(transform); - std::string result = param.toXMLString(); TSM_ASSERT_EQUALS( "Serialization of CoordTransform has not worked correctly.", "<Parameter><Type>AffineMatrixParameter</" diff --git a/Framework/DataObjects/test/PeaksWorkspaceTest.h b/Framework/DataObjects/test/PeaksWorkspaceTest.h index 41edfbeef31db35c3698535b5dbdf9d32dfcfe83..da1044841203748e52fb814c0c1107b0a39558d7 100644 --- a/Framework/DataObjects/test/PeaksWorkspaceTest.h +++ b/Framework/DataObjects/test/PeaksWorkspaceTest.h @@ -140,9 +140,6 @@ public: } void test_Save_Unmodified_PeaksWorkspace_Nexus() { - - const std::string filename = - "test_Save_Unmodified_PeaksWorkspace_Nexus.nxs"; auto testPWS = createSaveTestPeaksWorkspace(); NexusTestHelper nexusHelper(true); nexusHelper.createFile("testSavePeaksWorkspace.nxs"); diff --git a/Framework/DataObjects/test/WeightedEventTest.h b/Framework/DataObjects/test/WeightedEventTest.h index 7c22aa630fb8a34f9bcd7dc86b2318906276a845..621d22978ef0873674d6dc30e42fcc84f6f1c172 100644 --- a/Framework/DataObjects/test/WeightedEventTest.h +++ b/Framework/DataObjects/test/WeightedEventTest.h @@ -62,6 +62,7 @@ public: // Copy constructor we = WeightedEvent(); we2 = WeightedEvent(456, 789, 2.5, 1.5 * 1.5); + // cppcheck-suppress redundantAssignment we = we2; TS_ASSERT_EQUALS(we.tof(), 456); TS_ASSERT_EQUALS(we.pulseTime(), 789); diff --git a/Framework/Geometry/src/Instrument/ObjCompAssembly.cpp b/Framework/Geometry/src/Instrument/ObjCompAssembly.cpp index 57587fe90275d2819aef42fd014680103618301d..13c327d53751caf48d17ca4777d730936b53c6b5 100644 --- a/Framework/Geometry/src/Instrument/ObjCompAssembly.cpp +++ b/Framework/Geometry/src/Instrument/ObjCompAssembly.cpp @@ -409,12 +409,12 @@ boost::shared_ptr<IObject> ObjCompAssembly::createOutline() { // find the 'moments of inertia' of the assembly double Ixx = 0, Iyy = 0, Izz = 0, Ixy = 0, Ixz = 0, Iyz = 0; V3D Cmass; // 'center of mass' of the assembly - for (const_comp_it it = group.begin(); it != group.end(); it++) { + for (const_comp_it it = group.begin(); it != group.end(); ++it) { V3D p = (**it).getRelativePos(); Cmass += p; } Cmass /= nelements(); - for (const_comp_it it = group.begin(); it != group.end(); it++) { + for (const_comp_it it = group.begin(); it != group.end(); ++it) { V3D p = (**it).getRelativePos(); double x = p.X() - Cmass.X(), x2 = x * x; double y = p.Y() - Cmass.Y(), y2 = y * y; @@ -476,7 +476,7 @@ boost::shared_ptr<IObject> ObjCompAssembly::createOutline() { // positive displacements are positive numbers and negative ones are negative double hxn = 0, hyn = 0, hzn = 0; double hxp = 0, hyp = 0, hzp = 0; - for (const_comp_it it = group.begin(); it != group.end(); it++) { + for (const_comp_it it = group.begin(); it != group.end(); ++it) { // displacement vector of a detector V3D p = (**it).getRelativePos() - Cmass; // its projection on the vx axis diff --git a/Framework/Geometry/src/Instrument/XMLInstrumentParameter.cpp b/Framework/Geometry/src/Instrument/XMLInstrumentParameter.cpp index ce2c5a1337bea7635be934c635d2ea0f2f1aaff0..17c163adb6c0c54e0d33ae61740eca3c2d48481f 100644 --- a/Framework/Geometry/src/Instrument/XMLInstrumentParameter.cpp +++ b/Framework/Geometry/src/Instrument/XMLInstrumentParameter.cpp @@ -147,7 +147,7 @@ double XMLInstrumentParameter::createParamValue( } // Looking for string: "position n", where n is an integer and is a 1-based // index - else if (m_extractSingleValueAs.find("position") == 0 && + else if (m_extractSingleValueAs.compare("position") == 0 && m_extractSingleValueAs.size() >= 10) { std::stringstream extractPosition(m_extractSingleValueAs); std::string dummy; diff --git a/Framework/Geometry/src/Objects/CSGObject.cpp b/Framework/Geometry/src/Objects/CSGObject.cpp index 9985ef2753a9075e902cb474d73b3c0a76648fbe..bc955a76162d900785d4b338872565fbb29ece9e 100644 --- a/Framework/Geometry/src/Objects/CSGObject.cpp +++ b/Framework/Geometry/src/Objects/CSGObject.cpp @@ -1594,6 +1594,7 @@ double CSGObject::singleShotMonteCarloVolume(const int shotSize, const auto threadCount = PARALLEL_NUMBER_OF_THREADS; const auto currentThreadNum = PARALLEL_THREAD_NUMBER; size_t blocksize = shotSize / threadCount; + // cppcheck-suppress knownConditionTrueFalse if (currentThreadNum == threadCount - 1) { // Last thread may have to do threadCount extra iterations in // the worst case. diff --git a/Framework/HistogramData/test/CountStandardDeviationsTest.h b/Framework/HistogramData/test/CountStandardDeviationsTest.h index fc094f623f4b9eb34e5d6c146b0af99f51a4e60a..4da236676c4c2888e762ab7493f56aeeed1b16ac 100644 --- a/Framework/HistogramData/test/CountStandardDeviationsTest.h +++ b/Framework/HistogramData/test/CountStandardDeviationsTest.h @@ -94,7 +94,6 @@ public: const BinEdges edges{1.0, 2.0}; auto old_ptr = &frequencies[0]; const CountStandardDeviations counts(std::move(frequencies), edges); - TS_ASSERT(!frequencies); TS_ASSERT_EQUALS(&counts[0], old_ptr); } @@ -104,8 +103,6 @@ public: const BinEdges edges{1.0, 2.0}; auto old_ptr = &frequencies[0]; const CountStandardDeviations counts(std::move(frequencies), edges); - // Moved from frequencies... - TS_ASSERT(!frequencies); // ... but made a copy of data, since "copy" also held a reference. TS_ASSERT_DIFFERS(&counts[0], old_ptr); } @@ -127,7 +124,6 @@ public: // This implicitly constructs FrequencyStandardDeviations first, so there is // a two-step move going on! const CountStandardDeviations counts(std::move(frequencies), edges); - TS_ASSERT(!frequencies); TS_ASSERT_EQUALS(&counts[0], old_ptr); } }; diff --git a/Framework/HistogramData/test/CountVariancesTest.h b/Framework/HistogramData/test/CountVariancesTest.h index f574cb79e7ee113e8130c574b165188ac1ce5331..1ee331c55109a2c6a40e37ffb36d27d28aa44e83 100644 --- a/Framework/HistogramData/test/CountVariancesTest.h +++ b/Framework/HistogramData/test/CountVariancesTest.h @@ -101,7 +101,6 @@ public: const BinEdges edges{1.0, 2.0}; auto old_ptr = &frequencies[0]; const CountVariances counts(std::move(frequencies), edges); - TS_ASSERT(!frequencies); TS_ASSERT_EQUALS(&counts[0], old_ptr); } @@ -111,8 +110,6 @@ public: const BinEdges edges{1.0, 2.0}; auto old_ptr = &frequencies[0]; const CountVariances counts(std::move(frequencies), edges); - // Moved from frequencies... - TS_ASSERT(!frequencies); // ... but made a copy of data, since "copy" also held a reference. TS_ASSERT_DIFFERS(&counts[0], old_ptr); } @@ -134,7 +131,6 @@ public: // This implicitly constructs FrequencyVariances first, so there is a // two-step move going on! const CountVariances counts(std::move(frequencies), edges); - TS_ASSERT(!frequencies); TS_ASSERT_EQUALS(&counts[0], old_ptr); } }; diff --git a/Framework/HistogramData/test/CountsTest.h b/Framework/HistogramData/test/CountsTest.h index d6474d26253b361f3c1ba7a510d2066de48acc92..49725b67d754d84891064760d61f8ff99b1b1144 100644 --- a/Framework/HistogramData/test/CountsTest.h +++ b/Framework/HistogramData/test/CountsTest.h @@ -97,7 +97,6 @@ public: const BinEdges edges{1.0, 2.0}; auto old_ptr = &frequencies[0]; const Counts counts(std::move(frequencies), edges); - TS_ASSERT(!frequencies); TS_ASSERT_EQUALS(&counts[0], old_ptr); } @@ -107,8 +106,6 @@ public: const BinEdges edges{1.0, 2.0}; auto old_ptr = &frequencies[0]; const Counts counts(std::move(frequencies), edges); - // Moved from frequencies... - TS_ASSERT(!frequencies); // ... but made a copy of data, since "copy" also held a reference. TS_ASSERT_DIFFERS(&counts[0], old_ptr); } diff --git a/Framework/HistogramData/test/FrequenciesTest.h b/Framework/HistogramData/test/FrequenciesTest.h index 598fd5aa8424e47c2b138a3ba12359f980f2edb8..1eb1b105bddb4a5f8ac56457ea1f7fd568331377 100644 --- a/Framework/HistogramData/test/FrequenciesTest.h +++ b/Framework/HistogramData/test/FrequenciesTest.h @@ -97,7 +97,6 @@ public: const BinEdges edges{1.0, 2.0}; auto old_ptr = &counts[0]; const Frequencies frequencies(std::move(counts), edges); - TS_ASSERT(!counts); TS_ASSERT_EQUALS(&frequencies[0], old_ptr); } @@ -107,8 +106,6 @@ public: const BinEdges edges{1.0, 2.0}; auto old_ptr = &counts[0]; const Frequencies frequencies(std::move(counts), edges); - // Moved from counts... - TS_ASSERT(!counts); // ... but made a copy of data, since "copy" also held a reference. TS_ASSERT_DIFFERS(&frequencies[0], old_ptr); } diff --git a/Framework/HistogramData/test/FrequencyVariancesTest.h b/Framework/HistogramData/test/FrequencyVariancesTest.h index a308a66dd0ede9763c2dfcef1d09febb43b2abb1..cabf615d4746d78df244300195cf2bd624f9b3c2 100644 --- a/Framework/HistogramData/test/FrequencyVariancesTest.h +++ b/Framework/HistogramData/test/FrequencyVariancesTest.h @@ -104,7 +104,6 @@ public: const BinEdges edges{1.0, 2.0}; auto old_ptr = &counts[0]; const FrequencyVariances frequencies(std::move(counts), edges); - TS_ASSERT(!counts); TS_ASSERT_EQUALS(&frequencies[0], old_ptr); } @@ -114,8 +113,6 @@ public: const BinEdges edges{1.0, 2.0}; auto old_ptr = &counts[0]; const FrequencyVariances frequencies(std::move(counts), edges); - // Moved from counts... - TS_ASSERT(!counts); // ... but made a copy of data, since "copy" also held a reference. TS_ASSERT_DIFFERS(&frequencies[0], old_ptr); } @@ -137,7 +134,6 @@ public: // This implicitly constructs CountVariances first, so there is a // two-step move going on! const FrequencyVariances frequencies(std::move(counts), edges); - TS_ASSERT(!counts); TS_ASSERT_EQUALS(&frequencies[0], old_ptr); } }; diff --git a/Framework/HistogramData/test/StandardDeviationVectorOfTest.h b/Framework/HistogramData/test/StandardDeviationVectorOfTest.h index f5da8607d1e5f95fbe39c7ffa020b94014e48ab6..113209ffb93d70d3744fae9eac2c20b8bdd6c953 100644 --- a/Framework/HistogramData/test/StandardDeviationVectorOfTest.h +++ b/Framework/HistogramData/test/StandardDeviationVectorOfTest.h @@ -74,7 +74,6 @@ public: VariancesTester variances{1.0, 4.0}; auto old_ptr = &variances[0]; StandardDeviationVectorOfTester sigmas(std::move(variances)); - TS_ASSERT(!variances); TS_ASSERT_EQUALS(&sigmas[0], old_ptr); TS_ASSERT_EQUALS(sigmas[0], 1.0); TS_ASSERT_EQUALS(sigmas[1], 2.0); @@ -93,7 +92,6 @@ public: auto old_ptr = &variances[0]; StandardDeviationVectorOfTester sigmas{}; sigmas = std::move(variances); - TS_ASSERT(!variances); TS_ASSERT_EQUALS(&sigmas[0], old_ptr); TS_ASSERT_EQUALS(sigmas[0], 1.0); TS_ASSERT_EQUALS(sigmas[1], 2.0); diff --git a/Framework/HistogramData/test/VarianceVectorOfTest.h b/Framework/HistogramData/test/VarianceVectorOfTest.h index 1dfed01a9c67c43698361c8b88ca8705cc49b629..2c58a64f541ba310f5591b327b97653b1e16db30 100644 --- a/Framework/HistogramData/test/VarianceVectorOfTest.h +++ b/Framework/HistogramData/test/VarianceVectorOfTest.h @@ -70,7 +70,6 @@ public: SigmasTester sigmas{1.0, 2.0}; auto old_ptr = &sigmas[0]; VarianceVectorOfTester variances(std::move(sigmas)); - TS_ASSERT(!sigmas); TS_ASSERT_EQUALS(&variances[0], old_ptr); TS_ASSERT_EQUALS(variances[0], 1.0); TS_ASSERT_EQUALS(variances[1], 4.0); @@ -89,7 +88,6 @@ public: auto old_ptr = &sigmas[0]; VarianceVectorOfTester variances{}; variances = std::move(sigmas); - TS_ASSERT(!sigmas); TS_ASSERT_EQUALS(&variances[0], old_ptr); TS_ASSERT_EQUALS(variances[0], 1.0); TS_ASSERT_EQUALS(variances[1], 4.0); diff --git a/Framework/HistogramData/test/VectorOfTest.h b/Framework/HistogramData/test/VectorOfTest.h index 032b30e9fd303422f0360c468f7a9810e23925e3..f38e4d64c540d051b4ef59699534be748bb6e87c 100644 --- a/Framework/HistogramData/test/VectorOfTest.h +++ b/Framework/HistogramData/test/VectorOfTest.h @@ -100,7 +100,6 @@ public: TS_ASSERT_EQUALS(src.size(), 2); TS_ASSERT(src); const VectorOfTester dest(std::move(src)); - TS_ASSERT(!src); TS_ASSERT_EQUALS(dest[0], 0.1); TS_ASSERT_EQUALS(dest[1], 0.1); } @@ -108,7 +107,6 @@ public: void test_move_from_null_constructor() { VectorOfTester src{}; const VectorOfTester dest(std::move(src)); - TS_ASSERT(!src); TS_ASSERT(!dest); } @@ -160,7 +158,6 @@ public: TS_ASSERT_EQUALS(dest[0], 0.0); TS_ASSERT(src); dest = std::move(src); - TS_ASSERT(!src); TS_ASSERT_EQUALS(dest[0], 0.1); TS_ASSERT_EQUALS(dest[1], 0.1); } @@ -169,7 +166,6 @@ public: VectorOfTester src{}; VectorOfTester dest(1); dest = std::move(src); - TS_ASSERT(!src); TS_ASSERT(!dest); } diff --git a/Framework/ICat/test/CatalogSearchTest.h b/Framework/ICat/test/CatalogSearchTest.h index 89c73f02b08983a849dc59697209a73dd6a57b02..54b80e7d6a5fd0989bb6d125330c462407ebbf2f 100644 --- a/Framework/ICat/test/CatalogSearchTest.h +++ b/Framework/ICat/test/CatalogSearchTest.h @@ -121,16 +121,9 @@ public: if (!searchobj.isInitialized()) searchobj.initialize(); - std::string errorMsg = "Invalid value for property StartDate (string) " - "sssss" - ": Invalid Date:date format must be DD/MM/YYYY"; TS_ASSERT_THROWS(searchobj.setPropertyValue("StartDate", "sssss"), const std::invalid_argument &); - - errorMsg = "Invalid value for property EndDate (string) " - "aaaaa" - ": Invalid Date:date format must be DD/MM/YYYY"; TS_ASSERT_THROWS(searchobj.setPropertyValue("EndDate", "aaaaa"), const std::invalid_argument &); @@ -146,17 +139,8 @@ public: if (!searchobj.isInitialized()) searchobj.initialize(); - std::string errorMsg = "Invalid value for property StartDate (string) " - "39/22/2009" - ": Invalid Date:Day part of the Date parameter must " - "be between 1 and 31"; TS_ASSERT_THROWS(searchobj.setPropertyValue("StartDate", "39/22/2009"), const std::invalid_argument &); - - errorMsg = "Invalid value for property EndDate (string) " - "1/22/2009" - ": Invalid Date:Month part of the Date parameter must be " - "between 1 and 12"; TS_ASSERT_THROWS(searchobj.setPropertyValue("EndDate", "1/22/2009"), const std::invalid_argument &); diff --git a/Framework/Kernel/test/CowPtrTest.h b/Framework/Kernel/test/CowPtrTest.h index d4a97a9cc9eed1ead59b813df37df533655ac76f..5736a8dee62a2ad73e15066b772ce1b91c2a0e69 100644 --- a/Framework/Kernel/test/CowPtrTest.h +++ b/Framework/Kernel/test/CowPtrTest.h @@ -10,6 +10,7 @@ #include <boost/make_shared.hpp> #include <boost/shared_ptr.hpp> #include <cxxtest/TestSuite.h> +#include <memory> using namespace Mantid::Kernel; diff --git a/Framework/Kernel/test/LogParserTest.h b/Framework/Kernel/test/LogParserTest.h index cc2e5d5e9fbf3e5c9e806f9e1ed44ce967ef0e39..47f6e248f6eb27b6d50948a2afe6c9f78c01672f 100644 --- a/Framework/Kernel/test/LogParserTest.h +++ b/Framework/Kernel/test/LogParserTest.h @@ -69,10 +69,10 @@ public: const auto &ti_data1 = v->first.to_tm(); TS_ASSERT_EQUALS(ti_data1.tm_hour, 12); TS_ASSERT_EQUALS(ti_data1.tm_min, 22); - v++; - v++; - v++; - v++; + ++v; + ++v; + ++v; + ++v; // time 5 const auto &ti_data5 = v->first.to_tm(); TS_ASSERT_EQUALS(ti_data5.tm_hour, 12); @@ -119,10 +119,10 @@ public: const auto &ti_data1 = v->first.to_tm(); TS_ASSERT_EQUALS(ti_data1.tm_hour, 12); TS_ASSERT_EQUALS(ti_data1.tm_min, 22); - v++; - v++; - v++; - v++; + ++v; + ++v; + ++v; + ++v; // time 5 const auto &ti_data5 = v->first.to_tm(); TS_ASSERT_EQUALS(ti_data5.tm_hour, 12); @@ -156,10 +156,10 @@ public: const auto &ti_data1 = v->first.to_tm(); TS_ASSERT_EQUALS(ti_data1.tm_hour, 12); TS_ASSERT_EQUALS(ti_data1.tm_min, 22); - v++; - v++; - v++; - v++; + ++v; + ++v; + ++v; + ++v; // time 5 const auto &ti_data5 = v->first.to_tm(); TS_ASSERT_EQUALS(ti_data5.tm_hour, 12); @@ -216,9 +216,9 @@ public: const auto &ti_data1 = v->first.to_tm(); TS_ASSERT_EQUALS(ti_data1.tm_hour, 12); TS_ASSERT_EQUALS(ti_data1.tm_min, 22); - v++; - v++; - v++; + ++v; + ++v; + ++v; // time 4 TS_ASSERT_EQUALS(v->second, " line 4"); const auto &ti_data4 = v->first.to_tm(); @@ -381,10 +381,10 @@ public: const auto &ti_data1 = v->first.to_tm(); TS_ASSERT_EQUALS(ti_data1.tm_hour, 12); TS_ASSERT_EQUALS(ti_data1.tm_min, 22); - v++; - v++; - v++; - v++; + ++v; + ++v; + ++v; + ++v; // time 5 // TS_ASSERT(!isNaN(v->second)); // last time diff --git a/buildconfig/CMake/CppCheck_Suppressions.txt.in b/buildconfig/CMake/CppCheck_Suppressions.txt.in index ed2ac5eb001b00f7453cbb1aeaf63182d8424d48..f60bde7ca6c07350da914bd49f6587cc984566e3 100644 --- a/buildconfig/CMake/CppCheck_Suppressions.txt.in +++ b/buildconfig/CMake/CppCheck_Suppressions.txt.in @@ -2,8 +2,6 @@ // NOTE this needs the full path to the file, so would need this file to be generated by cmake // as different build servers have different starts to the file path - - // -------- Project Wide ------------------ // Hide warnings about using explicit keyword constructors as we have "too many" @@ -16,15 +14,6 @@ duplInheritedMember // We have some potentially uninitialized member vars but too many to fix at the moment uninitMemberVar -// 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 - -// A large number of copying instead of pass by ref were picked up by clang-tidy, but around 200 remain -passedByValue - // Around 100 of these exist where noConstructor is present noConstructor @@ -32,22 +21,39 @@ noConstructor 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 ----------------- // Mantid Plot specific ones we probably won't fix before removal -cstyleCase:*${CMAKE_SOURCE_DIR}/MantidPlot + *:${CMAKE_SOURCE_DIR}/MantidPlot/src/origin/tree.hh *:${CMAKE_SOURCE_DIR}/MantidPlot/src/nrutil.cpp +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 -// Ones below was beyond the Cppcheck 1.90 migration scope -pureVirtualCall:${CMAKE_SOURCE_DIR}/qt/scientific_interfaces/Indirect/IndirectBayesTab.cpp - // Ref binding means Cppcheck can't see these are used unreadVariable:${CMAKE_SOURCE_DIR}/Framework/Algorithms/src/MaskBinsIf.cpp @@ -68,11 +74,17 @@ copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/Catalog/inc/MantidCatalog/ON copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/Crystal/inc/MantidCrystal/IndexSXPeaks.h copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/Crystal/inc/MantidCrystal/IntegratePeakTimeSlices.h +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/Geometry/inc/MantidGeometry/Instrument/CompAssembly.h +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/Geometry/inc/MantidGeometry/Instrument/Container.h +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/Geometry/inc/MantidGeometry/Instrument/ObjCompAssembly.h +copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/Framework/Geometry/inc/MantidGeometry/Rendering/GeometryHandler.h + copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/QwtWorkspaceBinData.h copyCtorAndEqOperator:${CMAKE_SOURCE_DIR}/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/QwtWorkspaceSpectrumData.h noCopyConstructor:${CMAKE_SOURCE_DIR}/Framework/DataHandling/inc/MantidDataHandling/BankPulseTimes.h noCopyConstructor:${CMAKE_SOURCE_DIR}/Framework/DataHandling/src/LoadRaw/isisraw.h +noCopyConstructor:${CMAKE_SOURCE_DIR}/Framework/Geometry/inc/MantidGeometry/Rendering/vtkGeometryCacheWriter.h // ----------------- Upstream libs --------------- @@ -86,8 +98,7 @@ noCopyConstructor:${CMAKE_SOURCE_DIR}/Framework/DataHandling/src/LoadRaw/isisraw *:*${CMAKE_SOURCE_DIR}/Framework/Kernel/src/ANN/* // Libs we have in-source -*:*${CMAKE_SOURCE_DIR}/Framework/DataObjects/inc/MantidDataObjects/MortonIndex/* -*:*${CMAKE_SOURCE_DIR}/Framework/ICat/src/GSoap/* -*:*${CMAKE_SOURCE_DIR}/ICat/src/ICat3/GSoapGenerated/* -*:*${CMAKE_SOURCE_DIR}/ICat/src/ICat4/GSoapGenerated/* -*:*${CMAKE_SOURCE_DIR}/MantidPlot/src/zlib123/* +*:${CMAKE_SOURCE_DIR}/Framework/ICat/src/GSoap/* +*:${CMAKE_SOURCE_DIR}/Framework/ICat/src/ICat3/GSoapGenerated/* +*:${CMAKE_SOURCE_DIR}/Framework/ICat/src/ICat4/GSoapGenerated/* +*:${CMAKE_SOURCE_DIR}/MantidPlot/src/zlib123/* diff --git a/qt/scientific_interfaces/Indirect/IndirectBayesTab.cpp b/qt/scientific_interfaces/Indirect/IndirectBayesTab.cpp index 07d99f46148827fc4a9d268a6f461e22401d2ace..8d7484a3a3f81e6868d9deaa9841100fab83ddcf 100644 --- a/qt/scientific_interfaces/Indirect/IndirectBayesTab.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectBayesTab.cpp @@ -13,7 +13,6 @@ IndirectBayesTab::IndirectBayesTab(QWidget *parent) : IndirectTab(parent), m_propTree(new QtTreePropertyBrowser()) { m_propTree->setFactoryForManager(m_dblManager, m_dblEdFac); - // cppcheck-suppress pureVirtualCall connect(m_dblManager, SIGNAL(valueChanged(QtProperty *, double)), this, // cppcheck-suppress pureVirtualCall SLOT(updateProperties(QtProperty *, double))); diff --git a/qt/widgets/common/src/FunctionTreeView.cpp b/qt/widgets/common/src/FunctionTreeView.cpp index 734ce0f4ba99f0b9710c587ae79fd2238d23f07a..3969cf380a94a78f20d84c46e072ac754664b0af 100644 --- a/qt/widgets/common/src/FunctionTreeView.cpp +++ b/qt/widgets/common/src/FunctionTreeView.cpp @@ -904,10 +904,6 @@ void FunctionTreeView::addTieProperty(QtProperty *prop, const QString &tie) { if (!prop) { throw std::runtime_error("FunctionTreeView: null property pointer"); } - AProperty ap; - ap.item = nullptr; - ap.prop = nullptr; - ap.parent = nullptr; if (!isParameter(prop)) return; @@ -918,7 +914,7 @@ void FunctionTreeView::addTieProperty(QtProperty *prop, const QString &tie) { m_tieManager->blockSignals(true); QtProperty *tieProp = m_tieManager->addProperty("Tie"); m_tieManager->setValue(tieProp, tie); - ap = addProperty(prop, tieProp); + addProperty(prop, tieProp); m_tieManager->blockSignals(false); const auto parName = getParameterName(prop); diff --git a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/ScaleEngine.h b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/ScaleEngine.h index 8a6667050281c60f343225f0c7afca1c7ae4f68a..937e569189b54c5c9f8c85a846c6db8494345b8e 100644 --- a/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/ScaleEngine.h +++ b/qt/widgets/plotting/inc/MantidQtWidgets/Plotting/Qwt/ScaleEngine.h @@ -45,8 +45,8 @@ public: : QwtScaleTransformation(Other), d_engine(engine){}; double xForm(double x, double /*s1*/, double /*s2*/, double p1, double p2) const override; - double invXForm(double x, double s1, double s2, double p1, - double p2) const override; + double invXForm(double p, double p1, double p2, double s1, + double s2) const override; QwtScaleTransformation *copy() const override; ~ScaleTransformation() override; diff --git a/qt/widgets/plugins/algorithm_dialogs/src/ConvertTableToMatrixWorkspaceDialog.cpp b/qt/widgets/plugins/algorithm_dialogs/src/ConvertTableToMatrixWorkspaceDialog.cpp index c9a665b7e4557f14a16fe2c326040f1c39b1bc55..016e947c58a1b42946a39084cd0c8fabbe8f6a05 100644 --- a/qt/widgets/plugins/algorithm_dialogs/src/ConvertTableToMatrixWorkspaceDialog.cpp +++ b/qt/widgets/plugins/algorithm_dialogs/src/ConvertTableToMatrixWorkspaceDialog.cpp @@ -103,7 +103,9 @@ void ConvertTableToMatrixWorkspaceDialog::fillColumnNames( /// Initialize the layout void ConvertTableToMatrixWorkspaceDialog::initLayout() { m_form.setupUi(this); - ((QVBoxLayout *)this->layout())->addLayout(createDefaultButtonLayout()); + + static_cast<QVBoxLayout *>(this->layout()) + ->addLayout(createDefaultButtonLayout()); tie(m_form.cbInputWorkspace, "InputWorkspace", m_form.gridLayout); tie(m_form.leOutputWorkspace, "OutputWorkspace", m_form.gridLayout); tie(m_form.cbColumnX, "ColumnX", m_form.gridLayout);