Commit 2357c748 authored by David Fairbrother's avatar David Fairbrother
Browse files

Clang-tidy pass by ref

Runs clang-tidy pass by ref across the codebase to fix-up various
warnings we are seeing in cppcheck
parent 08088625
......@@ -33,7 +33,7 @@ public:
~Grouping();
/// Construct a Grouping from a table
Grouping(ITableWorkspace_sptr table);
Grouping(const ITableWorkspace_sptr &table);
/// Convert to grouping table
ITableWorkspace_sptr toTable() const;
......
......@@ -24,6 +24,8 @@
#endif
#include <string>
#include <utility>
#include <vector>
#ifdef _WIN32
......@@ -521,7 +523,8 @@ public:
/// Calculate numerical derivatives
void calNumericalDeriv(const FunctionDomain &domain, Jacobian &jacobian);
/// Set the covariance matrix
void setCovarianceMatrix(boost::shared_ptr<Kernel::Matrix<double>> covar);
void
setCovarianceMatrix(const boost::shared_ptr<Kernel::Matrix<double>> &covar);
/// Get the covariance matrix
boost::shared_ptr<const Kernel::Matrix<double>> getCovarianceMatrix() const {
return m_covar;
......@@ -562,11 +565,11 @@ protected:
/// Convert a value from one unit (inUnit) to unit defined in workspace (ws)
double convertValue(double value, Kernel::Unit_sptr &outUnit,
boost::shared_ptr<const MatrixWorkspace> ws,
const boost::shared_ptr<const MatrixWorkspace> &ws,
size_t wsIndex) const;
void convertValue(std::vector<double> &values, Kernel::Unit_sptr &outUnit,
boost::shared_ptr<const MatrixWorkspace> ws,
const boost::shared_ptr<const MatrixWorkspace> &ws,
size_t wsIndex) const;
/// Override to declare function attributes
......@@ -635,7 +638,7 @@ using IFunction_const_sptr = boost::shared_ptr<const IFunction>;
class FunctionHandler {
public:
/// Constructor
FunctionHandler(IFunction_sptr fun) : m_fun(fun) {}
FunctionHandler(IFunction_sptr fun) : m_fun(std::move(fun)) {}
/// Virtual destructor
virtual ~FunctionHandler() = default;
/// abstract init method. It is called after setting handler to the function
......
......@@ -22,6 +22,7 @@
#endif
#include <sstream>
#include <utility>
namespace Mantid {
......@@ -349,7 +350,7 @@ public:
}
}
/// Construct directly from column
ColumnVector(Column_sptr column) : m_column(column) {
ColumnVector(Column_sptr column) : m_column(std::move(column)) {
if (!m_column->isType<T>()) {
std::stringstream mess;
mess << "Type mismatch when creating a ColumnVector<" << typeid(T).name()
......@@ -387,7 +388,7 @@ public:
}
}
/// Construct directly from column
ConstColumnVector(Column_const_sptr column) : m_column(column) {
ConstColumnVector(Column_const_sptr column) : m_column(std::move(column)) {
if (!m_column->isType<T>()) {
std::stringstream mess;
mess << "Type mismatch when creating a ColumnVector<" << typeid(T).name()
......
......@@ -32,7 +32,7 @@ public:
IndexProperty(const std::string &name,
const IWorkspaceProperty &workspaceProp,
const IndexTypeProperty &indexTypeProp,
Kernel::IValidator_sptr validator =
const Kernel::IValidator_sptr &validator =
Kernel::IValidator_sptr(new Kernel::NullValidator));
IndexProperty *clone() const override;
......
......@@ -31,7 +31,7 @@ public:
size_t getNParts() const override;
/// Return i-th domain
const FunctionDomain &getDomain(size_t i) const override;
void addDomain(FunctionDomain_sptr domain);
void addDomain(const FunctionDomain_sptr &domain);
protected:
/// Vector with member domains.
......
......@@ -64,7 +64,8 @@ public:
std::string getGeometryXML() const;
void addDimension(boost::shared_ptr<Mantid::Geometry::IMDDimension> dim);
void
addDimension(const boost::shared_ptr<Mantid::Geometry::IMDDimension> &dim);
void addDimension(Mantid::Geometry::IMDDimension *dim);
// --------------------------------------------------------------------------------------------
......
......@@ -52,7 +52,7 @@ private:
/// Try ot add a workspace to the group of input workspaces.
void tryAddInputWorkspaceToInputGroups(
Workspace_sptr ws, VecWSGroupType &vecMultiPeriodWorkspaceGroups,
const Workspace_sptr &ws, VecWSGroupType &vecMultiPeriodWorkspaceGroups,
VecWSGroupType &vecWorkspaceGroups) const;
/// Copy input workspace properties to spawned algorithm.
......
......@@ -27,7 +27,7 @@ public:
ExperimentInfo_const_sptr getExperimentInfo(const uint16_t runIndex) const;
uint16_t addExperimentInfo(ExperimentInfo_sptr ei);
uint16_t addExperimentInfo(const ExperimentInfo_sptr &ei);
void setExperimentInfo(const uint16_t runIndex, ExperimentInfo_sptr ei);
......
......@@ -26,20 +26,21 @@ namespace API {
class MANTID_API_DLL NotebookBuilder {
public:
NotebookBuilder(boost::shared_ptr<HistoryView> view,
NotebookBuilder(const boost::shared_ptr<HistoryView> &view,
std::string versionSpecificity = "old");
virtual ~NotebookBuilder() = default;
/// build an ipython notebook from the history view
const std::string build(std::string ws_name, std::string ws_title,
std::string ws_comment);
const std::string build(const std::string &ws_name,
const std::string &ws_title,
const std::string &ws_comment);
private:
void writeHistoryToStream(std::vector<HistoryItem>::const_iterator &iter);
void buildChildren(std::vector<HistoryItem>::const_iterator &iter);
const std::string
buildAlgorithmString(AlgorithmHistory_const_sptr algHistory);
const std::string
buildPropertyString(Mantid::Kernel::PropertyHistory_const_sptr propHistory);
buildAlgorithmString(const AlgorithmHistory_const_sptr &algHistory);
const std::string buildPropertyString(
const Mantid::Kernel::PropertyHistory_const_sptr &propHistory);
const std::vector<HistoryItem> m_historyItems;
std::string m_output;
......
......@@ -24,8 +24,8 @@ class MANTID_API_DLL NotebookWriter {
public:
NotebookWriter();
virtual ~NotebookWriter() = default;
std::string markdownCell(std::string string_text);
std::string codeCell(std::string string_code);
std::string markdownCell(const std::string &string_text);
std::string codeCell(const std::string &string_code);
std::string writeNotebook();
private:
......
......@@ -47,8 +47,8 @@ public:
/// alternative (lower level) create where the specific type of
/// manager and base URL are directly given
IRemoteJobManager_sptr create(const std::string baseURL,
const std::string jobManagerType) const;
IRemoteJobManager_sptr create(const std::string &baseURL,
const std::string &jobManagerType) const;
private:
/// So that the singleton can be created (cons/destructor are private)
......
......@@ -45,7 +45,7 @@ public:
/// the number of samples
std::size_t size() const;
/// Adds a sample to the list
void addSample(boost::shared_ptr<Sample> childSample);
void addSample(const boost::shared_ptr<Sample> &childSample);
/// Returns the name of the sample
const std::string &getName() const;
......
......@@ -37,7 +37,7 @@ public:
ScopedWorkspace();
/// Workspace constructor
ScopedWorkspace(Workspace_sptr ws);
ScopedWorkspace(const Workspace_sptr &ws);
/// Destructor
virtual ~ScopedWorkspace();
......@@ -61,7 +61,7 @@ public:
operator bool() const;
/// Make ADS entry to point to the given workspace
void set(Workspace_sptr newWS);
void set(const Workspace_sptr &newWS);
private:
/// ADS name of the workspace
......
......@@ -31,7 +31,7 @@ namespace API {
class MANTID_API_DLL ScriptBuilder {
public:
ScriptBuilder(
boost::shared_ptr<HistoryView> view,
const boost::shared_ptr<HistoryView> &view,
std::string versionSpecificity = "old", bool appendTimestamp = false,
std::vector<std::string> ignoreTheseAlgs = {},
std::vector<std::vector<std::string>> ignoreTheseAlgProperties = {},
......
......@@ -31,7 +31,7 @@ class MANTID_API_DLL SpectrumDetectorMapping {
using sdmap = std::unordered_map<specnum_t, std::set<detid_t>>;
public:
explicit SpectrumDetectorMapping(MatrixWorkspace_const_sptr workspace,
explicit SpectrumDetectorMapping(const MatrixWorkspace_const_sptr &workspace,
const bool useSpecNoIndex = true);
SpectrumDetectorMapping(
const std::vector<specnum_t> &spectrumNumbers,
......
......@@ -79,9 +79,9 @@ public:
private:
/// Recursive function to load the algorithm history tree from file
void loadNestedHistory(
::NeXus::File *file,
AlgorithmHistory_sptr parent = boost::shared_ptr<AlgorithmHistory>());
void loadNestedHistory(::NeXus::File *file,
const AlgorithmHistory_sptr &parent =
boost::shared_ptr<AlgorithmHistory>());
/// Parse an algorithm history string loaded from file
AlgorithmHistory_sptr parseAlgorithmHistory(const std::string &rawData);
/// Find the history entries at this level in the file.
......
......@@ -22,51 +22,51 @@ DLLExport ResultType executeBinaryOperation(
bool rethrow = false);
} // namespace OperatorOverloads
bool MANTID_API_DLL equals(const MatrixWorkspace_sptr lhs,
const MatrixWorkspace_sptr rhs,
bool MANTID_API_DLL equals(const MatrixWorkspace_sptr &lhs,
const MatrixWorkspace_sptr &rhs,
double tolerance = 0.0);
// Workspace operator overloads
MatrixWorkspace_sptr MANTID_API_DLL operator+(const MatrixWorkspace_sptr lhs,
const MatrixWorkspace_sptr rhs);
MatrixWorkspace_sptr MANTID_API_DLL operator-(const MatrixWorkspace_sptr lhs,
const MatrixWorkspace_sptr rhs);
MatrixWorkspace_sptr MANTID_API_DLL operator*(const MatrixWorkspace_sptr lhs,
const MatrixWorkspace_sptr rhs);
MatrixWorkspace_sptr MANTID_API_DLL operator/(const MatrixWorkspace_sptr lhs,
const MatrixWorkspace_sptr rhs);
MatrixWorkspace_sptr MANTID_API_DLL operator+(const MatrixWorkspace_sptr &lhs,
const MatrixWorkspace_sptr &rhs);
MatrixWorkspace_sptr MANTID_API_DLL operator-(const MatrixWorkspace_sptr &lhs,
const MatrixWorkspace_sptr &rhs);
MatrixWorkspace_sptr MANTID_API_DLL operator*(const MatrixWorkspace_sptr &lhs,
const MatrixWorkspace_sptr &rhs);
MatrixWorkspace_sptr MANTID_API_DLL operator/(const MatrixWorkspace_sptr &lhs,
const MatrixWorkspace_sptr &rhs);
MatrixWorkspace_sptr MANTID_API_DLL operator+(const MatrixWorkspace_sptr lhs,
MatrixWorkspace_sptr MANTID_API_DLL operator+(const MatrixWorkspace_sptr &lhs,
const double &rhsValue);
MatrixWorkspace_sptr MANTID_API_DLL operator-(const MatrixWorkspace_sptr lhs,
MatrixWorkspace_sptr MANTID_API_DLL operator-(const MatrixWorkspace_sptr &lhs,
const double &rhsValue);
MatrixWorkspace_sptr MANTID_API_DLL operator-(const double &lhsValue,
const MatrixWorkspace_sptr rhs);
MatrixWorkspace_sptr MANTID_API_DLL operator*(const MatrixWorkspace_sptr lhs,
const MatrixWorkspace_sptr &rhs);
MatrixWorkspace_sptr MANTID_API_DLL operator*(const MatrixWorkspace_sptr &lhs,
const double &rhsValue);
MatrixWorkspace_sptr MANTID_API_DLL operator*(const double &lhsValue,
const MatrixWorkspace_sptr rhs);
MatrixWorkspace_sptr MANTID_API_DLL operator/(const MatrixWorkspace_sptr lhs,
const MatrixWorkspace_sptr &rhs);
MatrixWorkspace_sptr MANTID_API_DLL operator/(const MatrixWorkspace_sptr &lhs,
const double &rhsValue);
MatrixWorkspace_sptr MANTID_API_DLL operator/(const double &lhsValue,
const MatrixWorkspace_sptr rhs);
const MatrixWorkspace_sptr &rhs);
MatrixWorkspace_sptr MANTID_API_DLL operator+=(const MatrixWorkspace_sptr lhs,
const MatrixWorkspace_sptr rhs);
MatrixWorkspace_sptr MANTID_API_DLL operator-=(const MatrixWorkspace_sptr lhs,
const MatrixWorkspace_sptr rhs);
MatrixWorkspace_sptr MANTID_API_DLL operator*=(const MatrixWorkspace_sptr lhs,
const MatrixWorkspace_sptr rhs);
MatrixWorkspace_sptr MANTID_API_DLL operator/=(const MatrixWorkspace_sptr lhs,
const MatrixWorkspace_sptr rhs);
MatrixWorkspace_sptr MANTID_API_DLL operator+=(const MatrixWorkspace_sptr &lhs,
const MatrixWorkspace_sptr &rhs);
MatrixWorkspace_sptr MANTID_API_DLL operator-=(const MatrixWorkspace_sptr &lhs,
const MatrixWorkspace_sptr &rhs);
MatrixWorkspace_sptr MANTID_API_DLL operator*=(const MatrixWorkspace_sptr &lhs,
const MatrixWorkspace_sptr &rhs);
MatrixWorkspace_sptr MANTID_API_DLL operator/=(const MatrixWorkspace_sptr &lhs,
const MatrixWorkspace_sptr &rhs);
MatrixWorkspace_sptr MANTID_API_DLL operator+=(const MatrixWorkspace_sptr lhs,
MatrixWorkspace_sptr MANTID_API_DLL operator+=(const MatrixWorkspace_sptr &lhs,
const double &rhsValue);
MatrixWorkspace_sptr MANTID_API_DLL operator-=(const MatrixWorkspace_sptr lhs,
MatrixWorkspace_sptr MANTID_API_DLL operator-=(const MatrixWorkspace_sptr &lhs,
const double &rhsValue);
MatrixWorkspace_sptr MANTID_API_DLL operator*=(const MatrixWorkspace_sptr lhs,
MatrixWorkspace_sptr MANTID_API_DLL operator*=(const MatrixWorkspace_sptr &lhs,
const double &rhsValue);
MatrixWorkspace_sptr MANTID_API_DLL operator/=(const MatrixWorkspace_sptr lhs,
MatrixWorkspace_sptr MANTID_API_DLL operator/=(const MatrixWorkspace_sptr &lhs,
const double &rhsValue);
/** A collection of static functions for use with workspaces
......@@ -83,7 +83,7 @@ struct MANTID_API_DLL WorkspaceHelpers {
static bool sharedXData(const MatrixWorkspace &WS);
// Divides the data in a workspace by the bin width to make it a distribution
// (or the reverse)
static void makeDistribution(MatrixWorkspace_sptr workspace,
static void makeDistribution(const MatrixWorkspace_sptr &workspace,
const bool forwards = true);
};
......
......@@ -59,20 +59,20 @@ public:
explicit WorkspaceProperty(
const std::string &name, const std::string &wsName,
const unsigned int direction,
Kernel::IValidator_sptr validator =
const Kernel::IValidator_sptr &validator =
Kernel::IValidator_sptr(new Kernel::NullValidator));
explicit WorkspaceProperty(
const std::string &name, const std::string &wsName,
const unsigned int direction, const PropertyMode::Type optional,
Kernel::IValidator_sptr validator =
const Kernel::IValidator_sptr &validator =
Kernel::IValidator_sptr(new Kernel::NullValidator));
explicit WorkspaceProperty(
const std::string &name, const std::string &wsName,
const unsigned int direction, const PropertyMode::Type optional,
const LockMode::Type locking,
Kernel::IValidator_sptr validator =
const Kernel::IValidator_sptr &validator =
Kernel::IValidator_sptr(new Kernel::NullValidator));
WorkspaceProperty(const WorkspaceProperty &right);
......@@ -118,7 +118,8 @@ public:
void setIsMasterRank(bool isMasterRank) override;
private:
std::string isValidGroup(boost::shared_ptr<WorkspaceGroup> wsGroup) const;
std::string
isValidGroup(const boost::shared_ptr<WorkspaceGroup> &wsGroup) const;
std::string isValidOutputWs() const;
......
......@@ -29,10 +29,9 @@ namespace API {
* Direction enum (i.e. 0-2)
*/
template <typename TYPE>
WorkspaceProperty<TYPE>::WorkspaceProperty(const std::string &name,
const std::string &wsName,
const unsigned int direction,
Kernel::IValidator_sptr validator)
WorkspaceProperty<TYPE>::WorkspaceProperty(
const std::string &name, const std::string &wsName,
const unsigned int direction, const Kernel::IValidator_sptr &validator)
: Kernel::PropertyWithValue<boost::shared_ptr<TYPE>>(
name, boost::shared_ptr<TYPE>(), validator, direction),
m_workspaceName(wsName), m_initialWSName(wsName),
......@@ -51,11 +50,10 @@ WorkspaceProperty<TYPE>::WorkspaceProperty(const std::string &name,
* Direction enum (i.e. 0-2)
*/
template <typename TYPE>
WorkspaceProperty<TYPE>::WorkspaceProperty(const std::string &name,
const std::string &wsName,
const unsigned int direction,
const PropertyMode::Type optional,
Kernel::IValidator_sptr validator)
WorkspaceProperty<TYPE>::WorkspaceProperty(
const std::string &name, const std::string &wsName,
const unsigned int direction, const PropertyMode::Type optional,
const Kernel::IValidator_sptr &validator)
: Kernel::PropertyWithValue<boost::shared_ptr<TYPE>>(
name, boost::shared_ptr<TYPE>(), validator, direction),
m_workspaceName(wsName), m_initialWSName(wsName), m_optional(optional),
......@@ -78,12 +76,10 @@ WorkspaceProperty<TYPE>::WorkspaceProperty(const std::string &name,
* Direction enum (i.e. 0-2)
*/
template <typename TYPE>
WorkspaceProperty<TYPE>::WorkspaceProperty(const std::string &name,
const std::string &wsName,
const unsigned int direction,
const PropertyMode::Type optional,
const LockMode::Type locking,
Kernel::IValidator_sptr validator)
WorkspaceProperty<TYPE>::WorkspaceProperty(
const std::string &name, const std::string &wsName,
const unsigned int direction, const PropertyMode::Type optional,
const LockMode::Type locking, const Kernel::IValidator_sptr &validator)
: Kernel::PropertyWithValue<boost::shared_ptr<TYPE>>(
name, boost::shared_ptr<TYPE>(), validator, direction),
m_workspaceName(wsName), m_initialWSName(wsName), m_optional(optional),
......@@ -410,7 +406,7 @@ void WorkspaceProperty<TYPE>::setIsMasterRank(bool isMasterRank) {
*/
template <typename TYPE>
std::string WorkspaceProperty<TYPE>::isValidGroup(
boost::shared_ptr<WorkspaceGroup> wsGroup) const {
const boost::shared_ptr<WorkspaceGroup> &wsGroup) const {
g_log.debug() << " Input WorkspaceGroup found \n";
std::vector<std::string> wsGroupNames = wsGroup->getNames();
......
......@@ -39,6 +39,7 @@
#include <json/json.h>
#include <map>
#include <utility>
// Index property handling template definitions
#include "MantidAPI/Algorithm.tcc"
......@@ -845,7 +846,7 @@ Algorithm_sptr Algorithm::createChildAlgorithm(const std::string &name,
* Can also be used manually for algorithms created otherwise. This allows
* running algorithms that are not declared into the factory as child
* algorithms. */
void Algorithm::setupAsChildAlgorithm(Algorithm_sptr alg,
void Algorithm::setupAsChildAlgorithm(const Algorithm_sptr &alg,
const double startProgress,
const double endProgress,
const bool enableLogging) {
......@@ -1077,7 +1078,7 @@ void Algorithm::linkHistoryWithLastChild() {
void Algorithm::trackAlgorithmHistory(
boost::shared_ptr<AlgorithmHistory> parentHist) {
enableHistoryRecordingForChild(true);
m_parentHistory = parentHist;
m_parentHistory = std::move(parentHist);
}
/** Check if we are tracking history for this algorithm
......
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