Skip to content

Commit

Permalink
Merge pull request #37218 from robertapplin/0-fix-coverity-warnings-i…
Browse files Browse the repository at this point in the history
…n-data-manipulations

Fix coverity warnings in Data Manipulations interface
  • Loading branch information
SilkeSchomann committed Apr 26, 2024
2 parents 03b15d3 + 27fb420 commit f552f6d
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 30 deletions.
Expand Up @@ -73,7 +73,7 @@ void DataManipulationInterface::initLayout() {
// Connect the "Manage User Directories" Button
connect(m_uiForm.pbManageDirectories, SIGNAL(clicked()), this, SLOT(manageUserDirectories()));

auto const facility = Mantid::Kernel::ConfigService::Instance().getFacility();
auto const &facility = Mantid::Kernel::ConfigService::Instance().getFacility();
filterUiForFacility(QString::fromStdString(facility.name()));

IndirectInterface::initLayout();
Expand Down
Expand Up @@ -23,10 +23,9 @@ using namespace MantidQt::MantidWidgets;

namespace MantidQt::CustomInterfaces {

//----------------------------------------------------------------------------------------------
/** Constructor
*/
ElwinModel::ElwinModel() {}
ElwinModel::ElwinModel()
: m_integrationStart(), m_integrationEnd(), m_backgroundStart(), m_backgroundEnd(), m_backgroundSubtraction(),
m_normalise(), m_outputWorkspaceNames() {}

void ElwinModel::setupLoadAlgorithm(MantidQt::API::BatchAlgorithmRunner *batchAlgoRunner, std::string const &filepath,
std::string const &outputName) {
Expand Down Expand Up @@ -130,7 +129,7 @@ std::string ElwinModel::getOutputWorkspaceNames() const {
std::vector<std::string> keys = {"qWorkspace", "qSquaredWorkspace", "elfWorkspace", "eltWorkspace"};
std::ostringstream oss;
std::transform(keys.cbegin(), keys.cend(), std::ostream_iterator<std::string>(oss, ","),
[&outNames = m_outputWorkspaceNames](const auto &key) { return outNames.at(key); });
[&](const auto &key) { return m_outputWorkspaceNames.at(key); });
std::string outputWorkspaceNames = oss.str();
outputWorkspaceNames.resize(outputWorkspaceNames.size() - 1);
return outputWorkspaceNames;
Expand Down
7 changes: 3 additions & 4 deletions qt/scientific_interfaces/Inelastic/Manipulation/IqtModel.cpp
Expand Up @@ -20,10 +20,9 @@ using namespace Mantid::API;

namespace MantidQt::CustomInterfaces {

//----------------------------------------------------------------------------------------------
/** Constructor
*/
IqtModel::IqtModel() {}
IqtModel::IqtModel()
: m_sampleWorkspace(), m_resWorkspace(), m_nIterations(), m_energyMin(), m_energyMax(), m_numBins(),
m_calculateErrors(), m_enforceNormalization() {}

void IqtModel::setupTransformToIqt(MantidQt::API::BatchAlgorithmRunner *batchAlgoRunner,
std::string const &outputWorkspace) {
Expand Down
Expand Up @@ -38,10 +38,9 @@ IqtPresenter::IqtPresenter(QWidget *parent, IIqtView *view)
void IqtPresenter::setup() { m_view->setup(); }

void IqtPresenter::handleSampDataReady(const std::string &wsname) {
MatrixWorkspace_sptr workspace;
try {
workspace = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(wsname);
setInputWorkspace(workspace);
auto workspace = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(wsname);
setInputWorkspace(std::move(workspace));
} catch (Mantid::Kernel::Exception::NotFoundError &) {
m_view->showMessageBox("Unable to retrieve workspace: " + wsname);
m_view->setPreviewSpectrumMaximum(0);
Expand Down
Expand Up @@ -20,10 +20,7 @@ using namespace Mantid::API;

namespace MantidQt::CustomInterfaces {

//----------------------------------------------------------------------------------------------
/** Constructor
*/
MomentsModel::MomentsModel() { m_scale = false; }
MomentsModel::MomentsModel() : m_inputWorkspace(), m_outputWorkspaceName(), m_eMin(), m_eMax(), m_scale(false) {}

IAlgorithm_sptr MomentsModel::setupAlgorithm() {
IAlgorithm_sptr momentsAlg = AlgorithmManager::Instance().create("SofQWMoments", -1);
Expand Down
7 changes: 3 additions & 4 deletions qt/scientific_interfaces/Inelastic/Manipulation/SqwModel.cpp
Expand Up @@ -39,10 +39,9 @@ void convertToSpectrumAxis(std::string const &inputName, std::string const &outp

namespace MantidQt::CustomInterfaces {

//----------------------------------------------------------------------------------------------
/** Constructor
*/
SqwModel::SqwModel() { m_rebinInEnergy = false; }
SqwModel::SqwModel()
: m_inputWorkspace(), m_baseName(), m_eFixed(), m_qLow(), m_qWidth(0.05), m_qHigh(), m_eLow(), m_eWidth(0.005),
m_eHigh(), m_rebinInEnergy(false) {}

void SqwModel::setupRebinAlgorithm(MantidQt::API::BatchAlgorithmRunner *batchAlgoRunner) {
if (m_rebinInEnergy) {
Expand Down
4 changes: 2 additions & 2 deletions qt/scientific_interfaces/Inelastic/Manipulation/SqwModel.h
Expand Up @@ -48,10 +48,10 @@ class MANTIDQT_INELASTIC_DLL SqwModel {
std::string m_baseName;
double m_eFixed;
double m_qLow;
double m_qWidth = 0.05;
double m_qWidth;
double m_qHigh;
double m_eLow;
double m_eWidth = 0.005;
double m_eWidth;
double m_eHigh;
bool m_rebinInEnergy;
};
Expand Down
Expand Up @@ -20,13 +20,12 @@ using namespace Mantid::API;

namespace MantidQt::CustomInterfaces {

//----------------------------------------------------------------------------------------------
/** Constructor
*/
SymmetriseModel::SymmetriseModel() {}
SymmetriseModel::SymmetriseModel()
: m_inputWorkspace(), m_reflectedInputWorkspace(), m_negativeOutputWorkspace(), m_positiveOutputWorkspace(),
m_eMin(), m_eMax(), m_isPositiveReflect(), m_spectraRange() {}

void SymmetriseModel::setupPreviewAlgorithm(MantidQt::API::BatchAlgorithmRunner *batchAlgoRunner,
std::vector<long> spectraRange) {
std::vector<long> const &spectraRange) {

if (!m_isPositiveReflect) {
reflectNegativeToPositive();
Expand Down
Expand Up @@ -22,7 +22,8 @@ class MANTIDQT_INELASTIC_DLL SymmetriseModel {
public:
SymmetriseModel();
~SymmetriseModel() = default;
void setupPreviewAlgorithm(MantidQt::API::BatchAlgorithmRunner *batchAlgoRunner, std::vector<long> spectraRange);
void setupPreviewAlgorithm(MantidQt::API::BatchAlgorithmRunner *batchAlgoRunner,
std::vector<long> const &spectraRange);
std::string setupSymmetriseAlgorithm(MantidQt::API::BatchAlgorithmRunner *batchAlgoRunner);
void reflectNegativeToPositive();
void setWorkspaceName(std::string const &workspaceName);
Expand Down
2 changes: 1 addition & 1 deletion qt/widgets/common/src/WorkspaceUtils.cpp
Expand Up @@ -207,7 +207,7 @@ QPair<double, double> getXRangeFromWorkspace(std::string const &workspaceName, d

QPair<double, double> getXRangeFromWorkspace(const Mantid::API::MatrixWorkspace_const_sptr &workspace,
double precision) {
auto const xValues = workspace->x(0);
auto const &xValues = workspace->x(0);
return roundRangeToPrecision(xValues.front(), xValues.back(), precision);
}

Expand Down

0 comments on commit f552f6d

Please sign in to comment.