From 57b3bc4ec511ba8ce0f5d316554ecbd30bcf3653 Mon Sep 17 00:00:00 2001 From: Steven Hahn <hahnse@ornl.gov> Date: Sat, 9 Sep 2017 10:16:01 -0400 Subject: [PATCH] fixed readability-container-size-empty. --- Framework/API/src/Algorithm.cpp | 2 +- Framework/API/src/DetectorSearcher.cpp | 2 +- Framework/API/src/IndexTypeProperty.cpp | 2 +- Framework/API/src/MatrixWorkspace.cpp | 2 +- Framework/Algorithms/src/AddSampleLog.cpp | 6 +++--- Framework/Algorithms/src/ChangeTimeZero.cpp | 2 +- .../Algorithms/src/ConvertAxisByFormula.cpp | 8 ++++---- Framework/Algorithms/src/ConvertUnits.cpp | 2 +- .../src/DiffractionEventCalibrateDetectors.cpp | 2 +- .../Algorithms/src/DiffractionFocussing2.cpp | 2 +- .../Algorithms/src/ExportTimeSeriesLog.cpp | 2 +- Framework/Algorithms/src/FilterByTime.cpp | 4 ++-- Framework/Algorithms/src/FilterByTime2.cpp | 4 ++-- Framework/Algorithms/src/FilterEvents.cpp | 6 +++--- .../Algorithms/src/GenerateIPythonNotebook.cpp | 4 ++-- .../Algorithms/src/GeneratePythonScript.cpp | 4 ++-- .../src/ReflectometryReductionOne2.cpp | 2 +- Framework/Algorithms/src/RenameWorkspaces.cpp | 6 +++--- Framework/Algorithms/src/Stitch1DMany.cpp | 4 ++-- Framework/Crystal/src/PeakHKLErrors.cpp | 2 +- Framework/Crystal/src/SCDPanelErrors.cpp | 2 +- .../src/Algorithms/ConvertToYSpace.cpp | 2 +- Framework/CurveFitting/src/Algorithms/Fit.cpp | 2 +- .../src/Algorithms/PlotPeakByLogValue.cpp | 2 +- .../src/Algorithms/SplineInterpolation.cpp | 2 +- .../Functions/CrystalFieldMultiSpectrum.cpp | 2 +- .../src/Functions/TabulatedFunction.cpp | 2 +- .../DataHandling/src/DownloadInstrument.cpp | 2 +- Framework/DataHandling/src/LoadAscii2.cpp | 2 +- Framework/DataHandling/src/LoadFITS.cpp | 18 +++++++++--------- .../src/LoadFullprofResolution.cpp | 4 ++-- .../src/LoadGSASInstrumentFile.cpp | 2 +- .../DataHandling/src/LoadIDFFromNexus.cpp | 10 +++++----- .../DataHandling/src/LoadILLDiffraction.cpp | 2 +- .../DataHandling/src/LoadILLIndirect2.cpp | 2 +- .../DataHandling/src/LoadILLReflectometry.cpp | 2 +- Framework/DataHandling/src/LoadILLSANS.cpp | 2 +- Framework/DataHandling/src/LoadILLTOF2.cpp | 2 +- Framework/DataHandling/src/LoadIsawDetCal.cpp | 2 +- Framework/DataHandling/src/LoadLLB.cpp | 2 +- Framework/DataHandling/src/LoadMLZ.cpp | 2 +- Framework/DataHandling/src/LoadSINQFocus.cpp | 2 +- .../DataHandling/src/LoadSpiceXML2DDet.cpp | 4 ++-- Framework/DataHandling/src/LoadTBL.cpp | 16 ++++++++-------- Framework/DataHandling/src/SaveAscii.cpp | 2 +- Framework/DataHandling/src/SaveAscii2.cpp | 2 +- .../DataHandling/src/SaveReflCustomAscii.cpp | 2 +- .../src/SaveReflThreeColumnAscii.cpp | 2 +- .../src/SaveToSNSHistogramNexus.cpp | 4 ++-- Framework/DataObjects/src/EventList.cpp | 2 +- .../src/Crystal/SymmetryElementFactory.cpp | 2 +- .../Instrument/InstrumentDefinitionParser.cpp | 2 +- .../src/CountStandardDeviations.cpp | 2 +- Framework/HistogramData/src/CountVariances.cpp | 2 +- Framework/HistogramData/src/Counts.cpp | 2 +- Framework/HistogramData/src/Frequencies.cpp | 2 +- .../src/FrequencyStandardDeviations.cpp | 2 +- .../HistogramData/src/FrequencyVariances.cpp | 2 +- Framework/HistogramData/src/Points.cpp | 2 +- .../inc/MantidKernel/PropertyWithValue.tcc | 2 +- Framework/Kernel/src/CompositeValidator.cpp | 2 +- Framework/Kernel/src/ConfigService.cpp | 4 ++-- Framework/Kernel/src/UsageService.cpp | 2 +- .../MDAlgorithms/src/CompareMDWorkspaces.cpp | 2 +- .../src/ConvertToDiffractionMDWorkspace3.cpp | 2 +- Framework/Nexus/src/NexusFileIO.cpp | 2 +- .../mantid/api/src/Exports/IAlgorithm.cpp | 2 +- Framework/SINQ/src/PoldiPeakSearch.cpp | 2 +- .../TestHelpers/src/FileComparisonHelper.cpp | 4 ++-- 69 files changed, 107 insertions(+), 107 deletions(-) diff --git a/Framework/API/src/Algorithm.cpp b/Framework/API/src/Algorithm.cpp index 795addd969a..22239ea2e19 100644 --- a/Framework/API/src/Algorithm.cpp +++ b/Framework/API/src/Algorithm.cpp @@ -1711,7 +1711,7 @@ void Algorithm::execMasterOnly() { * non-master ranks in master-only execution. */ void Algorithm::execNonMaster() { // If there is no output we can simply do nothing. - if (m_pureOutputWorkspaceProps.size() == 0) + if (m_pureOutputWorkspaceProps.empty()) return; // Does Algorithm have exactly one input and one output workspace property? if (m_inputWorkspaceProps.size() == 1 && diff --git a/Framework/API/src/DetectorSearcher.cpp b/Framework/API/src/DetectorSearcher.cpp index 76d8f93ebde..6170612c893 100644 --- a/Framework/API/src/DetectorSearcher.cpp +++ b/Framework/API/src/DetectorSearcher.cpp @@ -148,7 +148,7 @@ DetectorSearcher::searchUsingNearestNeighbours(const V3D &q) { // find where this Q vector should intersect with "extended" space const auto neighbours = m_detectorCacheSearch->findNearest(Eigen::Vector3d(q[0], q[1], q[2]), 5); - if (neighbours.size() == 0) + if (neighbours.empty()) return std::make_tuple(false, 0); const auto result = checkInteceptWithNeighbours(detectorDir, neighbours); diff --git a/Framework/API/src/IndexTypeProperty.cpp b/Framework/API/src/IndexTypeProperty.cpp index df454100350..7a45c4741b7 100644 --- a/Framework/API/src/IndexTypeProperty.cpp +++ b/Framework/API/src/IndexTypeProperty.cpp @@ -10,7 +10,7 @@ IndexTypeProperty::IndexTypeProperty(const std::string &name, if (indexType & IndexType::SpectrumNum) m_allowedValues.push_back("SpectrumNumber"); - if (m_allowedValues.size() == 0) + if (m_allowedValues.empty()) throw std::invalid_argument("Argument indexType incorrectly specified"); m_value = m_allowedValues[0]; diff --git a/Framework/API/src/MatrixWorkspace.cpp b/Framework/API/src/MatrixWorkspace.cpp index 2a1794eb532..c07904a0494 100644 --- a/Framework/API/src/MatrixWorkspace.cpp +++ b/Framework/API/src/MatrixWorkspace.cpp @@ -239,7 +239,7 @@ void MatrixWorkspace::initialize(const std::size_t &NVectors, void MatrixWorkspace::initialize(const std::size_t &NVectors, const HistogramData::Histogram &histogram) { // Check validity of arguments - if (NVectors == 0 || histogram.x().size() == 0) { + if (NVectors == 0 || histogram.x().empty()) { throw std::out_of_range( "All arguments to init must be positive and non-zero"); } diff --git a/Framework/Algorithms/src/AddSampleLog.cpp b/Framework/Algorithms/src/AddSampleLog.cpp index 5b7be49cd1e..7abbf956b7f 100644 --- a/Framework/Algorithms/src/AddSampleLog.cpp +++ b/Framework/Algorithms/src/AddSampleLog.cpp @@ -228,7 +228,7 @@ void AddSampleLog::addTimeSeriesProperty(Run &run_obj, is_int_series = true; } else if (prop_number_type == autoTypeOption) { // auto type. by default - if (prop_value.size() == 0) + if (prop_value.empty()) g_log.warning("For sample log in TimeSeriesProperty and values are given " "by MarixWorkspace, the default data type " "is double."); @@ -248,8 +248,8 @@ void AddSampleLog::addTimeSeriesProperty(Run &run_obj, // check using workspace or some specified start value std::string tsp_ws_name = getPropertyValue("TimeSeriesWorkspace"); - bool use_ws = tsp_ws_name.size() > 0; - bool use_single_value = prop_value.size() > 0; + bool use_ws = !tsp_ws_name.empty(); + bool use_single_value = !prop_value.empty(); if (use_ws && use_single_value) { throw std::runtime_error("Both TimeSeries workspace and sing value are " "specified. It is not allowed."); diff --git a/Framework/Algorithms/src/ChangeTimeZero.cpp b/Framework/Algorithms/src/ChangeTimeZero.cpp index 631e7068f15..5494590af12 100644 --- a/Framework/Algorithms/src/ChangeTimeZero.cpp +++ b/Framework/Algorithms/src/ChangeTimeZero.cpp @@ -331,7 +331,7 @@ bool ChangeTimeZero::checkForDateTime(const std::string &val) const { // Hedge for bad lexical casts in the DateTimeValidator try { DateTimeValidator validator = DateTimeValidator(); - isDateTime = validator.isValid(val) == ""; + isDateTime = validator.isValid(val).empty(); } catch (...) { isDateTime = false; } diff --git a/Framework/Algorithms/src/ConvertAxisByFormula.cpp b/Framework/Algorithms/src/ConvertAxisByFormula.cpp index ada62fb7d4e..de1ab2350a8 100644 --- a/Framework/Algorithms/src/ConvertAxisByFormula.cpp +++ b/Framework/Algorithms/src/ConvertAxisByFormula.cpp @@ -105,7 +105,7 @@ void ConvertAxisByFormula::exec() { RefAxis *refAxisPtr = dynamic_cast<RefAxis *>(axisPtr); if (refAxisPtr != nullptr) { CommonBinsValidator sameBins; - if (sameBins.isValid(outputWs) != "") { + if (!sameBins.isValid(outputWs).empty()) { isRaggedBins = true; } isRefAxis = true; @@ -245,14 +245,14 @@ void ConvertAxisByFormula::exec() { } // Set the Unit of the Axis - if ((axisUnits != "") || (axisTitle != "")) { + if ((!axisUnits.empty()) || (!axisTitle.empty())) { try { axisPtr->unit() = UnitFactory::Instance().create(axisUnits); } catch (Exception::NotFoundError &) { - if (axisTitle == "") { + if (axisTitle.empty()) { axisTitle = axisPtr->unit()->caption(); } - if (axisUnits == "") { + if (axisUnits.empty()) { axisUnits = axisPtr->unit()->label(); } axisPtr->unit() = boost::make_shared<Units::Label>(axisTitle, axisUnits); diff --git a/Framework/Algorithms/src/ConvertUnits.cpp b/Framework/Algorithms/src/ConvertUnits.cpp index 33fa5a87287..7f58d71c62d 100644 --- a/Framework/Algorithms/src/ConvertUnits.cpp +++ b/Framework/Algorithms/src/ConvertUnits.cpp @@ -337,7 +337,7 @@ ConvertUnits::convertQuickly(API::MatrixWorkspace_const_sptr inputWS, // First a quick check using the validator CommonBinsValidator sameBins; bool commonBoundaries = false; - if (sameBins.isValid(inputWS) == "") { + if (sameBins.isValid(inputWS).empty()) { commonBoundaries = WorkspaceHelpers::commonBoundaries(*inputWS); // Only do the full check if the quick one passes if (commonBoundaries) { diff --git a/Framework/Algorithms/src/DiffractionEventCalibrateDetectors.cpp b/Framework/Algorithms/src/DiffractionEventCalibrateDetectors.cpp index 5136276a2e8..24381be1b96 100644 --- a/Framework/Algorithms/src/DiffractionEventCalibrateDetectors.cpp +++ b/Framework/Algorithms/src/DiffractionEventCalibrateDetectors.cpp @@ -299,7 +299,7 @@ void DiffractionEventCalibrateDetectors::exec() { std::vector<boost::shared_ptr<RectangularDetector>> detList; // --------- Loading only one bank ---------------------------------- std::string onebank = getProperty("BankName"); - bool doOneBank = (onebank != ""); + bool doOneBank = (!onebank.empty()); for (int i = 0; i < inst->nelements(); i++) { boost::shared_ptr<RectangularDetector> det; boost::shared_ptr<ICompAssembly> assem; diff --git a/Framework/Algorithms/src/DiffractionFocussing2.cpp b/Framework/Algorithms/src/DiffractionFocussing2.cpp index 5465caa11d9..875954fbee9 100644 --- a/Framework/Algorithms/src/DiffractionFocussing2.cpp +++ b/Framework/Algorithms/src/DiffractionFocussing2.cpp @@ -109,7 +109,7 @@ void DiffractionFocussing2::exec() { throw std::invalid_argument("Workspace Invalid Spacing/UnitID"); } // --- Do we need to read the grouping workspace? ---- - if (groupingFileName != "") { + if (!groupingFileName.empty()) { progress(0.01, "Reading grouping file"); IAlgorithm_sptr childAlg = createChildAlgorithm("CreateGroupingWorkspace"); childAlg->setProperty( diff --git a/Framework/Algorithms/src/ExportTimeSeriesLog.cpp b/Framework/Algorithms/src/ExportTimeSeriesLog.cpp index bdce22f34a0..35c15bc9fa4 100644 --- a/Framework/Algorithms/src/ExportTimeSeriesLog.cpp +++ b/Framework/Algorithms/src/ExportTimeSeriesLog.cpp @@ -429,7 +429,7 @@ void ExportTimeSeriesLog::calculateFirstDerivative(bool is_event_ws) { // error message std::string errmsg = errmsg_ss.str(); - if (errmsg.size() > 0) + if (!errmsg.empty()) g_log.error(errmsg); return; diff --git a/Framework/Algorithms/src/FilterByTime.cpp b/Framework/Algorithms/src/FilterByTime.cpp index dd08a9f46bd..fe151e505ff 100644 --- a/Framework/Algorithms/src/FilterByTime.cpp +++ b/Framework/Algorithms/src/FilterByTime.cpp @@ -77,12 +77,12 @@ void FilterByTime::exec() { start_str = getPropertyValue("AbsoluteStartTime"); stop_str = getPropertyValue("AbsoluteStopTime"); - if ((start_str != "") && (stop_str != "") && (start_dbl <= 0.0) && + if ((!start_str.empty()) && (!stop_str.empty()) && (start_dbl <= 0.0) && (stop_dbl <= 0.0)) { // Use the absolute string start = DateAndTime(start_str); stop = DateAndTime(stop_str); - } else if ((start_str == "") && (stop_str == "") && + } else if ((start_str.empty()) && (stop_str.empty()) && ((start_dbl > 0.0) || (stop_dbl > 0.0))) { // Use the relative times in seconds. DateAndTime first = inputWS->getFirstPulseTime(); diff --git a/Framework/Algorithms/src/FilterByTime2.cpp b/Framework/Algorithms/src/FilterByTime2.cpp index 74ab5708084..71d70f36280 100644 --- a/Framework/Algorithms/src/FilterByTime2.cpp +++ b/Framework/Algorithms/src/FilterByTime2.cpp @@ -73,12 +73,12 @@ void FilterByTime2::exec() { std::string absstoptime = this->getProperty("AbsoluteStopTime"); std::string start, stop; - if ((absstarttime != "") && (absstoptime != "") && (starttime <= 0.0) && + if ((!absstarttime.empty()) && (!absstoptime.empty()) && (starttime <= 0.0) && (stoptime <= 0.0)) { // Use the absolute string start = absstarttime; stop = absstoptime; - } else if ((absstarttime != "" || absstoptime != "") && + } else if ((!absstarttime.empty() || !absstoptime.empty()) && (starttime > 0.0 || stoptime > 0.0)) { throw std::invalid_argument( "It is not allowed to provide both absolute time and relative time."); diff --git a/Framework/Algorithms/src/FilterEvents.cpp b/Framework/Algorithms/src/FilterEvents.cpp index 9f6b05f04ff..c4a4cf3116e 100644 --- a/Framework/Algorithms/src/FilterEvents.cpp +++ b/Framework/Algorithms/src/FilterEvents.cpp @@ -792,7 +792,7 @@ void FilterEvents::convertSplittersWorkspaceToVectors() { Kernel::SplittingInterval splitter = m_splitters[i_splitter]; int64_t start_time_i64 = splitter.start().totalNanoseconds(); int64_t stop_time_i64 = splitter.stop().totalNanoseconds(); - if (m_vecSplitterTime.size() == 0) { + if (m_vecSplitterTime.empty()) { // first entry: add m_vecSplitterTime.push_back(start_time_i64); m_vecSplitterTime.push_back(stop_time_i64); @@ -949,7 +949,7 @@ void FilterEvents::processTableSplittersWorkspace() { int64_t stop_64 = filter_shift_time + static_cast<int64_t>(stop_time * 1.E9); - if (m_vecSplitterTime.size() == 0) { + if (m_vecSplitterTime.empty()) { // first splitter: push the start time to vector m_vecSplitterTime.push_back(start_64); } else if (start_64 - m_vecSplitterTime.back() > TOLERANCE) { @@ -973,7 +973,7 @@ void FilterEvents::processTableSplittersWorkspace() { // convert string-target to integer target bool addnew = false; int int_target(-1); - if (m_targetIndexMap.size() == 0) { + if (m_targetIndexMap.empty()) { addnew = true; } else { std::map<std::string, int>::iterator mapiter = diff --git a/Framework/Algorithms/src/GenerateIPythonNotebook.cpp b/Framework/Algorithms/src/GenerateIPythonNotebook.cpp index 529b3354907..e5e90cd9a25 100644 --- a/Framework/Algorithms/src/GenerateIPythonNotebook.cpp +++ b/Framework/Algorithms/src/GenerateIPythonNotebook.cpp @@ -80,8 +80,8 @@ void GenerateIPythonNotebook::exec() { } // Need at least a start time to do time filter - if (startTime != "") { - if (endTime == "") { + if (!startTime.empty()) { + if (endTime.empty()) { // If no end time was given then filter up to now view->filterBetweenExecDate(DateAndTime(startTime)); } else { diff --git a/Framework/Algorithms/src/GeneratePythonScript.cpp b/Framework/Algorithms/src/GeneratePythonScript.cpp index 5ee5894becf..01ee8704fcf 100644 --- a/Framework/Algorithms/src/GeneratePythonScript.cpp +++ b/Framework/Algorithms/src/GeneratePythonScript.cpp @@ -79,8 +79,8 @@ void GeneratePythonScript::exec() { } // Need at least a start time to do time filter - if (startTime != "") { - if (endTime == "") { + if (!startTime.empty()) { + if (endTime.empty()) { // If no end time was given then filter up to now view->filterBetweenExecDate(DateAndTime(startTime)); } else { diff --git a/Framework/Algorithms/src/ReflectometryReductionOne2.cpp b/Framework/Algorithms/src/ReflectometryReductionOne2.cpp index 181ab0a98af..6bbbd39b7e5 100644 --- a/Framework/Algorithms/src/ReflectometryReductionOne2.cpp +++ b/Framework/Algorithms/src/ReflectometryReductionOne2.cpp @@ -856,7 +856,7 @@ void ReflectometryReductionOne2::findDetectorGroups() { return a.front() < b.front(); }); - if (m_detectorGroups.size() == 0) { + if (m_detectorGroups.empty()) { throw std::runtime_error("Invalid processing instructions"); } } diff --git a/Framework/Algorithms/src/RenameWorkspaces.cpp b/Framework/Algorithms/src/RenameWorkspaces.cpp index 9a6855d499b..7af32cd87e4 100644 --- a/Framework/Algorithms/src/RenameWorkspaces.cpp +++ b/Framework/Algorithms/src/RenameWorkspaces.cpp @@ -61,15 +61,15 @@ std::map<std::string, std::string> RenameWorkspaces::validateInputs() { std::string suffix = getPropertyValue("Suffix"); // Check properties - if (newWsName.empty() && prefix == "" && suffix == "") { + if (newWsName.empty() && prefix.empty() && suffix.empty()) { errorList["WorkspaceNames"] = "No list of Workspace names, prefix or suffix has been supplied."; } - if (!newWsName.empty() && (prefix != "" || suffix != "")) { + if (!newWsName.empty() && (!prefix.empty() || !suffix.empty())) { errorList["WorkspaceNames"] = "Both a list of workspace names and a prefix " "or suffix has been supplied."; - if (prefix != "") { + if (!prefix.empty()) { errorList["Prefix"] = "Both a list of workspace names and a prefix " "or suffix has been supplied."; } else { diff --git a/Framework/Algorithms/src/Stitch1DMany.cpp b/Framework/Algorithms/src/Stitch1DMany.cpp index afb9e4feefd..77f76abccba 100644 --- a/Framework/Algorithms/src/Stitch1DMany.cpp +++ b/Framework/Algorithms/src/Stitch1DMany.cpp @@ -205,7 +205,7 @@ void Stitch1DMany::validateGroupWorkspacesInputs() { // Log all errors and throw a runtime error if an error is found validateCommonInputs(errors); - if (errors.size() > 0) { + if (!errors.empty()) { auto &warnLog = getLogger().warning(); for (const auto &error : errors) { warnLog << "Invalid value for " << error.first << ": " << error.second @@ -241,7 +241,7 @@ void Stitch1DMany::validateCommonInputs( m_useManualScaleFactors = this->getProperty("UseManualScaleFactors"); m_manualScaleFactors = this->getProperty("ManualScaleFactors"); - if (m_manualScaleFactors.size() > 0) { + if (!m_manualScaleFactors.empty()) { if (m_manualScaleFactors.size() == 1) { // Single value: fill with list of the same scale factor value m_manualScaleFactors = std::vector<double>(numStitchableWS - 1, diff --git a/Framework/Crystal/src/PeakHKLErrors.cpp b/Framework/Crystal/src/PeakHKLErrors.cpp index cccd488248d..08e2cac4993 100644 --- a/Framework/Crystal/src/PeakHKLErrors.cpp +++ b/Framework/Crystal/src/PeakHKLErrors.cpp @@ -51,7 +51,7 @@ void PeakHKLErrors::init() { declareParameter("GonRotz", 0.0, "1st Rotation of Goniometer about the z axis"); initMode = 1; - if (OptRuns == "") + if (OptRuns.empty()) return; initMode = 2; diff --git a/Framework/Crystal/src/SCDPanelErrors.cpp b/Framework/Crystal/src/SCDPanelErrors.cpp index 07fd84a64f6..d6da4f78916 100644 --- a/Framework/Crystal/src/SCDPanelErrors.cpp +++ b/Framework/Crystal/src/SCDPanelErrors.cpp @@ -263,7 +263,7 @@ void SCDPanelErrors::setAttribute(const std::string &attName, } FileValidator fval; std::string error = fval.isValid(fileName); - if (error == "") { + if (error.empty()) { storeAttributeValue(attName, Attribute(fileName, true)); storeAttributeValue("Workspace", Attribute("")); } else { diff --git a/Framework/CurveFitting/src/Algorithms/ConvertToYSpace.cpp b/Framework/CurveFitting/src/Algorithms/ConvertToYSpace.cpp index 390821af3be..1db18580fae 100644 --- a/Framework/CurveFitting/src/Algorithms/ConvertToYSpace.cpp +++ b/Framework/CurveFitting/src/Algorithms/ConvertToYSpace.cpp @@ -289,7 +289,7 @@ void ConvertToYSpace::createOutputWorkspace() { m_outputWS->setYUnitLabel(""); // q-Space output workspace - if (getPropertyValue("QWorkspace") != "") { + if (!getPropertyValue("QWorkspace").empty()) { m_qOutputWS = WorkspaceFactory::Instance().create(m_inputWS); m_qOutputWS->getAxis(0)->unit() = xLabel; diff --git a/Framework/CurveFitting/src/Algorithms/Fit.cpp b/Framework/CurveFitting/src/Algorithms/Fit.cpp index a0d584825b5..95f0f788000 100644 --- a/Framework/CurveFitting/src/Algorithms/Fit.cpp +++ b/Framework/CurveFitting/src/Algorithms/Fit.cpp @@ -138,7 +138,7 @@ void Fit::copyMinimizerOutput(const API::IFuncMinimizer &minimizer) { auto &properties = minimizer.getProperties(); for (auto property : properties) { if ((*property).direction() == Kernel::Direction::Output && - (*property).isValid() == "") { + (*property).isValid().empty()) { auto clonedProperty = std::unique_ptr<Kernel::Property>((*property).clone()); declareProperty(std::move(clonedProperty)); diff --git a/Framework/CurveFitting/src/Algorithms/PlotPeakByLogValue.cpp b/Framework/CurveFitting/src/Algorithms/PlotPeakByLogValue.cpp index 97d725beb89..b744e8480cf 100644 --- a/Framework/CurveFitting/src/Algorithms/PlotPeakByLogValue.cpp +++ b/Framework/CurveFitting/src/Algorithms/PlotPeakByLogValue.cpp @@ -646,7 +646,7 @@ std::string PlotPeakByLogValue::getMinimizerString(const std::string &wsName, dynamic_cast<Mantid::API::WorkspaceProperty<> *>(minimizerProp); if (wsProp) { const std::string &wsPropValue = minimizerProp->value(); - if (wsPropValue != "") { + if (!wsPropValue.empty()) { const std::string &wsPropName = minimizerProp->name(); m_minimizerWorkspaces[wsPropName].push_back(wsPropValue); } diff --git a/Framework/CurveFitting/src/Algorithms/SplineInterpolation.cpp b/Framework/CurveFitting/src/Algorithms/SplineInterpolation.cpp index 9cd6f62a192..1978323b913 100644 --- a/Framework/CurveFitting/src/Algorithms/SplineInterpolation.cpp +++ b/Framework/CurveFitting/src/Algorithms/SplineInterpolation.cpp @@ -223,7 +223,7 @@ void SplineInterpolation::exec() { } // Store the output workspaces std::string derivWsName = getPropertyValue("OutputWorkspaceDeriv"); - if (order > 0 && derivWsName != "") { + if (order > 0 && !derivWsName.empty()) { // Store derivatives in a grouped workspace WorkspaceGroup_sptr wsg = WorkspaceGroup_sptr(new WorkspaceGroup); for (size_t i = 0; i < histNo; ++i) { diff --git a/Framework/CurveFitting/src/Functions/CrystalFieldMultiSpectrum.cpp b/Framework/CurveFitting/src/Functions/CrystalFieldMultiSpectrum.cpp index 7dec77fd50f..a9180754a94 100644 --- a/Framework/CurveFitting/src/Functions/CrystalFieldMultiSpectrum.cpp +++ b/Framework/CurveFitting/src/Functions/CrystalFieldMultiSpectrum.cpp @@ -266,7 +266,7 @@ void CrystalFieldMultiSpectrum::calcExcitations( // using an index instead of a name for performance reasons auto &source = dynamic_cast<Peaks &>(*m_source); double intensityScaling; - if (source.m_IntensityScalingIdx.size() == 0) { + if (source.m_IntensityScalingIdx.empty()) { intensityScaling = getParameter(m_nOwnParams - nSpec + iSpec); } else { intensityScaling = getParameter(source.m_IntensityScalingIdx[iSpec]); diff --git a/Framework/CurveFitting/src/Functions/TabulatedFunction.cpp b/Framework/CurveFitting/src/Functions/TabulatedFunction.cpp index a10ed3ab8ab..a9fe5275204 100644 --- a/Framework/CurveFitting/src/Functions/TabulatedFunction.cpp +++ b/Framework/CurveFitting/src/Functions/TabulatedFunction.cpp @@ -174,7 +174,7 @@ void TabulatedFunction::setAttribute(const std::string &attName, } FileValidator fval; std::string error = fval.isValid(fileName); - if (error == "") { + if (error.empty()) { storeAttributeValue(attName, Attribute(fileName, true)); storeAttributeValue("Workspace", Attribute("")); } else { diff --git a/Framework/DataHandling/src/DownloadInstrument.cpp b/Framework/DataHandling/src/DownloadInstrument.cpp index 5bd0af84487..1b45d90322b 100644 --- a/Framework/DataHandling/src/DownloadInstrument.cpp +++ b/Framework/DataHandling/src/DownloadInstrument.cpp @@ -204,7 +204,7 @@ DownloadInstrument::StringToStringMap DownloadInstrument::processRepository() { if ((sha != installSha) && (sha != localSha)) { fileMap.emplace(htmlUrl, filePath.toString()); // ACTION - DOWNLOAD to localPath - } else if ((localSha != "") && (sha == installSha) && + } else if ((!localSha.empty()) && (sha == installSha) && (sha != localSha)) // matches install, but different local { fileMap.emplace( diff --git a/Framework/DataHandling/src/LoadAscii2.cpp b/Framework/DataHandling/src/LoadAscii2.cpp index e5ccb44c41b..3ffa5ed3b66 100644 --- a/Framework/DataHandling/src/LoadAscii2.cpp +++ b/Framework/DataHandling/src/LoadAscii2.cpp @@ -671,7 +671,7 @@ void LoadAscii2::exec() { std::string sep; // If the custom separator property is not empty, then we use that under any // circumstance. - if (custom != "") { + if (!custom.empty()) { sep = custom; } // Else if the separator drop down choice is not UserDefined then we use that. diff --git a/Framework/DataHandling/src/LoadFITS.cpp b/Framework/DataHandling/src/LoadFITS.cpp index 0754635782a..694bbb04743 100644 --- a/Framework/DataHandling/src/LoadFITS.cpp +++ b/Framework/DataHandling/src/LoadFITS.cpp @@ -293,7 +293,7 @@ void LoadFITS::loadHeader(const std::string &filePath, FITSInfo &header) { } // scale parameter, header BSCALE in the fits standard - if ("" == header.headerKeys[m_headerScaleKey]) { + if (header.headerKeys[m_headerScaleKey].empty()) { header.scale = 1; } else { try { @@ -308,7 +308,7 @@ void LoadFITS::loadHeader(const std::string &filePath, FITSInfo &header) { } // data offsset parameter, header BZERO in the fits standard - if ("" == header.headerKeys[m_headerOffsetKey]) { + if (header.headerKeys[m_headerOffsetKey].empty()) { header.offset = 0; } else { try { @@ -361,7 +361,7 @@ void LoadFITS::loadHeader(const std::string &filePath, FITSInfo &header) { void LoadFITS::headerSanityCheck(const FITSInfo &hdr, const FITSInfo &hdrFirst) { bool valid = true; - if (hdr.extension != "") { + if (!hdr.extension.empty()) { valid = false; g_log.error() << "File " << hdr.filePath << ": extensions found in the header.\n"; @@ -625,7 +625,7 @@ void LoadFITS::parseHeader(FITSInfo &headerInfo) { if (key == g_END_KEYNAME) endFound = true; - if (key != "") + if (!key.empty()) headerInfo.headerKeys[key] = value; } } @@ -1141,7 +1141,7 @@ void LoadFITS::setupDefaultKeywordNames() { * Maps the header keys to specified values */ void LoadFITS::mapHeaderKeys() { - if ("" == getPropertyValue(g_HEADER_MAP_NAME)) + if (getPropertyValue(g_HEADER_MAP_NAME).empty()) return; // If a map file is selected, use that. @@ -1157,19 +1157,19 @@ void LoadFITS::mapHeaderKeys() { while (getline(fStream, line)) { boost::split(lineSplit, line, boost::is_any_of("=")); - if (lineSplit[0] == g_ROTATION_NAME && lineSplit[1] != "") + if (lineSplit[0] == g_ROTATION_NAME && !lineSplit[1].empty()) m_headerRotationKey = lineSplit[1]; - if (lineSplit[0] == g_BIT_DEPTH_NAME && lineSplit[1] != "") + if (lineSplit[0] == g_BIT_DEPTH_NAME && !lineSplit[1].empty()) m_headerBitDepthKey = lineSplit[1]; - if (lineSplit[0] == g_AXIS_NAMES_NAME && lineSplit[1] != "") { + if (lineSplit[0] == g_AXIS_NAMES_NAME && !lineSplit[1].empty()) { m_headerAxisNameKeys.clear(); boost::split(m_headerAxisNameKeys, lineSplit[1], boost::is_any_of(",")); } - if (lineSplit[0] == g_IMAGE_KEY_NAME && lineSplit[1] != "") { + if (lineSplit[0] == g_IMAGE_KEY_NAME && !lineSplit[1].empty()) { m_headerImageKeyKey = lineSplit[1]; } } diff --git a/Framework/DataHandling/src/LoadFullprofResolution.cpp b/Framework/DataHandling/src/LoadFullprofResolution.cpp index 32c8bc93506..cb0e15e0128 100644 --- a/Framework/DataHandling/src/LoadFullprofResolution.cpp +++ b/Framework/DataHandling/src/LoadFullprofResolution.cpp @@ -189,7 +189,7 @@ void LoadFullprofResolution::exec() { // Generate output table workspace API::ITableWorkspace_sptr outTabWs = genTableWorkspace(bankparammap); - if (getPropertyValue("OutputTableWorkspace") != "") { + if (!getPropertyValue("OutputTableWorkspace").empty()) { // Output the output table workspace setProperty("OutputTableWorkspace", outTabWs); } @@ -225,7 +225,7 @@ void LoadFullprofResolution::exec() { loadParamAlg->execute(); } } - } else if (getPropertyValue("OutputTableWorkspace") == "") { + } else if (getPropertyValue("OutputTableWorkspace").empty()) { // We don't know where to output throw std::runtime_error( "Either the OutputTableWorkspace or Workspace property must be set."); diff --git a/Framework/DataHandling/src/LoadGSASInstrumentFile.cpp b/Framework/DataHandling/src/LoadGSASInstrumentFile.cpp index 239ea187ff4..ca4e25413be 100644 --- a/Framework/DataHandling/src/LoadGSASInstrumentFile.cpp +++ b/Framework/DataHandling/src/LoadGSASInstrumentFile.cpp @@ -151,7 +151,7 @@ void LoadGSASInstrumentFile::exec() { WorkspaceGroup_sptr wsg = getProperty("Workspace"); // Generate output table workspace API::ITableWorkspace_sptr outTabWs = genTableWorkspace(bankparammap); - if (getPropertyValue("OutputTableWorkspace") != "") { + if (!getPropertyValue("OutputTableWorkspace").empty()) { // Output the output table workspace setProperty("OutputTableWorkspace", outTabWs); } diff --git a/Framework/DataHandling/src/LoadIDFFromNexus.cpp b/Framework/DataHandling/src/LoadIDFFromNexus.cpp index f68ae54eb58..74305f3eedf 100644 --- a/Framework/DataHandling/src/LoadIDFFromNexus.cpp +++ b/Framework/DataHandling/src/LoadIDFFromNexus.cpp @@ -88,7 +88,7 @@ void LoadIDFFromNexus::exec() { // Look for parameter correction file std::string parameterCorrectionFile = getPropertyValue("ParameterCorrectionFilePath"); - if (parameterCorrectionFile == "") { + if (parameterCorrectionFile.empty()) { parameterCorrectionFile = getParameterCorrectionFile(localWorkspace->getInstrument()->getName()); } @@ -98,7 +98,7 @@ void LoadIDFFromNexus::exec() { // Read parameter correction file, if found std::string correctionParameterFile; bool append = false; - if (parameterCorrectionFile != "") { + if (!parameterCorrectionFile.empty()) { // Read parameter correction file // to find out which parameter file to use // and whether it is appended to default parameters. @@ -112,7 +112,7 @@ void LoadIDFFromNexus::exec() { // Load default parameters if either there is no correction parameter file or // it is to be appended. - if (correctionParameterFile == "" || append) { + if (correctionParameterFile.empty() || append) { LoadParameters(&nxfile, localWorkspace); } else { // Else clear the parameters g_log.notice() << "Parameters to be replaced are cleared.\n"; @@ -120,7 +120,7 @@ void LoadIDFFromNexus::exec() { } // Load parameters from correction parameter file, if it exists - if (correctionParameterFile != "") { + if (!correctionParameterFile.empty()) { Poco::Path corrFilePath(parameterCorrectionFile); g_log.debug() << "Correction file path: " << corrFilePath.toString() << "\n"; @@ -200,7 +200,7 @@ void LoadIDFFromNexus::readParameterCorrectionFile( append = false; // Check the date. - if (date == "") { + if (date.empty()) { g_log.notice() << "No date is supplied for parameter correction file " << correction_file << ". Correction file is ignored.\n"; return; diff --git a/Framework/DataHandling/src/LoadILLDiffraction.cpp b/Framework/DataHandling/src/LoadILLDiffraction.cpp index 707c1e4661b..f04af6189a0 100644 --- a/Framework/DataHandling/src/LoadILLDiffraction.cpp +++ b/Framework/DataHandling/src/LoadILLDiffraction.cpp @@ -480,7 +480,7 @@ std::vector<double> LoadILLDiffraction::getScannedVaribleByPropertyName( } } - if (scannedVariable.size() == 0) + if (scannedVariable.empty()) throw std::runtime_error( "Can not load file because scanned variable with property name " + propertyName + " was not found"); diff --git a/Framework/DataHandling/src/LoadILLIndirect2.cpp b/Framework/DataHandling/src/LoadILLIndirect2.cpp index 4a40a4d3eb8..9360967a296 100644 --- a/Framework/DataHandling/src/LoadILLIndirect2.cpp +++ b/Framework/DataHandling/src/LoadILLIndirect2.cpp @@ -130,7 +130,7 @@ void LoadILLIndirect2::exec() { void LoadILLIndirect2::setInstrumentName( const NeXus::NXEntry &firstEntry, const std::string &instrumentNamePath) { - if (instrumentNamePath == "") { + if (instrumentNamePath.empty()) { std::string message("Cannot set the instrument name from the Nexus file!"); g_log.error(message); throw std::runtime_error(message); diff --git a/Framework/DataHandling/src/LoadILLReflectometry.cpp b/Framework/DataHandling/src/LoadILLReflectometry.cpp index 8a5b69d8b49..f5f647ae829 100644 --- a/Framework/DataHandling/src/LoadILLReflectometry.cpp +++ b/Framework/DataHandling/src/LoadILLReflectometry.cpp @@ -176,7 +176,7 @@ void LoadILLReflectometry::exec() { void LoadILLReflectometry::setInstrumentName( const NeXus::NXEntry &firstEntry, const std::string &instrumentNamePath) { - if (instrumentNamePath == "") { + if (instrumentNamePath.empty()) { std::string message("Cannot set the instrument name from the Nexus file!"); g_log.error(message); throw std::runtime_error(message); diff --git a/Framework/DataHandling/src/LoadILLSANS.cpp b/Framework/DataHandling/src/LoadILLSANS.cpp index 4e04e099d39..b9c0d3667cb 100644 --- a/Framework/DataHandling/src/LoadILLSANS.cpp +++ b/Framework/DataHandling/src/LoadILLSANS.cpp @@ -107,7 +107,7 @@ void LoadILLSANS::exec() { void LoadILLSANS::setInstrumentName(const NeXus::NXEntry &firstEntry, const std::string &instrumentNamePath) { - if (instrumentNamePath == "") { + if (instrumentNamePath.empty()) { std::string message("Cannot set the instrument name from the Nexus file!"); g_log.error(message); throw std::runtime_error(message); diff --git a/Framework/DataHandling/src/LoadILLTOF2.cpp b/Framework/DataHandling/src/LoadILLTOF2.cpp index 50f76c1d024..9cc3f2e0a70 100644 --- a/Framework/DataHandling/src/LoadILLTOF2.cpp +++ b/Framework/DataHandling/src/LoadILLTOF2.cpp @@ -144,7 +144,7 @@ void LoadILLTOF2::loadInstrumentDetails(NeXus::NXEntry &firstEntry) { m_instrumentPath = m_loader.findInstrumentNexusPath(firstEntry); - if (m_instrumentPath == "") { + if (m_instrumentPath.empty()) { throw std::runtime_error( "Cannot set the instrument name from the Nexus file!"); } diff --git a/Framework/DataHandling/src/LoadIsawDetCal.cpp b/Framework/DataHandling/src/LoadIsawDetCal.cpp index f2a479594d1..54638a6518b 100644 --- a/Framework/DataHandling/src/LoadIsawDetCal.cpp +++ b/Framework/DataHandling/src/LoadIsawDetCal.cpp @@ -92,7 +92,7 @@ std::map<std::string, std::string> LoadIsawDetCal::validateInputs() { // two detcal files is only valid for snap std::vector<std::string> filenames = getFilenames(); - if (filenames.size() == 0) { + if (filenames.empty()) { result["Filename"] = "Must supply .detcal file"; } else if (filenames.size() == 2) { Workspace_const_sptr wksp = getProperty("InputWorkspace"); diff --git a/Framework/DataHandling/src/LoadLLB.cpp b/Framework/DataHandling/src/LoadLLB.cpp index 83f047c8782..6599483496a 100644 --- a/Framework/DataHandling/src/LoadLLB.cpp +++ b/Framework/DataHandling/src/LoadLLB.cpp @@ -104,7 +104,7 @@ void LoadLLB::setInstrumentName(NeXus::NXEntry &entry) { m_instrumentName = m_loader.getStringFromNexusPath(entry, m_instrumentPath + "/name"); - if (m_instrumentName == "") { + if (m_instrumentName.empty()) { throw std::runtime_error( "Cannot read the instrument name from the Nexus file!"); } diff --git a/Framework/DataHandling/src/LoadMLZ.cpp b/Framework/DataHandling/src/LoadMLZ.cpp index 1ad5df05084..23159b7e790 100644 --- a/Framework/DataHandling/src/LoadMLZ.cpp +++ b/Framework/DataHandling/src/LoadMLZ.cpp @@ -149,7 +149,7 @@ void LoadMLZ::loadInstrumentDetails(NeXus::NXEntry &firstEntry) { m_instrumentPath = m_mlzloader.findInstrumentNexusPath(firstEntry); - if (m_instrumentPath == "") { + if (m_instrumentPath.empty()) { throw std::runtime_error( "Cannot set the instrument name from the Nexus file!"); } diff --git a/Framework/DataHandling/src/LoadSINQFocus.cpp b/Framework/DataHandling/src/LoadSINQFocus.cpp index d7a6a56b7ba..3494437cfa3 100644 --- a/Framework/DataHandling/src/LoadSINQFocus.cpp +++ b/Framework/DataHandling/src/LoadSINQFocus.cpp @@ -112,7 +112,7 @@ void LoadSINQFocus::setInstrumentName(NeXus::NXEntry &entry) { m_instrumentPath = m_loader.findInstrumentNexusPath(entry); - if (m_instrumentPath == "") { + if (m_instrumentPath.empty()) { throw std::runtime_error( "Cannot set the instrument name from the Nexus file!"); } diff --git a/Framework/DataHandling/src/LoadSpiceXML2DDet.cpp b/Framework/DataHandling/src/LoadSpiceXML2DDet.cpp index eb822378272..f8eda027c8d 100644 --- a/Framework/DataHandling/src/LoadSpiceXML2DDet.cpp +++ b/Framework/DataHandling/src/LoadSpiceXML2DDet.cpp @@ -231,7 +231,7 @@ void LoadSpiceXML2DDet::processInputs() { if (vec_pixelgeom.size() == 2) { m_numPixelX = vec_pixelgeom[0]; m_numPixelY = vec_pixelgeom[1]; - } else if (vec_pixelgeom.size() == 0) { + } else if (vec_pixelgeom.empty()) { m_numPixelX = 0; m_numPixelY = 0; } else { @@ -714,7 +714,7 @@ LoadSpiceXML2DDet::parseDetectorNode(const std::string &detvaluestr, size_t num_empty_line = 0; size_t num_weird_line = 0; for (size_t iline = 0; iline < vecLines.size(); ++iline) { - if (vecLines[iline].size() == 0) + if (vecLines[iline].empty()) ++num_empty_line; else if (vecLines[iline].size() < 100) ++num_weird_line; diff --git a/Framework/DataHandling/src/LoadTBL.cpp b/Framework/DataHandling/src/LoadTBL.cpp index 1eeaff23a34..b5ab7f31e63 100644 --- a/Framework/DataHandling/src/LoadTBL.cpp +++ b/Framework/DataHandling/src/LoadTBL.cpp @@ -342,7 +342,7 @@ void LoadTBL::exec() { std::string line; int stitchID = 1; while (Kernel::Strings::extractToEOL(file, line)) { - if (line == "" || line == ",,,,,,,,,,,,,,,,") { + if (line.empty() || line == ",,,,,,,,,,,,,,,,") { continue; } getCells(line, rowVec, 16, isOld); @@ -351,8 +351,8 @@ void LoadTBL::exec() { // check if the first run in the row has any data associated with it // 0 = runs, 1 = theta, 2 = trans, 3 = qmin, 4 = qmax - if (rowVec[0] != "" || rowVec[1] != "" || rowVec[2] != "" || - rowVec[3] != "" || rowVec[4] != "") { + if (!rowVec[0].empty() || !rowVec[1].empty() || !rowVec[2].empty() || + !rowVec[3].empty() || !rowVec[4].empty()) { TableRow row = ws->appendRow(); row << stitchStr; for (int i = 0; i < 5; ++i) { @@ -364,8 +364,8 @@ void LoadTBL::exec() { // check if the second run in the row has any data associated with it // 5 = runs, 6 = theta, 7 = trans, 8 = qmin, 9 = qmax - if (rowVec[5] != "" || rowVec[6] != "" || rowVec[7] != "" || - rowVec[8] != "" || rowVec[9] != "") { + if (!rowVec[5].empty() || !rowVec[6].empty() || !rowVec[7].empty() || + !rowVec[8].empty() || !rowVec[9].empty()) { TableRow row = ws->appendRow(); row << stitchStr; for (int i = 5; i < 10; ++i) { @@ -377,8 +377,8 @@ void LoadTBL::exec() { // check if the third run in the row has any data associated with it // 10 = runs, 11 = theta, 12 = trans, 13 = qmin, 14 = qmax - if (rowVec[10] != "" || rowVec[11] != "" || rowVec[12] != "" || - rowVec[13] != "" || rowVec[14] != "") { + if (!rowVec[10].empty() || !rowVec[11].empty() || !rowVec[12].empty() || + !rowVec[13].empty() || !rowVec[14].empty()) { TableRow row = ws->appendRow(); row << stitchStr; for (int i = 10; i < 17; ++i) { @@ -413,7 +413,7 @@ void LoadTBL::exec() { } size_t expectedCommas = columnHeadings.size() - 1; while (Kernel::Strings::extractToEOL(file, line)) { - if (line == "" || line == ",,,,,,,,,,,,,,,,") { + if (line.empty() || line == ",,,,,,,,,,,,,,,,") { // skip over any empty lines continue; } diff --git a/Framework/DataHandling/src/SaveAscii.cpp b/Framework/DataHandling/src/SaveAscii.cpp index 090452f8089..2b10f7211f0 100644 --- a/Framework/DataHandling/src/SaveAscii.cpp +++ b/Framework/DataHandling/src/SaveAscii.cpp @@ -111,7 +111,7 @@ void SaveAscii::exec() { std::string sep; // If the custom separator property is not empty, then we use that under any // circumstance. - if (custom != "") { + if (!custom.empty()) { sep = custom; } // Else if the separator drop down choice is not UserDefined then we use that. diff --git a/Framework/DataHandling/src/SaveAscii2.cpp b/Framework/DataHandling/src/SaveAscii2.cpp index e44f640c9e5..55a10b34c34 100644 --- a/Framework/DataHandling/src/SaveAscii2.cpp +++ b/Framework/DataHandling/src/SaveAscii2.cpp @@ -166,7 +166,7 @@ void SaveAscii2::exec() { const std::string custom = getPropertyValue("CustomSeparator"); // If the custom separator property is not empty, then we use that under any // circumstance. - if (custom != "") { + if (!custom.empty()) { m_sep = custom; } // Else if the separator drop down choice is not UserDefined then we use that. diff --git a/Framework/DataHandling/src/SaveReflCustomAscii.cpp b/Framework/DataHandling/src/SaveReflCustomAscii.cpp index 6b9a61892c1..2630e931e3e 100644 --- a/Framework/DataHandling/src/SaveReflCustomAscii.cpp +++ b/Framework/DataHandling/src/SaveReflCustomAscii.cpp @@ -34,7 +34,7 @@ void SaveReflCustomAscii::extraHeaders(std::ofstream &file) { std::string subtitleEntry; std::string title = getProperty("Title"); - if (title != "") // if is toggled + if (!title.empty()) // if is toggled { file << "#" << title << '\n'; } diff --git a/Framework/DataHandling/src/SaveReflThreeColumnAscii.cpp b/Framework/DataHandling/src/SaveReflThreeColumnAscii.cpp index 29b9218c24e..cf8c9cd7013 100644 --- a/Framework/DataHandling/src/SaveReflThreeColumnAscii.cpp +++ b/Framework/DataHandling/src/SaveReflThreeColumnAscii.cpp @@ -28,7 +28,7 @@ void SaveReflThreeColumnAscii::extraHeaders(std::ofstream &file) { auto samp = m_ws->run(); std::string title = getProperty("Title"); - if (title != "") // if is toggled + if (!title.empty()) // if is toggled { file << "#" << title << '\n'; } diff --git a/Framework/DataHandling/src/SaveToSNSHistogramNexus.cpp b/Framework/DataHandling/src/SaveToSNSHistogramNexus.cpp index b44854c1b2f..38625424c86 100644 --- a/Framework/DataHandling/src/SaveToSNSHistogramNexus.cpp +++ b/Framework/DataHandling/src/SaveToSNSHistogramNexus.cpp @@ -560,13 +560,13 @@ int SaveToSNSHistogramNexus::WriteGroup(int is_definition) { } //--------------------------------------------------------------------------------------- - if (data_label == "data" && (bank != "")) { + if (data_label == "data" && (!bank.empty())) { if (this->WriteDataGroup(bank, is_definition) != NX_OK) return NX_ERROR; ; } //--------------------------------------------------------------------------------------- - else if (data_label == "time_of_flight" && (bank != "")) { + else if (data_label == "time_of_flight" && (!bank.empty())) { // Get the original info if (NXgetinfo(inId, &dataRank, dataDimensions, &dataType) != NX_OK) return NX_ERROR; diff --git a/Framework/DataObjects/src/EventList.cpp b/Framework/DataObjects/src/EventList.cpp index 9471b3bf95b..64dd418bad5 100644 --- a/Framework/DataObjects/src/EventList.cpp +++ b/Framework/DataObjects/src/EventList.cpp @@ -4403,7 +4403,7 @@ void EventList::splitByPulseTimeWithMatrix( } // Split - if (vec_target.size() == 0) { + if (vec_target.empty()) { // No splitter: copy all events to group workspace = -1 (*outputs[-1]) = (*this); } else { diff --git a/Framework/Geometry/src/Crystal/SymmetryElementFactory.cpp b/Framework/Geometry/src/Crystal/SymmetryElementFactory.cpp index 09c5dfd1b37..471c225be68 100644 --- a/Framework/Geometry/src/Crystal/SymmetryElementFactory.cpp +++ b/Framework/Geometry/src/Crystal/SymmetryElementFactory.cpp @@ -313,7 +313,7 @@ std::string SymmetryElementMirrorGenerator::determineSymbol( * proper symbol, so the general symbol "g" is used for these cases. * Examples can be found in No. 227 (Fd-3m). */ - if (symbol == "") { + if (symbol.empty()) { return "g"; } diff --git a/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp b/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp index f079aa5fa59..62e0b6d875c 100644 --- a/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp +++ b/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp @@ -1282,7 +1282,7 @@ void InstrumentDefinitionParser::createDetectorOrMonitor( std::stringstream ss1, ss2; ss1 << idList.vec.size(); ss2 << idList.counted; - if (idList.idname == "") { + if (idList.idname.empty()) { g_log.error("No list of detector IDs found for location element " + name); throw Kernel::Exception::InstrumentDefinitionError( "Detector location element " + name + " has no idlist.", filename); diff --git a/Framework/HistogramData/src/CountStandardDeviations.cpp b/Framework/HistogramData/src/CountStandardDeviations.cpp index 40fc5823bcd..439692a50a0 100644 --- a/Framework/HistogramData/src/CountStandardDeviations.cpp +++ b/Framework/HistogramData/src/CountStandardDeviations.cpp @@ -24,7 +24,7 @@ CountStandardDeviations::CountStandardDeviations( throw std::logic_error("CountStandardDeviations: Cannot construct from " "FrequencyStandardDeviations -- BinEdges are NULL."); if ((frequencies.size() + 1) != edges.size()) - if (frequencies.size() != 0 || edges.size() != 0) + if (!frequencies.empty() || !edges.empty()) throw std::logic_error("CountStandardDeviations: Cannot construct from " "FrequencyStandardDeviations -- BinEdges size " "does not " diff --git a/Framework/HistogramData/src/CountVariances.cpp b/Framework/HistogramData/src/CountVariances.cpp index 3153e6f540e..baf7b9c4c55 100644 --- a/Framework/HistogramData/src/CountVariances.cpp +++ b/Framework/HistogramData/src/CountVariances.cpp @@ -23,7 +23,7 @@ CountVariances::CountVariances(FrequencyVariances &&frequencies, throw std::logic_error("CountVariances: Cannot construct from " "FrequencyVariances -- BinEdges are NULL."); if ((frequencies.size() + 1) != edges.size()) - if (frequencies.size() != 0 || edges.size() != 0) + if (!frequencies.empty() || !edges.empty()) throw std::logic_error("CountVariances: Cannot construct from " "FrequencyVariances -- BinEdges size does not " "match."); diff --git a/Framework/HistogramData/src/Counts.cpp b/Framework/HistogramData/src/Counts.cpp index f63e47a0da0..3c5b7e0461f 100644 --- a/Framework/HistogramData/src/Counts.cpp +++ b/Framework/HistogramData/src/Counts.cpp @@ -17,7 +17,7 @@ Counts::Counts(Frequencies &&frequencies, const BinEdges &edges) { throw std::logic_error( "Counts: Cannot construct from Frequencies -- BinEdges are NULL."); if ((frequencies.size() + 1) != edges.size()) - if (frequencies.size() != 0 || edges.size() != 0) + if (!frequencies.empty() || !edges.empty()) throw std::logic_error("Counts: Cannot construct from Frequencies -- " "BinEdges size does not match."); // Cannot move frequencies private data since it is of different type. diff --git a/Framework/HistogramData/src/Frequencies.cpp b/Framework/HistogramData/src/Frequencies.cpp index 21b8836351a..6623ee0b2f8 100644 --- a/Framework/HistogramData/src/Frequencies.cpp +++ b/Framework/HistogramData/src/Frequencies.cpp @@ -17,7 +17,7 @@ Frequencies::Frequencies(Counts &&counts, const BinEdges &edges) { throw std::logic_error( "Frequencies: Cannot construct from Counts -- BinEdges are NULL."); if ((counts.size() + 1) != edges.size()) - if (counts.size() != 0 || edges.size() != 0) + if (!counts.empty() || !edges.empty()) throw std::logic_error("Frequencies: Cannot construct from Counts -- " "BinEdges size does not match."); // Cannot move counts private data since it is of different type. diff --git a/Framework/HistogramData/src/FrequencyStandardDeviations.cpp b/Framework/HistogramData/src/FrequencyStandardDeviations.cpp index a4b568727b1..99665e08cf8 100644 --- a/Framework/HistogramData/src/FrequencyStandardDeviations.cpp +++ b/Framework/HistogramData/src/FrequencyStandardDeviations.cpp @@ -23,7 +23,7 @@ FrequencyStandardDeviations::FrequencyStandardDeviations( throw std::logic_error("FrequencyStandardDeviations: Cannot construct from " "CountStandardDeviations -- BinEdges are NULL."); if ((counts.size() + 1) != edges.size()) - if (counts.size() != 0 || edges.size() != 0) + if (!counts.empty() || !edges.empty()) throw std::logic_error("FrequencyStandardDeviations: Cannot construct " "from CountStandardDeviations -- BinEdges size " "does not match."); diff --git a/Framework/HistogramData/src/FrequencyVariances.cpp b/Framework/HistogramData/src/FrequencyVariances.cpp index 86c7c47bb61..a68c1c1ac07 100644 --- a/Framework/HistogramData/src/FrequencyVariances.cpp +++ b/Framework/HistogramData/src/FrequencyVariances.cpp @@ -23,7 +23,7 @@ FrequencyVariances::FrequencyVariances(CountVariances &&counts, throw std::logic_error("FrequencyVariances: Cannot construct from " "CountVariances -- BinEdges are NULL."); if ((counts.size() + 1) != edges.size()) - if (counts.size() != 0 || edges.size() != 0) + if (!counts.empty() || !edges.empty()) throw std::logic_error("FrequencyVariances: Cannot construct from " "CountVariances -- BinEdges size does not match."); // Cannot move counts private data since it is of different type. diff --git a/Framework/HistogramData/src/Points.cpp b/Framework/HistogramData/src/Points.cpp index 78edbfac5fb..a375c2c64f9 100644 --- a/Framework/HistogramData/src/Points.cpp +++ b/Framework/HistogramData/src/Points.cpp @@ -10,7 +10,7 @@ Points::Points(const BinEdges &edges) { return; if (edges.size() == 1) throw std::logic_error("Points: Cannot construct from BinEdges of size 1"); - if (edges.size() == 0) { + if (edges.empty()) { m_data = Kernel::make_cow<HistogramX>(0); return; } diff --git a/Framework/Kernel/inc/MantidKernel/PropertyWithValue.tcc b/Framework/Kernel/inc/MantidKernel/PropertyWithValue.tcc index 134f38a8d0c..a4902017dbb 100644 --- a/Framework/Kernel/inc/MantidKernel/PropertyWithValue.tcc +++ b/Framework/Kernel/inc/MantidKernel/PropertyWithValue.tcc @@ -271,7 +271,7 @@ TYPE &PropertyWithValue<TYPE>::operator=(const TYPE &value) { m_value = value; } std::string problem = this->isValid(); - if (problem == "") { + if (problem.empty()) { return m_value; } else if (problem == "_alias") { m_value = getValueForAlias(value); diff --git a/Framework/Kernel/src/CompositeValidator.cpp b/Framework/Kernel/src/CompositeValidator.cpp index b87ecc4f290..55fd549ab0d 100644 --- a/Framework/Kernel/src/CompositeValidator.cpp +++ b/Framework/Kernel/src/CompositeValidator.cpp @@ -74,7 +74,7 @@ std::string CompositeValidator::check(const boost::any &value) const { std::string error = (*itr)->check(value); // exit on the first error, to avoid passing doing more tests on invalid // objects that could fail - if (error != "") + if (!error.empty()) return error; } // there were no errors diff --git a/Framework/Kernel/src/ConfigService.cpp b/Framework/Kernel/src/ConfigService.cpp index 92f5b6b5d4c..59ca2639dfb 100644 --- a/Framework/Kernel/src/ConfigService.cpp +++ b/Framework/Kernel/src/ConfigService.cpp @@ -372,7 +372,7 @@ void ConfigServiceImpl::loadConfig(const std::string &filename, bool good = readFile(filename, temp); // check if we have failed to open the file - if ((!good) || (temp == "")) { + if ((!good) || (temp.empty())) { if (filename == getUserPropertiesDir() + m_user_properties_file_name) { // write out a fresh file createUserPropertiesFile(); @@ -382,7 +382,7 @@ void ConfigServiceImpl::loadConfig(const std::string &filename, } // store the property string - if ((append) && (m_PropertyString != "")) { + if ((append) && (!m_PropertyString.empty())) { m_PropertyString = m_PropertyString + "\n" + temp; } else { m_PropertyString = temp; diff --git a/Framework/Kernel/src/UsageService.cpp b/Framework/Kernel/src/UsageService.cpp index 5b77d1be8fa..54ab2d4a49e 100644 --- a/Framework/Kernel/src/UsageService.cpp +++ b/Framework/Kernel/src/UsageService.cpp @@ -263,7 +263,7 @@ std::string UsageServiceImpl::generateFeatureUsageMessage() { thisFeature["count"] = featureItem.second; features.append(thisFeature); } - if (features.size() > 0) { + if (!features.empty()) { message["features"] = features; return writer.write(message); } diff --git a/Framework/MDAlgorithms/src/CompareMDWorkspaces.cpp b/Framework/MDAlgorithms/src/CompareMDWorkspaces.cpp index e11d0a2a9c9..943900034c0 100644 --- a/Framework/MDAlgorithms/src/CompareMDWorkspaces.cpp +++ b/Framework/MDAlgorithms/src/CompareMDWorkspaces.cpp @@ -341,7 +341,7 @@ void CompareMDWorkspaces::exec() { this->doComparison(); - if (m_result != "") { + if (!m_result.empty()) { g_log.notice() << "The workspaces did not match: " << m_result << '\n'; this->setProperty("Equals", false); } else { diff --git a/Framework/MDAlgorithms/src/ConvertToDiffractionMDWorkspace3.cpp b/Framework/MDAlgorithms/src/ConvertToDiffractionMDWorkspace3.cpp index 3eb926cae75..639462ab745 100644 --- a/Framework/MDAlgorithms/src/ConvertToDiffractionMDWorkspace3.cpp +++ b/Framework/MDAlgorithms/src/ConvertToDiffractionMDWorkspace3.cpp @@ -70,7 +70,7 @@ void ConvertToDiffractionMDWorkspace3::convertExtents( minVal[d] = Extents[2 * d + 0]; maxVal[d] = Extents[2 * d + 1]; } - } else if (Extents.size() == 0) { + } else if (Extents.empty()) { calculateExtentsFromData(minVal, maxVal); } else throw std::invalid_argument( diff --git a/Framework/Nexus/src/NexusFileIO.cpp b/Framework/Nexus/src/NexusFileIO.cpp index 502ab8330ec..e373e252dbb 100644 --- a/Framework/Nexus/src/NexusFileIO.cpp +++ b/Framework/Nexus/src/NexusFileIO.cpp @@ -264,7 +264,7 @@ bool NexusFileIO::writeNxNote(const std::string ¬eName, m_filehandle->makeGroup(noteName, "NXnote", true); std::vector<std::string> attributes, avalues; - if (date != "") { + if (!date.empty()) { attributes.emplace_back("date"); avalues.push_back(date); } diff --git a/Framework/PythonInterface/mantid/api/src/Exports/IAlgorithm.cpp b/Framework/PythonInterface/mantid/api/src/Exports/IAlgorithm.cpp index 889e326b374..6115a7a2561 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/IAlgorithm.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/IAlgorithm.cpp @@ -93,7 +93,7 @@ struct MandatoryFirst { /// in the list bool operator()(const Property *p1, const Property *p2) const { // this is false, unless p1 is not valid and p2 is valid - return (p1->isValid() != "") && (p2->isValid() == ""); + return (!p1->isValid().empty()) && (p2->isValid().empty()); } }; diff --git a/Framework/SINQ/src/PoldiPeakSearch.cpp b/Framework/SINQ/src/PoldiPeakSearch.cpp index f6091db34bb..2b502b516b6 100644 --- a/Framework/SINQ/src/PoldiPeakSearch.cpp +++ b/Framework/SINQ/src/PoldiPeakSearch.cpp @@ -564,7 +564,7 @@ void PoldiPeakSearch::exec() { Unit_sptr xUnit = correlationWorkspace->getAxis(0)->unit(); - if (xUnit->caption() == "") { + if (xUnit->caption().empty()) { g_log.information() << " Workspace does not have unit, defaulting to MomentumTransfer.\n"; diff --git a/Framework/TestHelpers/src/FileComparisonHelper.cpp b/Framework/TestHelpers/src/FileComparisonHelper.cpp index 5da64ccbeec..ccf783e80f2 100644 --- a/Framework/TestHelpers/src/FileComparisonHelper.cpp +++ b/Framework/TestHelpers/src/FileComparisonHelper.cpp @@ -112,7 +112,7 @@ bool areIteratorsEqual(streamCharIter refStream, streamCharIter testStream, Mantid::Kernel::Logger g_log("FileComparisonHelper"); g_log.error("Length of both files were not identical"); areStreamsEqual = false; - } else if (numNewLines == 0 && seenChars.size() == 0) { + } else if (numNewLines == 0 && seenChars.empty()) { Mantid::Kernel::Logger g_log("FileComparisonHelper"); g_log.error("No characters checked in FileComparisonHelper"); areStreamsEqual = false; @@ -190,7 +190,7 @@ bool isEqualToReferenceFile(const std::string &referenceFileName, const std::string referenceFilePath = Mantid::API::FileFinder::Instance().getFullPath(referenceFileName); - if (referenceFilePath == "") { + if (referenceFilePath.empty()) { throw std::invalid_argument("No reference file with the name: " + referenceFileName + " could be found by FileComparisonHelper"); -- GitLab