Skip to content

Commit 0a76c8b

Browse files
committed
Fix cppcheck warnings in loading code
1 parent d422525 commit 0a76c8b

File tree

12 files changed

+31
-44
lines changed

12 files changed

+31
-44
lines changed

Framework/DataHandling/inc/MantidDataHandling/LoadISISNexus2.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ class MANTID_DATAHANDLING_DLL LoadISISNexus2 : public API::IFileLoader<Kernel::N
116116
void validateMultiPeriodLogs(const Mantid::API::MatrixWorkspace_sptr &);
117117

118118
// build the list of spectra numbers to load and include in the spectra list
119-
void buildSpectraInd2SpectraNumMap(bool range_supplied, bool hasSpectraList, DataBlockComposite &dataBlockComposite);
119+
void buildSpectraInd2SpectraNumMap(bool range_supplied, bool hasSpectraList,
120+
const DataBlockComposite &dataBlockComposite);
120121

121122
/// Check if any of the spectra block ranges overlap
122123
void checkOverlappingSpectraRange();
@@ -171,8 +172,8 @@ class MANTID_DATAHANDLING_DLL LoadISISNexus2 : public API::IFileLoader<Kernel::N
171172
boost::scoped_ptr< ::NeXus::File> m_nexusFile;
172173
// clang-format on
173174

174-
bool findSpectraDetRangeInFile(NeXus::NXEntry &entry, std::vector<specnum_t> &spectrum_index, int64_t ndets,
175-
int64_t n_vms_compat_spectra, std::map<specnum_t, std::string> &monitors,
175+
bool findSpectraDetRangeInFile(const NeXus::NXEntry &entry, std::vector<specnum_t> &spectrum_index, int64_t ndets,
176+
int64_t n_vms_compat_spectra, const std::map<specnum_t, std::string> &monitors,
176177
bool excludeMonitors, bool separateMonitors);
177178

178179
/// Check if is the file is a multiple time regime file

Framework/DataHandling/inc/MantidDataHandling/LoadMLZ.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ class MANTID_DATAHANDLING_DLL LoadMLZ : public API::IFileLoader<Kernel::NexusDes
4242

4343
std::vector<std::vector<int>> getMonitorInfo(NeXus::NXEntry &firstEntry);
4444

45-
void initWorkSpace(NeXus::NXEntry &entry);
45+
void initWorkspace(const NeXus::NXEntry &entry);
4646
void initInstrumentSpecific();
4747
void loadRunDetails(NeXus::NXEntry &entry);
4848
void loadExperimentDetails(const NeXus::NXEntry &entry);
4949

5050
NeXus::NXData loadNexusFileData(NeXus::NXEntry &entry);
5151
void maskDetectors(const NeXus::NXEntry &entry);
52-
void loadDataIntoTheWorkSpace(NeXus::NXEntry &entry); //, int ElasticPeakPosition = -1);
52+
void loadDataIntoTheWorkSpace(const NeXus::NXEntry &entry); //, int ElasticPeakPosition = -1);
5353

5454
void runLoadInstrument();
5555

Framework/DataHandling/inc/MantidDataHandling/LoadSINQFocus.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class MANTID_DATAHANDLING_DLL LoadSINQFocus : public API::IFileLoader<Kernel::Ne
4646
void init() override;
4747
void exec() override;
4848
void setInstrumentName(const NeXus::NXEntry &entry);
49-
void initWorkSpace(NeXus::NXEntry &);
49+
void initWorkSpace(const NeXus::NXEntry &);
5050
void loadDataIntoTheWorkSpace(NeXus::NXEntry &);
5151
/// Calculate error for y
5252
static double calculateError(double in) { return sqrt(in); }

Framework/DataHandling/src/LoadISISNexus2.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ below have to be processed rather then spectra list
605605
intervals
606606
**/
607607
void LoadISISNexus2::buildSpectraInd2SpectraNumMap(bool range_supplied, bool hasSpectraList,
608-
DataBlockComposite &dataBlockComposite) {
608+
const DataBlockComposite &dataBlockComposite) {
609609

610610
if (range_supplied || hasSpectraList || true) {
611611
auto generator = dataBlockComposite.getGenerator();
@@ -944,9 +944,10 @@ double LoadISISNexus2::dblSqrt(double in) { return sqrt(in); }
944944
* (contain different number of time channels)
945945
*
946946
*/
947-
bool LoadISISNexus2::findSpectraDetRangeInFile(NXEntry &entry, std::vector<specnum_t> &spectrum_index, int64_t ndets,
948-
int64_t n_vms_compat_spectra, std::map<specnum_t, std::string> &monitors,
949-
bool excludeMonitors, bool separateMonitors) {
947+
bool LoadISISNexus2::findSpectraDetRangeInFile(const NXEntry &entry, std::vector<specnum_t> &spectrum_index,
948+
int64_t ndets, int64_t n_vms_compat_spectra,
949+
const std::map<specnum_t, std::string> &monitors, bool excludeMonitors,
950+
bool separateMonitors) {
950951
size_t nmons = monitors.size();
951952

952953
if (nmons > 0) {

Framework/DataHandling/src/LoadMLZ.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void LoadMLZ::exec() {
7878
loadInstrumentDetails(dataFirstEntry);
7979
loadTimeDetails(dataFirstEntry);
8080

81-
initWorkSpace(dataFirstEntry);
81+
initWorkspace(dataFirstEntry);
8282

8383
// load the instrument from the IDF
8484
runLoadInstrument();
@@ -170,7 +170,7 @@ void LoadMLZ::loadInstrumentDetails(const NeXus::NXEntry &firstEntry) {
170170
* @param entry :: The Nexus entry
171171
*
172172
*/
173-
void LoadMLZ::initWorkSpace(NeXus::NXEntry &entry) //, const std::vector<std::vector<int> >&monitors)
173+
void LoadMLZ::initWorkspace(const NeXus::NXEntry &entry) //, const std::vector<std::vector<int> >&monitors)
174174
{
175175
// read in the data
176176
NXData dataGroup = entry.openNXData("data");
@@ -353,7 +353,7 @@ void LoadMLZ::loadExperimentDetails(const NXEntry &entry) {
353353
*
354354
* @param entry :: The Nexus entry
355355
*/
356-
void LoadMLZ::loadDataIntoTheWorkSpace(NeXus::NXEntry &entry) {
356+
void LoadMLZ::loadDataIntoTheWorkSpace(const NeXus::NXEntry &entry) {
357357
// read in the data
358358
NXData dataGroup = entry.openNXData("data");
359359
NXInt data = dataGroup.openIntData();

Framework/DataHandling/src/LoadMuonNexus2.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ void LoadMuonNexus2::doExec() {
148148

149149
std::string detectorName;
150150
// Only the first NXdata found
151-
for (auto &group : entry.groups()) {
151+
for (const auto &group : entry.groups()) {
152152
std::string className = group.nxclass;
153153
if (className == "NXdata") {
154154
detectorName = group.nxname;
@@ -486,7 +486,7 @@ std::map<int, std::set<int>> LoadMuonNexus2::loadDetectorMapping(const Mantid::N
486486
NXEntry entry = root.openEntry(m_entry_name);
487487
const std::string detectorName = [&entry]() {
488488
// Only the first NXdata found
489-
for (auto &group : entry.groups()) {
489+
for (const auto &group : entry.groups()) {
490490
std::string className = group.nxclass;
491491
if (className == "NXdata") {
492492
return group.nxname;

Framework/DataHandling/src/LoadSINQFocus.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ void LoadSINQFocus::setInstrumentName(const NeXus::NXEntry &entry) {
122122
m_instrumentName = m_instrumentName.substr(0, pos);
123123
}
124124

125-
void LoadSINQFocus::initWorkSpace(NeXus::NXEntry &entry) {
125+
void LoadSINQFocus::initWorkSpace(const NeXus::NXEntry &entry) {
126126

127127
// read in the data
128128
NXData dataGroup = entry.openNXData("merged");

Framework/DataHandling/src/SaveNXcanSAS.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ std::string getDate() {
316316
void addPropertyFromRunIfExists(Run const &run, std::string const &propertyName, H5::Group &sasGroup,
317317
std::string const &sasTerm) {
318318
if (run.hasProperty(propertyName)) {
319-
auto property = run.getProperty(propertyName);
319+
const auto property = run.getProperty(propertyName);
320320
Mantid::NeXus::H5Util::write(sasGroup, sasTerm, property->value());
321321
}
322322
}
@@ -408,7 +408,7 @@ WorkspaceDimensionality getWorkspaceDimensionality(const Mantid::API::MatrixWork
408408

409409
//------- SASdata
410410

411-
std::string getIntensityUnitLabel(std::string intensityUnitLabel) {
411+
std::string getIntensityUnitLabel(const std::string &intensityUnitLabel) {
412412
if (intensityUnitLabel == "I(q) (cm-1)") {
413413
return sasIntensity;
414414
} else {
@@ -424,7 +424,7 @@ std::string getIntensityUnit(const Mantid::API::MatrixWorkspace_sptr &workspace)
424424
return iUnit;
425425
}
426426

427-
std::string getMomentumTransferLabel(std::string momentumTransferLabel) {
427+
std::string getMomentumTransferLabel(const std::string &momentumTransferLabel) {
428428
if (momentumTransferLabel == "Angstrom^-1") {
429429
return sasMomentumTransfer;
430430
} else {

Framework/Nexus/inc/MantidNexus/MuonNexusReader.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class MANTID_NEXUS_DLL MuonNexusReader {
7474
void getTimeChannels(float *timebnds,
7575
const int &nbnds) const; ///< get time bin boundaries
7676
/// return sample name
77-
std::string getSampleName() const { return m_nexusSampleName; };
77+
std::string const &getSampleName() const { return m_nexusSampleName; };
7878
int numberOfLogs() const; ///< Number of NXlog sections read from file
7979
int getLogLength(const int i) const; ///< Lenght of i'th log
8080
std::string getLogName(const int i) const; ///< Name of i'th log
@@ -89,11 +89,11 @@ class MANTID_NEXUS_DLL MuonNexusReader {
8989
int t_ntc1 = 0; ///< number of time channels in time regime 1
9090
int t_nper = 0; ///< number of periods in file (=1 at present)
9191
// for nexus histogram data
92-
std::vector<float> m_correctedTimes; ///< temp store for corrected times
93-
std::vector<int> m_counts; ///< temp store of histogram data
94-
std::vector<int> m_detectorGroupings; ///< detector grouping info
95-
int m_numDetectors = 0; ///< detector count
96-
std::string getInstrumentName() const; ///< return instrument name
92+
std::vector<float> m_correctedTimes; ///< temp store for corrected times
93+
std::vector<int> m_counts; ///< temp store of histogram data
94+
std::vector<int> m_detectorGroupings; ///< detector grouping info
95+
int m_numDetectors = 0; ///< detector count
96+
std::string const &getInstrumentName() const; ///< return instrument name
9797
int m_numPeriodSequences = 0;
9898
std::string m_periodNames;
9999
std::string m_periodTypes;

Framework/Nexus/inc/MantidNexus/NexusClasses.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class MANTID_NEXUS_DLL NXObject {
9696
// definition.
9797
// virtual bool isStandard()const = 0;
9898
/// Returns the absolute path to the object
99-
std::string path() const { return m_path; }
99+
std::string const &path() const { return m_path; }
100100
/// Returns the name of the object
101101
std::string name() const;
102102
/// Attributes

0 commit comments

Comments
 (0)