Skip to content

Commit

Permalink
Updated fixes for cppcheck suppressions
Browse files Browse the repository at this point in the history
  • Loading branch information
SilkeSchomann committed Jan 31, 2025
1 parent 367ba9d commit 4443b40
Show file tree
Hide file tree
Showing 15 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Framework/SINQ/inc/MantidSINQ/PoldiPeakSearch.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class MANTID_SINQ_DLL PoldiPeakSearch : public API::Algorithm {
MantidVec::const_iterator end) const;

std::list<MantidVec::const_iterator>
mapPeakPositionsToCorrelationData(std::list<MantidVec::const_iterator> &peakPositions,
mapPeakPositionsToCorrelationData(const std::list<MantidVec::const_iterator> &peakPositions,
MantidVec::const_iterator baseDataStart,
MantidVec::const_iterator originalDataStart) const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace Poldi {
class MANTID_SINQ_DLL MillerIndices {
public:
MillerIndices(int h = 0, int k = 0, int l = 0);
MillerIndices(std::vector<int> &hkl);
MillerIndices(const std::vector<int> &hkl);
MillerIndices(const Kernel::V3D &hkl);

int h() const;
Expand Down
2 changes: 1 addition & 1 deletion Framework/SINQ/inc/MantidSINQ/PoldiUtilities/PoldiPeak.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class MANTID_SINQ_DLL PoldiPeak {
public:
enum FwhmRelation { AbsoluteQ, AbsoluteD, Relative };

PoldiPeak_sptr clone() const;
PoldiPeak_sptr clonePeak() const;

const MillerIndices &hkl() const;
void setHKL(MillerIndices hkl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class MANTID_SINQ_DLL PoldiPeakCollection {

virtual ~PoldiPeakCollection() = default;

PoldiPeakCollection_sptr clone();
PoldiPeakCollection_sptr clonePeakCollection();

size_t peakCount() const;

Expand Down
10 changes: 5 additions & 5 deletions Framework/SINQ/src/PoldiFitPeaks2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ PoldiFitPeaks2D::getIntegratedPeakCollection(const PoldiPeakCollection_sptr &raw
* except cloning the collection, to make behavior consistent, since
* integrating also results in a new peak collection.
*/
return rawPeakCollection->clone();
return rawPeakCollection->clonePeakCollection();
}

/* If no profile function is specified, it's not possible to get integrated
Expand Down Expand Up @@ -229,7 +229,7 @@ PoldiFitPeaks2D::getIntegratedPeakCollection(const PoldiPeakCollection_sptr &raw
profileFunction->setHeight(peak->intensity());
profileFunction->setFwhm(peak->fwhm(PoldiPeak::AbsoluteD));

PoldiPeak_sptr integratedPeak = peak->clone();
PoldiPeak_sptr integratedPeak = peak->clonePeak();
integratedPeak->setIntensity(UncertainValue(profileFunction->intensity()));
integratedPeakCollection->addPeak(integratedPeak);
}
Expand Down Expand Up @@ -267,7 +267,7 @@ PoldiFitPeaks2D::getNormalizedPeakCollection(const PoldiPeakCollection_sptr &pea
PoldiPeak_sptr peak = peakCollection->peak(i);
double calculatedIntensity = m_timeTransformer->calculatedTotalIntensity(peak->d());

PoldiPeak_sptr normalizedPeak = peak->clone();
PoldiPeak_sptr normalizedPeak = peak->clonePeak();
normalizedPeak->setIntensity(peak->intensity() / calculatedIntensity);
normalizedPeakCollection->addPeak(normalizedPeak);
}
Expand Down Expand Up @@ -340,7 +340,7 @@ PoldiPeakCollection_sptr PoldiFitPeaks2D::getCountPeakCollection(const PoldiPeak
PoldiPeak_sptr peak = peakCollection->peak(i);
double calculatedIntensity = m_timeTransformer->calculatedTotalIntensity(peak->d());

PoldiPeak_sptr countPeak = peak->clone();
PoldiPeak_sptr countPeak = peak->clonePeak();
countPeak->setIntensity(peak->intensity() * calculatedIntensity);

countPeakCollection->addPeak(countPeak);
Expand Down Expand Up @@ -574,7 +574,7 @@ std::string PoldiFitPeaks2D::getRefinedStartingCell(const std::string &initialCe
latticeFunction->setUnitCell(cell);

// Remove errors from d-values
PoldiPeakCollection_sptr clone = peakCollection->clone();
PoldiPeakCollection_sptr clone = peakCollection->clonePeakCollection();
for (size_t i = 0; i < clone->peakCount(); ++i) {
PoldiPeak_sptr peak = clone->peak(i);

Expand Down
2 changes: 1 addition & 1 deletion Framework/SINQ/src/PoldiIndexKnownCompounds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ PoldiIndexKnownCompounds::getIntensitySortedPeakCollection(const PoldiPeakCollec

PoldiPeakCollection_sptr sortedPeaks = std::make_shared<PoldiPeakCollection>(peaks->intensityType());
for (const auto &peak : peakVector) {
sortedPeaks->addPeak(peak->clone());
sortedPeaks->addPeak(peak->clonePeak());
}

return sortedPeaks;
Expand Down
4 changes: 2 additions & 2 deletions Framework/SINQ/src/PoldiPeakSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ std::list<MantidVec::const_iterator> PoldiPeakSearch::findPeaks(MantidVec::const
++iter;
}

return std::move(truncatedPeaks);
return truncatedPeaks;
}

/** Actual recursive peak search method
Expand Down Expand Up @@ -180,7 +180,7 @@ std::list<MantidVec::const_iterator> PoldiPeakSearch::findPeaksRecursive(MantidV
*data.
*/
std::list<MantidVec::const_iterator>
PoldiPeakSearch::mapPeakPositionsToCorrelationData(std::list<MantidVec::const_iterator> &peakPositions,
PoldiPeakSearch::mapPeakPositionsToCorrelationData(const std::list<MantidVec::const_iterator> &peakPositions,
MantidVec::const_iterator baseDataStart,
MantidVec::const_iterator originalDataStart) const {
std::list<MantidVec::const_iterator> transformedIndices;
Expand Down
2 changes: 1 addition & 1 deletion Framework/SINQ/src/PoldiUtilities/MillerIndices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ MillerIndices::MillerIndices(int h, int k, int l)
populateVector();
}

MillerIndices::MillerIndices(std::vector<int> &hkl) {
MillerIndices::MillerIndices(const std::vector<int> &hkl) {
if (hkl.size() != 3) {
throw std::runtime_error("MillerIndices object can only be created with 3 indices");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ double PoldiInstrumentAdapter::extractPropertyFromRun(const Run &runInformation,
throw std::runtime_error("Cannot construct instrument without " + propertyName + "-property in log. Aborting.");
}

Kernel::Property *property = runInformation.getProperty(propertyName);
const Kernel::Property *property = runInformation.getProperty(propertyName);

AbstractDoubleValueExtractor_sptr extractor = getExtractorForProperty(property);

Expand Down
2 changes: 1 addition & 1 deletion Framework/SINQ/src/PoldiUtilities/PoldiPeak.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace Mantid::Poldi {

PoldiPeak_sptr PoldiPeak::clone() const { return PoldiPeak_sptr(new PoldiPeak(*this)); }
PoldiPeak_sptr PoldiPeak::clonePeak() const { return PoldiPeak_sptr(new PoldiPeak(*this)); }

const MillerIndices &PoldiPeak::hkl() const { return m_hkl; }

Expand Down
4 changes: 2 additions & 2 deletions Framework/SINQ/src/PoldiUtilities/PoldiPeakCollection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ PoldiPeakCollection::PoldiPeakCollection(const CrystalStructure &crystalStructur
setPeaks(hkls, dValues, structureFactors);
}

PoldiPeakCollection_sptr PoldiPeakCollection::clone() {
PoldiPeakCollection_sptr PoldiPeakCollection::clonePeakCollection() {
PoldiPeakCollection_sptr clone = std::make_shared<PoldiPeakCollection>(m_intensityType);
clone->setProfileFunctionName(m_profileFunctionName);
clone->setPointGroup(m_pointGroup);
clone->setUnitCell(m_unitCell);

for (const auto &peak : m_peaks) {
clone->addPeak(peak->clone());
clone->addPeak(peak->clonePeak());
}

return clone;
Expand Down
6 changes: 3 additions & 3 deletions Framework/SINQ/test/PoldiFitPeaks1D2Test.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,12 @@ class PoldiFitPeaks1D2Test : public CxxTest::TestSuite {

// Peaks with certain properties are rejected
// 1. negative intensity
PoldiPeak_sptr negativeIntensity = m_testPeak->clone();
PoldiPeak_sptr negativeIntensity = m_testPeak->clonePeak();
negativeIntensity->setIntensity(UncertainValue(-190.0));
TS_ASSERT(!poldiPeakFit.peakIsAcceptable(negativeIntensity));

// 2a. FWHM too large (rel. > 0.02)
PoldiPeak_sptr tooBroad = m_testPeak->clone();
PoldiPeak_sptr tooBroad = m_testPeak->clonePeak();
tooBroad->setFwhm(UncertainValue(0.021), PoldiPeak::Relative);
TS_ASSERT(!poldiPeakFit.peakIsAcceptable(tooBroad));

Expand All @@ -254,7 +254,7 @@ class PoldiFitPeaks1D2Test : public CxxTest::TestSuite {
TS_ASSERT(poldiPeakFit.peakIsAcceptable(tooBroad));

// 3. FWHM too small (rel. < 0.001)
PoldiPeak_sptr tooNarrow = m_testPeak->clone();
PoldiPeak_sptr tooNarrow = m_testPeak->clonePeak();
tooNarrow->setFwhm(UncertainValue(0.0009), PoldiPeak::Relative);
TS_ASSERT(!poldiPeakFit.peakIsAcceptable(tooNarrow));
}
Expand Down
2 changes: 1 addition & 1 deletion Framework/SINQ/test/PoldiFitPeaks2DTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class PoldiFitPeaks2DTest : public CxxTest::TestSuite {
// checking the actual integration result agains reference.
PoldiPeakCollection_sptr integratedReference(new PoldiPeakCollection(PoldiPeakCollection::Integral));
for (size_t i = 0; i < testPeaks->peakCount(); ++i) {
PoldiPeak_sptr peak = testPeaks->peak(i)->clone();
PoldiPeak_sptr peak = testPeaks->peak(i)->clonePeak();

double oldIntensity = peak->intensity();
double fwhm = peak->fwhm(PoldiPeak::AbsoluteD);
Expand Down
2 changes: 1 addition & 1 deletion Framework/SINQ/test/PoldiPeakCollectionTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ class PoldiPeakCollectionTest : public CxxTest::TestSuite {
peaks->addPeak(PoldiPeak::create(2.0));
peaks->addPeak(PoldiPeak::create(3.0));

PoldiPeakCollection_sptr clone = peaks->clone();
PoldiPeakCollection_sptr clone = peaks->clonePeakCollection();

// make sure those are different instances
TS_ASSERT(clone != peaks);
Expand Down
2 changes: 1 addition & 1 deletion Framework/SINQ/test/PoldiPeakTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class PoldiPeakTest : public CxxTest::TestSuite {

void testClone() {
PoldiPeak_sptr peak = PoldiPeak::create(1.0, 200.00);
PoldiPeak_sptr clone = peak->clone();
PoldiPeak_sptr clone = peak->clonePeak();

TS_ASSERT_EQUALS(peak->d(), clone->d());
TS_ASSERT_EQUALS(peak->fwhm(), clone->fwhm());
Expand Down

0 comments on commit 4443b40

Please sign in to comment.