diff --git a/Framework/API/src/ExperimentInfo.cpp b/Framework/API/src/ExperimentInfo.cpp index d61acf54a956e357c91196f11c6a0ef18c87d54c..938ba5dd0eb1b52bae9620c9a0b33996c08b831d 100644 --- a/Framework/API/src/ExperimentInfo.cpp +++ b/Framework/API/src/ExperimentInfo.cpp @@ -683,7 +683,7 @@ class DummyException { public: std::string m_validFrom; std::string m_validTo; - DummyException(std::string validFrom, std::string validTo) + DummyException(const std::string &validFrom, const std::string &validTo) : m_validFrom(validFrom), m_validTo(validTo) {} }; diff --git a/Framework/Algorithms/src/CalculateCountRate.cpp b/Framework/Algorithms/src/CalculateCountRate.cpp index 22629dde6cad6c4f46cf26058e90686c3efd8dc1..2f95a7a4bf5a83aeb14b184bf0e5c8eac3a74032 100644 --- a/Framework/Algorithms/src/CalculateCountRate.cpp +++ b/Framework/Algorithms/src/CalculateCountRate.cpp @@ -212,14 +212,13 @@ void CalculateCountRate::calcRateLog( double dTRangeMin = static_cast<double>(m_TRangeMin.totalNanoseconds()); double dTRangeMax = static_cast<double>(m_TRangeMax.totalNanoseconds()); std::vector<MantidVec> Buff; - int nThreads; #pragma omp parallel { + int nThreads = PARALLEL_NUMBER_OF_THREADS; #pragma omp single { // initialize thread's histogram buffer - nThreads = PARALLEL_NUMBER_OF_THREADS; Buff.resize(nThreads); } auto nThread = PARALLEL_THREAD_NUMBER; diff --git a/Framework/Crystal/src/OptimizeCrystalPlacement.cpp b/Framework/Crystal/src/OptimizeCrystalPlacement.cpp index c05e0e9aa40b03fc782a13af608af39fd1841583..e7f720798cf62d2f2b8ff271075d4a4b3523a0d9 100644 --- a/Framework/Crystal/src/OptimizeCrystalPlacement.cpp +++ b/Framework/Crystal/src/OptimizeCrystalPlacement.cpp @@ -36,9 +36,12 @@ DECLARE_ALGORITHM(OptimizeCrystalPlacement) class OrEnabledWhenProperties : public Kernel::IPropertySettings { public: - OrEnabledWhenProperties(std::string prop1Name, ePropertyCriterion prop1Crit, - std::string prop1Value, std::string prop2Name, - ePropertyCriterion prop2Crit, std::string prop2Value) + OrEnabledWhenProperties(const std::string &prop1Name, + ePropertyCriterion prop1Crit, + const std::string &prop1Value, + const std::string &prop2Name, + ePropertyCriterion prop2Crit, + const std::string &prop2Value) : IPropertySettings(), propName1(prop1Name), propName2(prop2Name), Criteria1(prop1Crit), Criteria2(prop2Crit), value1(prop1Value), value2(prop2Value) diff --git a/Framework/DataHandling/src/LoadBBY.cpp b/Framework/DataHandling/src/LoadBBY.cpp index e93e9e638aedaaf27385c6973c29a1ed32838b0e..b109d4d6ba4a8a61ff3d597a7462df6c6a61c352 100644 --- a/Framework/DataHandling/src/LoadBBY.cpp +++ b/Framework/DataHandling/src/LoadBBY.cpp @@ -689,12 +689,13 @@ void LoadBBY::loadEvents(API::Progress &prog, const char *progMsg, case 5: case 6: case 7: - case 8: event_ended = (c & 0xC0) != 0xC0; if (!event_ended) c &= 0x3F; - - dt |= (c & 0xFF) << (5 + 6 * (state - 3)); // set bit 6... + // avoid shifting by > 32 bits + // identical to dt |= 0 + if (state != 8) + dt |= (c & 0xFF) << (5 + 6 * (state - 3)); // set bit 6... break; } state++; diff --git a/Framework/DataHandling/src/StartAndEndTimeFromNexusFileExtractor.cpp b/Framework/DataHandling/src/StartAndEndTimeFromNexusFileExtractor.cpp index 362af848dd8207628d1398528f31bc7df93710e3..289abc173e6d25af61d66a789d6fdaa3936a8f5c 100644 --- a/Framework/DataHandling/src/StartAndEndTimeFromNexusFileExtractor.cpp +++ b/Framework/DataHandling/src/StartAndEndTimeFromNexusFileExtractor.cpp @@ -139,7 +139,7 @@ Mantid::Kernel::DateAndTime extractDateAndTime(TimeType type, * @return the start time * @throws if the the start time cannot be extracted */ -Mantid::Kernel::DateAndTime extractStartTime(std::string filename) { +Mantid::Kernel::DateAndTime extractStartTime(const std::string &filename) { return extractDateAndTime(TimeType::StartTime, filename); } @@ -149,7 +149,7 @@ Mantid::Kernel::DateAndTime extractStartTime(std::string filename) { * @return the start time * @throws if the the start time cannot be extracted */ -Mantid::Kernel::DateAndTime extractEndTime(std::string filename) { +Mantid::Kernel::DateAndTime extractEndTime(const std::string &filename) { return extractDateAndTime(TimeType::EndTime, filename); } diff --git a/Framework/DataObjects/src/ReflectometryTransform.cpp b/Framework/DataObjects/src/ReflectometryTransform.cpp index c87dad39f973f2d6c7705290c87c7061cc5a0699..b328094282f0cc81d7d26c4adcf510d76f4e6333 100644 --- a/Framework/DataObjects/src/ReflectometryTransform.cpp +++ b/Framework/DataObjects/src/ReflectometryTransform.cpp @@ -48,33 +48,32 @@ void writeRow(boost::shared_ptr<Mantid::DataObjects::TableWorkspace> &vertexes, * Adds the column headings to a table * @param vertexes : Table to which the columns are written to. */ -void addColumnHeadings( - boost::shared_ptr<Mantid::DataObjects::TableWorkspace> &vertexes, - std::string outputDimensions) { +void addColumnHeadings(Mantid::DataObjects::TableWorkspace &vertexes, + const std::string &outputDimensions) { if (outputDimensions == "Q (lab frame)") { - vertexes->addColumn("double", "Qx"); - vertexes->addColumn("double", "Qy"); - vertexes->addColumn("int", "OriginIndex"); - vertexes->addColumn("int", "OriginBin"); - vertexes->addColumn("double", "CellSignal"); - vertexes->addColumn("double", "CellError"); + vertexes.addColumn("double", "Qx"); + vertexes.addColumn("double", "Qy"); + vertexes.addColumn("int", "OriginIndex"); + vertexes.addColumn("int", "OriginBin"); + vertexes.addColumn("double", "CellSignal"); + vertexes.addColumn("double", "CellError"); } if (outputDimensions == "P (lab frame)") { - vertexes->addColumn("double", "Pi+Pf"); - vertexes->addColumn("double", "Pi-Pf"); - vertexes->addColumn("int", "OriginIndex"); - vertexes->addColumn("int", "OriginBin"); - vertexes->addColumn("double", "CellSignal"); - vertexes->addColumn("double", "CellError"); + vertexes.addColumn("double", "Pi+Pf"); + vertexes.addColumn("double", "Pi-Pf"); + vertexes.addColumn("int", "OriginIndex"); + vertexes.addColumn("int", "OriginBin"); + vertexes.addColumn("double", "CellSignal"); + vertexes.addColumn("double", "CellError"); } if (outputDimensions == "K (incident, final)") { - vertexes->addColumn("double", "Ki"); - vertexes->addColumn("double", "Kf"); - vertexes->addColumn("int", "OriginIndex"); - vertexes->addColumn("int", "OriginBin"); - vertexes->addColumn("double", "CellSignal"); - vertexes->addColumn("double", "CellError"); + vertexes.addColumn("double", "Ki"); + vertexes.addColumn("double", "Kf"); + vertexes.addColumn("int", "OriginIndex"); + vertexes.addColumn("int", "OriginBin"); + vertexes.addColumn("double", "CellSignal"); + vertexes.addColumn("double", "CellError"); } } } @@ -464,7 +463,7 @@ MatrixWorkspace_sptr ReflectometryTransform::executeNormPoly( std::vector<specnum_t> specNumberMapping; std::vector<detid_t> detIDMapping; // Create a table for the output if we want to debug vertex positioning - addColumnHeadings(vertexes, outputDimensions); + addColumnHeadings(*vertexes, outputDimensions); for (size_t i = 0; i < nHistos; ++i) { IDetector_const_sptr detector = inputWS->getDetector(i); if (!detector || detector->isMasked() || detector->isMonitor()) { diff --git a/Framework/Geometry/src/Surfaces/SurfaceFactory.cpp b/Framework/Geometry/src/Surfaces/SurfaceFactory.cpp index 6de9aa18a83801d23963dc03999630ba5b75c74e..1e3e177614f24c7299902d7bcfc4faf4c55bb50c 100644 --- a/Framework/Geometry/src/Surfaces/SurfaceFactory.cpp +++ b/Framework/Geometry/src/Surfaces/SurfaceFactory.cpp @@ -88,7 +88,7 @@ void SurfaceFactory::registerSurface() namespace { class KeyEquals { public: - explicit KeyEquals(std::string key) : m_key(std::move(key)) {} + explicit KeyEquals(const std::string &key) : m_key(key) {} bool operator()(const std::pair<std::string, std::unique_ptr<Surface>> &element) { return m_key == element.first; diff --git a/Framework/Kernel/src/MaterialXMLParser.cpp b/Framework/Kernel/src/MaterialXMLParser.cpp index c9c91ae43e099f1ad168fd1eb4f63b4438cf15f8..1e110f55d4e2f82abe2fd90c8dbffb495f2e697e 100644 --- a/Framework/Kernel/src/MaterialXMLParser.cpp +++ b/Framework/Kernel/src/MaterialXMLParser.cpp @@ -68,7 +68,8 @@ struct TypedBuilderHandle final : public BuilderHandle { typedef typename std::remove_const< typename std::remove_reference<ArgType>::type>::type ValueType; - TypedBuilderHandle(BuilderMethod<ArgType> m) : BuilderHandle(), m_method(m) {} + explicit TypedBuilderHandle(BuilderMethod<ArgType> m) + : BuilderHandle(), m_method(m) {} void operator()(MaterialBuilder &builder, const std::string &value) const override { diff --git a/Framework/Kernel/src/Strings.cpp b/Framework/Kernel/src/Strings.cpp index aa0550b5f251ea1175ac3d1a4226c6502d88f6fd..94977a619b58830b36ac6c81eab493de5e900873 100644 --- a/Framework/Kernel/src/Strings.cpp +++ b/Framework/Kernel/src/Strings.cpp @@ -411,7 +411,7 @@ void writeMCNPX(const std::string &Line, std::ostream &OX) { * @param Ln :: line component to strip * @return vector of components */ -std::vector<std::string> StrParts(std::string Ln) { +std::vector<std::string> StrParts(const std::string &Ln) { std::vector<std::string> Out; std::string Part; while (section(Ln, Part)) diff --git a/Framework/MatlabAPI/src/MatlabInterface.cpp b/Framework/MatlabAPI/src/MatlabInterface.cpp index 071d2ebc81b76ce32727e9eba389ad75afcc3ee6..d171b839024f890752974b9b243821aa42f61fce 100644 --- a/Framework/MatlabAPI/src/MatlabInterface.cpp +++ b/Framework/MatlabAPI/src/MatlabInterface.cpp @@ -302,8 +302,8 @@ mxArray *ixbcreateclassarray(const char *class_name, int *n) { */ int CreateFrameworkManager(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { - mwSize dims[2] = {1, 1}; try { + mwSize dims[2] = {1, 1}; FrameworkManagerImpl &fmgr = FrameworkManager::Instance(); plhs[0] = mxCreateNumericArray(2, dims, mxUINT64_CLASS, mxREAL); uint64_t *data = (uint64_t *)mxGetData(plhs[0]); diff --git a/Framework/TestHelpers/src/MDEventsTestHelper.cpp b/Framework/TestHelpers/src/MDEventsTestHelper.cpp index dad353bac4237afef6b886d9ed79f06b5c639980..63d708ccfbe2652f6933c4f5d8607e0d3ac0b25a 100644 --- a/Framework/TestHelpers/src/MDEventsTestHelper.cpp +++ b/Framework/TestHelpers/src/MDEventsTestHelper.cpp @@ -216,8 +216,8 @@ std::vector<MDLeanEvent<1>> makeMDEvents1(size_t num) { */ Mantid::DataObjects::MDHistoWorkspace_sptr makeFakeMDHistoWorkspace(double signal, size_t numDims, size_t numBins, - coord_t max, double errorSquared, std::string name, - double numEvents) { + coord_t max, double errorSquared, + const std::string &name, double numEvents) { // Create MDFrame of General Frame type Mantid::Geometry::GeneralFrame frame( Mantid::Geometry::GeneralFrame::GeneralFrameDistance, "m"); diff --git a/MantidPlot/src/QwtBarCurve.cpp b/MantidPlot/src/QwtBarCurve.cpp index 54c05370ba2351cc8a9ff4822e08c9c7142ccf39..ac81504050bf81c9a989707ce4f08e8d08492558 100644 --- a/MantidPlot/src/QwtBarCurve.cpp +++ b/MantidPlot/src/QwtBarCurve.cpp @@ -32,10 +32,8 @@ QwtBarCurve::QwtBarCurve(BarStyle style, Table *t, const QString &xColName, const QString &name, int startRow, int endRow) - : DataCurve(t, xColName, name, startRow, endRow) { - bar_offset = 0; - bar_gap = 0; - bar_style = style; + : DataCurve(t, xColName, name, startRow, endRow), bar_gap{0}, bar_offset{0}, + bar_style{style} { setPen(QPen(Qt::black, 1, Qt::SolidLine)); setBrush(QBrush(Qt::red)); diff --git a/MantidPlot/src/Spectrogram.cpp b/MantidPlot/src/Spectrogram.cpp index 8d092ad7a419c2d06c103bcf90947bddc69ca0a5..1e543976b0c0415d6ddb354492322105e526c855 100644 --- a/MantidPlot/src/Spectrogram.cpp +++ b/MantidPlot/src/Spectrogram.cpp @@ -1022,6 +1022,7 @@ void Spectrogram::loadFromProject(const std::string &lines) { std::string policyStr = tsv.sections("ColorPolicy").front(); int policy = 0; Strings::convert<int>(policyStr, policy); + // cppcheck-suppress knownConditionTrueFalse if (policy == GrayScale) setGrayScale(); else if (policy == Default) diff --git a/MantidQt/API/src/ScriptRepositoryView.cpp b/MantidQt/API/src/ScriptRepositoryView.cpp index 6226c6d237287b88a4a85c11a6df7256dc7646ab..c01d40274e588bf494ce5f64a2f8bfdadf6dd707 100644 --- a/MantidQt/API/src/ScriptRepositoryView.cpp +++ b/MantidQt/API/src/ScriptRepositoryView.cpp @@ -154,7 +154,7 @@ ScriptRepositoryView::ScriptRepositoryView(QWidget *parent) // create the model model = new RepoModel(this); - } catch (EXC_OPTIONS ex) { + } catch (EXC_OPTIONS &ex) { if (ex == NODIRECTORY) // probably the user change mind. He does not want to install any more. QMessageBox::warning(this, "Installation Failed", diff --git a/Vates/VatesAPI/src/PresenterUtilities.cpp b/Vates/VatesAPI/src/PresenterUtilities.cpp index f6f32fa88836b8d472c81ed44d890ef7ba9a8449..4062c83c4047098bc51f02b3e0b7170d97e8fe3f 100644 --- a/Vates/VatesAPI/src/PresenterUtilities.cpp +++ b/Vates/VatesAPI/src/PresenterUtilities.cpp @@ -125,7 +125,7 @@ createFactoryChainForHistoWorkspace(ThresholdRange_scptr threshold, * @param name: the input name * @return a name with a time stamp */ -std::string createTimeStampedName(std::string name) { +std::string createTimeStampedName(const std::string &name) { auto currentTime = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); std::string timeInReadableFormat = std::string(std::ctime(¤tTime)); diff --git a/Vates/VatesSimpleGui/ViewWidgets/src/RebinnedSourcesManager.cpp b/Vates/VatesSimpleGui/ViewWidgets/src/RebinnedSourcesManager.cpp index 4296350968370a7f9bc7f6111f85109f08c894e4..087483d000e55f74c841a8e6eb8fede2aac7e534 100644 --- a/Vates/VatesSimpleGui/ViewWidgets/src/RebinnedSourcesManager.cpp +++ b/Vates/VatesSimpleGui/ViewWidgets/src/RebinnedSourcesManager.cpp @@ -711,8 +711,7 @@ std::string RebinnedSourcesManager::saveToProject() { void RebinnedSourcesManager::loadFromProject(const std::string &lines) { MantidQt::API::TSVSerialiser tsv(lines); - std::string rebinWorkspaceName, originalWorkspaceName, rebinProxyName, - originalProxyName; + std::string rebinWorkspaceName, originalWorkspaceName, rebinProxyName; tsv.selectLine("RebinnedWorkspaceName"); tsv >> rebinWorkspaceName; tsv.selectLine("OriginalWorkspaceName");