Commit 16793a5f authored by Peterson, Peter's avatar Peterson, Peter
Browse files

Fixing cppcheck warnings

parent 029a7ea6
......@@ -114,8 +114,6 @@ std::shared_ptr<Mantid::API::TableRow> binarySearchForRow(API::ITableWorkspace_s
size_t currentPosition = start + ((end - start) / 2);
Mantid::API::TableRow currentRow = ws->getRow(currentPosition);
currentRow = ws->getRow(currentPosition);
if (currentRow.Int(0) > detid) {
end = currentPosition - 1;
} else if (currentRow.Int(0) < detid) {
......
......@@ -57,8 +57,8 @@ private:
std::vector<bool> buildMergeIndices(const ComponentInfo &other) const;
void checkSizes(const ComponentInfo &other) const;
void initIndices();
void checkIdenticalIntervals(const ComponentInfo &other, const std::pair<size_t, size_t> indexOther,
const std::pair<size_t, size_t> indexThis) const;
void checkIdenticalIntervals(const ComponentInfo &other, const std::pair<size_t, size_t> &indexOther,
const std::pair<size_t, size_t> &indexThis) const;
void checkSpecialIndices(size_t componentIndex) const;
size_t nonDetectorSize() const;
/// Copy constructor is private because of the way DetectorInfo stored
......@@ -101,9 +101,9 @@ public:
Eigen::Vector3d relativePosition(const size_t componentIndex) const;
Eigen::Quaterniond relativeRotation(const size_t componentIndex) const;
void setPosition(const size_t componentIndex, const Eigen::Vector3d &newPosition);
void setPosition(const std::pair<size_t, size_t> index, const Eigen::Vector3d &newPosition);
void setPosition(const std::pair<size_t, size_t> &index, const Eigen::Vector3d &newPosition);
void setRotation(const size_t componentIndex, const Eigen::Quaterniond &newRotation);
void setRotation(const std::pair<size_t, size_t> index, const Eigen::Quaterniond &newRotation);
void setRotation(const std::pair<size_t, size_t> &index, const Eigen::Quaterniond &newRotation);
size_t parent(const size_t componentIndex) const;
bool hasParent(const size_t componentIndex) const;
......
......@@ -327,7 +327,7 @@ void ComponentInfo::setPosition(const size_t componentIndex, const Eigen::Vector
* @param index : Component, time index pair
* @param newPosition : Absolute position to set
*/
void ComponentInfo::setPosition(const std::pair<size_t, size_t> index, const Eigen::Vector3d &newPosition) {
void ComponentInfo::setPosition(const std::pair<size_t, size_t> &index, const Eigen::Vector3d &newPosition) {
const auto componentIndex = index.first;
checkSpecialIndices(componentIndex);
......@@ -371,7 +371,7 @@ void ComponentInfo::setRotation(const size_t componentIndex, const Eigen::Quater
* @param index : Component and time index pair
* @param newRotation : Absolute rotation to set
*/
void ComponentInfo::setRotation(const std::pair<size_t, size_t> index, const Eigen::Quaterniond &newRotation) {
void ComponentInfo::setRotation(const std::pair<size_t, size_t> &index, const Eigen::Quaterniond &newRotation) {
const auto componentIndex = index.first;
checkSpecialIndices(componentIndex);
if (isDetector(componentIndex))
......@@ -659,8 +659,8 @@ void ComponentInfo::checkSizes(const ComponentInfo &other) const {
failMerge("size mismatch");
}
void ComponentInfo::checkIdenticalIntervals(const ComponentInfo &other, const std::pair<size_t, size_t> indexOther,
const std::pair<size_t, size_t> indexThis) const {
void ComponentInfo::checkIdenticalIntervals(const ComponentInfo &other, const std::pair<size_t, size_t> &indexOther,
const std::pair<size_t, size_t> &indexThis) const {
if (this->position(indexThis) != other.position(indexOther))
failMerge("matching scan interval but positions differ");
if (this->rotation(indexThis).coeffs() != other.rotation(indexOther).coeffs())
......
......@@ -324,6 +324,7 @@ BasePeak &BasePeak::operator=(const BasePeak &other) {
m_InverseGoniometerMatrix = other.m_InverseGoniometerMatrix;
m_runNumber = other.m_runNumber;
m_monitorCount = other.m_monitorCount;
m_peakNumber = other.m_peakNumber;
m_intHKL = other.m_intHKL;
m_intMNP = other.m_intMNP;
m_peakShape.reset(other.m_peakShape->clone());
......
......@@ -307,7 +307,8 @@ void EventList::createFromHistogram(const ISpectrum *inSpec, bool GenerateZeros,
* @return reference to this
* */
EventList &EventList::operator=(const EventList &rhs) {
// Note that we are NOT copying the MRU pointer.
// Note that we are NOT copying the MRU pointer
// the EventWorkspace that posseses the EventList has already configured the mru
IEventList::operator=(rhs);
m_histogram = rhs.m_histogram;
events = rhs.events;
......@@ -945,13 +946,14 @@ void EventList::setSortOrder(const EventSortType order) const { this->order = or
// --------------------------------------------------------------------------
/** Sort events by TOF in one thread */
void EventList::sortTof() const {
if (this->order == TOF_SORT)
return; // nothing to do
// nothing to do
if (this->order == TOF_SORT) // cppcheck-suppress identicalConditionAfterEarlyExit
return;
// Avoid sorting from multiple threads
std::lock_guard<std::mutex> _lock(m_sortMutex);
// If the list was sorted while waiting for the lock, return.
if (this->order == TOF_SORT)
if (this->order == TOF_SORT) // cppcheck-suppress identicalConditionAfterEarlyExit
return;
switch (eventType) {
......@@ -1011,13 +1013,13 @@ void EventList::sortTimeAtSample(const double &tofFactor, const double &tofShift
// --------------------------------------------------------------------------
/** Sort events by Frame */
void EventList::sortPulseTime() const {
if (this->order == PULSETIME_SORT)
if (this->order == PULSETIME_SORT) // cppcheck-suppress identicalConditionAfterEarlyExit
return; // nothing to do
// Avoid sorting from multiple threads
std::lock_guard<std::mutex> _lock(m_sortMutex);
// If the list was sorted while waiting for the lock, return.
if (this->order == PULSETIME_SORT)
if (this->order == PULSETIME_SORT) // cppcheck-suppress identicalConditionAfterEarlyExit
return;
// Perform sort.
......@@ -1041,13 +1043,13 @@ void EventList::sortPulseTime() const {
* (the absolute time)
*/
void EventList::sortPulseTimeTOF() const {
if (this->order == PULSETIMETOF_SORT)
return; // already ordered.
if (this->order == PULSETIMETOF_SORT) // cppcheck-suppress identicalConditionAfterEarlyExit
return; // already ordered
// Avoid sorting from multiple threads
std::lock_guard<std::mutex> _lock(m_sortMutex);
// If the list was sorted while waiting for the lock, return.
if (this->order == PULSETIMETOF_SORT)
if (this->order == PULSETIMETOF_SORT) // cppcheck-suppress identicalConditionAfterEarlyExit
return;
switch (eventType) {
......
......@@ -174,7 +174,7 @@ public:
/// Make list of the circle of direction vectors that form a fixed angle
/// with the specified axis
static std::vector<Kernel::V3D> MakeCircleDirections(int n_steps, const Kernel::V3D axis, double angle_degrees);
static std::vector<Kernel::V3D> MakeCircleDirections(int n_steps, const Kernel::V3D &axis, double angle_degrees);
/// Choose the direction in a list of directions, that is most nearly
/// perpendicular to planes with the specified spacing in reciprocal space.
......
......@@ -194,7 +194,7 @@ public:
std::string transformedSymbol = getTransformedSymbolOrthorhombic(hmSymbol, transformation);
bool symbolExists = std::find(transformedSpaceGroupSymbols.cbegin(), transformedSpaceGroupSymbols.cend(),
transformedSymbol) != transformedSpaceGroupSymbols.end();
transformedSymbol) != transformedSpaceGroupSymbols.cend();
if (transformedSymbol != hmSymbol && !symbolExists) {
subscribeUsingGenerator<TransformationSpaceGroupGenerator>(
......
......@@ -86,15 +86,15 @@ public:
bool uniqueName(const std::string &name) const;
bool isDetector(const size_t componentIndex) const;
Kernel::V3D position(const size_t componentIndex) const;
Kernel::V3D position(const std::pair<size_t, size_t> index) const;
Kernel::V3D position(const std::pair<size_t, size_t> &index) const;
Kernel::Quat rotation(const size_t componentIndex) const;
Kernel::Quat rotation(const std::pair<size_t, size_t> index) const;
Kernel::Quat rotation(const std::pair<size_t, size_t> &index) const;
Kernel::V3D relativePosition(const size_t componentIndex) const;
Kernel::Quat relativeRotation(const size_t componentIndex) const;
void setPosition(size_t componentIndex, const Kernel::V3D &newPosition);
void setRotation(size_t componentIndex, const Kernel::Quat &newRotation);
void setPosition(const std::pair<size_t, size_t> index, const Kernel::V3D &newPosition);
void setRotation(const std::pair<size_t, size_t> index, const Kernel::Quat &newRotation);
void setPosition(const std::pair<size_t, size_t> &index, const Kernel::V3D &newPosition);
void setRotation(const std::pair<size_t, size_t> &index, const Kernel::Quat &newRotation);
size_t parent(const size_t componentIndex) const;
bool hasParent(const size_t componentIndex) const;
bool hasDetectorInfo() const;
......
......@@ -28,7 +28,7 @@ public:
Container();
Container(IObject_sptr shape);
Container(const Container &container);
Container(std::string xml);
Container(const std::string &xml);
bool hasCustomizableSampleShape() const;
bool hasFixedSampleShape() const;
......
......@@ -42,7 +42,8 @@ struct GoniometerAxis {
int sense; /// Rotation sense (1 for CCW, -1 for CW)
int angleunit; /// angle units are angDegrees or angRadians (see AngleUnits.h)
/// Constructor
GoniometerAxis(std::string initname, Kernel::V3D initrotationaxis, double initangle, int initsense, int initangleunit)
GoniometerAxis(std::string initname, const Kernel::V3D &initrotationaxis, double initangle, int initsense,
int initangleunit)
: name(std::move(initname)), rotationaxis(initrotationaxis), angle(initangle), sense(initsense),
angleunit(initangleunit) {}
GoniometerAxis() : name(""), rotationaxis(), angle(0.), sense(0), angleunit(0) {}
......
......@@ -23,8 +23,7 @@ HKLGenerator::HKLGenerator(const Kernel::V3D &hklMinMax)
m_end(getEndIterator()) {}
/// Constructs a generator that creates all indices from -h,-k,-l to h,k,l.
HKLGenerator::HKLGenerator(int hMinMax, int kMinMax, int lMinMax) {
m_hklMax = V3D(hMinMax, kMinMax, lMinMax);
HKLGenerator::HKLGenerator(int hMinMax, int kMinMax, int lMinMax) : m_hklMax(hMinMax, kMinMax, lMinMax) {
m_hklMin = m_hklMax * -1;
m_size = getSize(m_hklMin, m_hklMax);
......@@ -34,8 +33,8 @@ HKLGenerator::HKLGenerator(int hMinMax, int kMinMax, int lMinMax) {
/// Constructs a generator that creates all indices for the given cell up to
/// dMin.
HKLGenerator::HKLGenerator(const UnitCell &unitCell, double dMin) {
m_hklMax = V3D(floor(unitCell.a() / dMin), floor(unitCell.b() / dMin), floor(unitCell.c() / dMin));
HKLGenerator::HKLGenerator(const UnitCell &unitCell, double dMin)
: m_hklMax(floor(unitCell.a() / dMin), floor(unitCell.b() / dMin), floor(unitCell.c() / dMin)) {
m_hklMin = m_hklMax * -1;
m_size = getSize(m_hklMin, m_hklMax);
......
......@@ -2642,7 +2642,7 @@ std::vector<V3D> IndexingUtils::MakeHemisphereDirections(int n_steps) {
@throws std::invalid_argument exception if the number of steps is <= 0, or
if the axix length is 0.
*/
std::vector<V3D> IndexingUtils::MakeCircleDirections(int n_steps, const V3D axis, double angle_degrees) {
std::vector<V3D> IndexingUtils::MakeCircleDirections(int n_steps, const Kernel::V3D &axis, double angle_degrees) {
if (n_steps <= 0) {
throw std::invalid_argument("MakeCircleDirections(): n_steps must be greater than 0");
}
......
......@@ -146,7 +146,7 @@ Kernel::V3D ComponentInfo::position(const size_t componentIndex) const {
return Kernel::toV3D(m_componentInfo->position(componentIndex));
}
Kernel::V3D ComponentInfo::position(const std::pair<size_t, size_t> index) const {
Kernel::V3D ComponentInfo::position(const std::pair<size_t, size_t> &index) const {
return Kernel::toV3D(m_componentInfo->position(index));
}
......@@ -154,7 +154,7 @@ Kernel::Quat ComponentInfo::rotation(const size_t componentIndex) const {
return Kernel::toQuat(m_componentInfo->rotation(componentIndex));
}
Kernel::Quat ComponentInfo::rotation(const std::pair<size_t, size_t> index) const {
Kernel::Quat ComponentInfo::rotation(const std::pair<size_t, size_t> &index) const {
return Kernel::toQuat(m_componentInfo->rotation(index));
}
......@@ -166,11 +166,11 @@ Kernel::Quat ComponentInfo::relativeRotation(const size_t componentIndex) const
return Kernel::toQuat(m_componentInfo->relativeRotation(componentIndex));
}
void ComponentInfo::setPosition(const std::pair<size_t, size_t> index, const Kernel::V3D &newPosition) {
void ComponentInfo::setPosition(const std::pair<size_t, size_t> &index, const Kernel::V3D &newPosition) {
m_componentInfo->setPosition(index, Kernel::toVector3d(newPosition));
}
void ComponentInfo::setRotation(const std::pair<size_t, size_t> index, const Kernel::Quat &newRotation) {
void ComponentInfo::setRotation(const std::pair<size_t, size_t> &index, const Kernel::Quat &newRotation) {
m_componentInfo->setRotation(index, Kernel::toQuaterniond(newRotation));
}
......
......@@ -65,7 +65,7 @@ Container::Container(const Container &container)
* Construct a container providing an XML definition shape
* @param xml Definition of the shape in xml
*/
Container::Container(std::string xml) : m_shape(std::make_shared<CSGObject>(xml)) {}
Container::Container(const std::string &xml) : m_shape(std::make_shared<CSGObject>(xml)) {}
/**
* @return True if the can contains a definition of the sample shape
......
......@@ -56,7 +56,7 @@ class SpectrumNumberTranslator;
*/
class MANTID_INDEXING_DLL IndexInfo {
public:
explicit IndexInfo(const size_t globalSize, const Parallel::StorageMode storageMode = Parallel::StorageMode::Cloned);
explicit IndexInfo(const size_t globalSize, const Parallel::StorageMode &storageMode = Parallel::StorageMode::Cloned);
IndexInfo(const size_t globalSize, const Parallel::StorageMode storageMode,
const Parallel::Communicator &communicator);
explicit IndexInfo(std::vector<SpectrumNumber> spectrumNumbers,
......
......@@ -22,7 +22,7 @@ namespace Indexing {
/// Construct a default IndexInfo, with contiguous spectrum numbers starting at
/// 1 and no spectrum definitions.
IndexInfo::IndexInfo(const size_t globalSize, const Parallel::StorageMode storageMode)
IndexInfo::IndexInfo(const size_t globalSize, const Parallel::StorageMode &storageMode)
: IndexInfo(globalSize, storageMode, Parallel::Communicator{}) {}
/// Construct a default IndexInfo, with contiguous spectrum numbers starting at
......
......@@ -42,12 +42,12 @@ public:
const bool allowMultiSelection = false)
: TypedValidator<TYPE>(), m_allowedValues(values.begin(), values.end()),
m_aliases(aliases.begin(), aliases.end()), m_allowMultiSelection(allowMultiSelection) {
for (auto aliasIt = m_aliases.begin(); aliasIt != m_aliases.end(); ++aliasIt) {
if (values.end() == std::find(values.begin(), values.end(), boost::lexical_cast<TYPE>(aliasIt->second))) {
throw std::invalid_argument("Alias " + aliasIt->first + " refers to invalid value " + aliasIt->second);
if (m_allowMultiSelection) {
throw Kernel::Exception::NotImplementedError("The List Validator does not support multi selection yet");
}
for (auto aliasIt = m_aliases.begin(); aliasIt != m_aliases.end(); ++aliasIt) {
if (values.end() == std::find(values.begin(), values.end(), boost::lexical_cast<TYPE>(aliasIt->second))) {
throw std::invalid_argument("Alias " + aliasIt->first + " refers to invalid value " + aliasIt->second);
}
}
}
......
......@@ -101,10 +101,10 @@ public:
std::ostream &debug();
/// Log a message at a given priority
void log(const std::string &message, Logger::Priority priority);
void log(const std::string &message, const Priority &priority);
/// gets the correct log stream for a priority
std::ostream &getLogStream(Logger::Priority priority);
std::ostream &getLogStream(const Priority &priority);
/// Logs the given message at debug level, followed by the data in buffer.
void dump(const std::string &msg, const void *buffer, std::size_t length);
......
......@@ -203,7 +203,7 @@ public:
protected:
/// Constructor
Property(std::string name, const std::type_info &type, unsigned int direction = Direction::Input);
Property(std::string name, const std::type_info &type, const unsigned int &direction = Direction::Input);
/// Copy constructor
Property(const Property &right);
/// The name of the property
......
......@@ -62,10 +62,7 @@ private:
TYPE mvalue;
public:
TimeValueUnit(const Types::Core::DateAndTime &time, TYPE value) {
mtime = time;
mvalue = value;
}
TimeValueUnit(const Types::Core::DateAndTime &time, const TYPE &value) : mtime(time), mvalue(value) {}
~TimeValueUnit() = default;
......@@ -184,11 +181,11 @@ public:
std::vector<double> timesAsVectorSeconds() const;
/// Add a value to the map using a DateAndTime object
void addValue(const Types::Core::DateAndTime &time, const TYPE value);
void addValue(const Types::Core::DateAndTime &time, const TYPE &value);
/// Add a value to the map using a string time
void addValue(const std::string &time, const TYPE value);
void addValue(const std::string &time, const TYPE &value);
/// Add a value to the map using a time_t
void addValue(const std::time_t &time, const TYPE value);
void addValue(const std::time_t &time, const TYPE &value);
/// Adds vectors of values to the map. Should be much faster than repeated
/// calls to addValue.
void addValues(const std::vector<Types::Core::DateAndTime> &times, const std::vector<TYPE> &values);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment