Skip to content

Commit 48acf14

Browse files
peterfpetersonRichardWaiteSTFCMohamedAlmakiGuiMacielPereirapre-commit-ci[bot]
authored
Build and cppcheck fixes - ornl-next (#39129)
* Cppcheck suppressions set 56 (#38744) * Cppcheck suppressions set 56 * Remove lines from suppressions and other fixes Py_RETURN_NONE renamed to Py_NONE and return removed (now to be done manually) as not used anywhere else and was confusing cppcheck with missing return. Had to make lambda function wrapper if wanted to return const pointer in AlgorithmProperty.cpp Co-authored-by: Mohamed Almaki <MohamedAlmaki@users.noreply.github.com> * Not use macro to return * Replace std::function pointer with a C style function pointer * Update Framework/PythonInterface/mantid/api/src/Exports/IPeakFunction.cpp Co-authored-by: Gui Maciel Pereira <80104863+GuiMacielPereira@users.noreply.github.com> * Update Framework/PythonInterface/mantid/api/src/Exports/IFunction1D.cpp Co-authored-by: Gui Maciel Pereira <80104863+GuiMacielPereira@users.noreply.github.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update Framework/PythonInterface/mantid/api/src/Exports/IFunction1D.cpp Co-authored-by: Gui Maciel Pereira <80104863+GuiMacielPereira@users.noreply.github.com> * Update Framework/PythonInterface/mantid/api/src/Exports/IPeakFunction.cpp Co-authored-by: Gui Maciel Pereira <80104863+GuiMacielPereira@users.noreply.github.com> * Revert constParameterCallback suppression fix --------- Co-authored-by: Mohamed Almaki <MohamedAlmaki@users.noreply.github.com> Co-authored-by: Mohammed Almakki <mohammed.almakki@stfc.ac.uk> Co-authored-by: Gui Maciel Pereira <80104863+GuiMacielPereira@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * fix some of the simpler knownConditionTrueFalse warnings (#39004) * fix some knownConditionTrueFalse warnings * fix cascading ccpcheck warnings * Review suggestions Co-authored-by: James Clarke <james.clarke@stfc.ac.uk> --------- Co-authored-by: James Clarke <james.clarke@stfc.ac.uk> * [pre-commit.ci] pre-commit autoupdate updates: - [github.com/pre-commit/mirrors-clang-format: v19.1.7 → v20.1.0](pre-commit/mirrors-clang-format@v19.1.7...v20.1.0) - [github.com/astral-sh/ruff-pre-commit: v0.9.10 → v0.11.2](astral-sh/ruff-pre-commit@v0.9.10...v0.11.2) remove unnecessary brackets Update cppcheck suppression line number * Pin conda=25.1.1 to avoid CMake FindPython error in Windows packaging (#39119) * A variety of Cppcheck fixes (#39115) * Delete unnecessary virtual destructors. * Fixes for ImportMDHistoWorkspaceBase The member variable nbins is unused, and was shadowed inside a method. Also made some variables in that method const. * AlgorithmDialog missing const in a few places * Fix some return by reference in FitPropertyBrowser * Fix several passedByValue Cppcheck warnings * Further Cppcheck fixes * Some stl related cppcheck fixes (#39072) * some stl related cppchecks * additional ccpcheck fixes from line numbers moving * remove fix that I think is causing the test failure * use std optional to avoid uninitialised warning * Pin pydantic to fix failing test --------- Co-authored-by: RichardWaiteSTFC <55979119+RichardWaiteSTFC@users.noreply.github.com> Co-authored-by: Mohamed Almaki <MohamedAlmaki@users.noreply.github.com> Co-authored-by: Mohammed Almakki <mohammed.almakki@stfc.ac.uk> Co-authored-by: Gui Maciel Pereira <80104863+GuiMacielPereira@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Jonathan Haigh <35813666+jhaigh0@users.noreply.github.com> Co-authored-by: James Clarke <james.clarke@stfc.ac.uk> Co-authored-by: thomashampson <thomas.hampson@stfc.ac.uk> Co-authored-by: James Clarke <139879523+jclarkeSTFC@users.noreply.github.com> Co-authored-by: sf1919 <sarah.foxley@stfc.ac.uk>
1 parent 13a696d commit 48acf14

File tree

93 files changed

+335
-461
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+335
-461
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ repos:
2424
exclude: .md5$|^external/|^tools/|Testing/Tools/cxxtest
2525

2626
- repo: https://github.com/pre-commit/mirrors-clang-format
27-
rev: v19.1.7
27+
rev: v20.1.0
2828
hooks:
2929
- id: clang-format
3030
exclude: Testing/Tools/cxxtest|tools|qt/icons/resources/
@@ -59,7 +59,7 @@ repos:
5959
)$
6060
6161
- repo: https://github.com/astral-sh/ruff-pre-commit
62-
rev: v0.9.10
62+
rev: v0.11.2
6363
# ruff must appear before black in the list of hooks
6464
hooks:
6565
- id: ruff

Framework/API/src/FileFinder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ const Kernel::InstrumentInfo FileFinderImpl::getInstrument(const string &hint,
145145
string instrName(hint);
146146
Poco::Path path(instrName);
147147
instrName = path.getFileName();
148-
if ((instrName.find("PG3") == 0) || (instrName.find("pg3") == 0)) {
148+
if (instrName.starts_with("PG3") || instrName.starts_with("pg3")) {
149149
instrName = "PG3";
150150
}
151151
// We're extending this nasty hack to accomodate data archive searching for
@@ -157,7 +157,7 @@ const Kernel::InstrumentInfo FileFinderImpl::getInstrument(const string &hint,
157157
// code gets an overhaul as part of that ticket. Please think twice before
158158
// adding
159159
// any more instruments to this list.
160-
else if ((instrName.find("SANS2D") == 0) || (instrName.find("sans2d") == 0)) {
160+
else if (instrName.starts_with("SANS2D") || instrName.starts_with("sans2d")) {
161161
instrName = "SANS2D";
162162
} else {
163163
// go forwards looking for the run number to start

Framework/API/src/FunctionFactory.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,7 @@ FunctionFactoryImpl::createComposite(const Expression &expr,
264264
}
265265
}
266266

267-
if (cfun) {
268-
cfun->applyTies();
269-
}
267+
cfun->applyTies();
270268
return cfun;
271269
}
272270

Framework/Algorithms/inc/MantidAlgorithms/ExtractMaskToTable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class MANTID_ALGORITHMS_DLL ExtractMaskToTable final : public API::Algorithm {
3535
const std::string category() const override { return "Transforms\\Masking"; }
3636

3737
/// Remove the items appeared in a vector from another
38-
std::vector<detid_t> subtractVector(std::vector<detid_t> minuend, std::vector<detid_t> subtrahend);
38+
std::vector<detid_t> subtractVector(const std::vector<detid_t> &minuend, std::vector<detid_t> subtrahend);
3939

4040
private:
4141
/// Initialisation code

Framework/Algorithms/inc/MantidAlgorithms/GeneratePeaks.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class MANTID_ALGORITHMS_DLL GeneratePeaks final : public API::Algorithm {
6868
/// Create output workspace
6969
API::MatrixWorkspace_sptr createOutputWorkspace();
7070

71-
API::MatrixWorkspace_sptr createDataWorkspace(std::vector<double> binparameters);
71+
API::MatrixWorkspace_sptr createDataWorkspace(const std::vector<double> &binparameters) const;
7272

7373
void createFunction(std::string &peaktype, std::string &bkgdtype);
7474

Framework/Algorithms/inc/MantidAlgorithms/GetAllEi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class MANTID_ALGORITHMS_DLL GetAllEi : public API::Algorithm {
6565

6666
/**Return average time series log value for the appropriately filtered log*/
6767
double getAvrgLogValue(const API::MatrixWorkspace_sptr &inputWS, const std::string &propertyName,
68-
Kernel::TimeROI &timeroi);
68+
const Kernel::TimeROI &timeroi);
6969
/**process logs and retrieve chopper speed and chopper delay*/
7070
void findChopSpeedAndDelay(const API::MatrixWorkspace_sptr &inputWS, double &chop_speed, double &chop_delay);
7171
void findGuessOpeningTimes(const std::pair<double, double> &TOF_range, double ChopDelay, double Period,

Framework/Algorithms/inc/MantidAlgorithms/SampleCorrections/SparseWorkspace.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class MANTID_ALGORITHMS_DLL SparseWorkspace : public DataObjects::Workspace2D {
4949
static HistogramData::Histogram modelHistogram(const API::MatrixWorkspace &modelWS, const size_t wavelengthPoints);
5050
static std::tuple<double, double> extremeWavelengths(const API::MatrixWorkspace &ws);
5151
static std::tuple<double, double, double, double> extremeAngles(const API::MatrixWorkspace &ws);
52-
HistogramData::HistogramY secondDerivative(const std::array<size_t, 3> indices, const double distanceStep) const;
52+
HistogramData::HistogramY secondDerivative(const std::array<size_t, 3> &indices, const double distanceStep) const;
5353
HistogramData::HistogramE esq(const HistogramData::HistogramE &e) const;
5454
HistogramData::HistogramE esqrt(HistogramData::HistogramE e) const;
5555

Framework/Algorithms/src/DiffractionFocussing2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ std::map<std::string, std::string> DiffractionFocussing2::validateInputs() {
9494
if (unitid == "TOF") {
9595
g_log.error(
9696
"Support for TOF data in DiffractionFocussing is deprecated (on 29/04/21) - use GroupDetectors instead)");
97-
} else if (unitid != "dSpacing" && unitid != "MomentumTransfer" && unitid != "TOF") {
97+
} else if (unitid != "dSpacing" && unitid != "MomentumTransfer") {
9898
std::stringstream msg;
9999
msg << "UnitID " << unitid << " is not a supported spacing";
100100
issues["InputWorkspace"] = msg.str();

Framework/Algorithms/src/ExtractMaskToTable.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,8 @@ void ExtractMaskToTable::addToTableWorkspace(const TableWorkspace_sptr &outws, s
360360
* @param minuend :: vector with items to be removed from
361361
* @param subtrahend :: vector containing the items to be removed from minuend
362362
*/
363-
std::vector<detid_t> ExtractMaskToTable::subtractVector(std::vector<detid_t> minuend, std::vector<detid_t> subtrahend) {
363+
std::vector<detid_t> ExtractMaskToTable::subtractVector(const std::vector<detid_t> &minuend,
364+
std::vector<detid_t> subtrahend) {
364365
// Define some variables
365366
std::vector<detid_t>::iterator firstsubiter, fiter;
366367
firstsubiter = subtrahend.begin();

Framework/Algorithms/src/FilterEvents.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,8 +617,7 @@ void FilterEvents::createOutputWorkspaces() {
617617
int delta_wsindex{0}; // an index shift
618618
if (getProperty("OutputWorkspaceIndexedFrom1")) {
619619
// Determine the minimum valid target index. Note that the set is sorted and guaranteed to start with -1.
620-
const int min_wsindex = m_targetWorkspaceIndexSet.size() == 1 ? *m_targetWorkspaceIndexSet.begin()
621-
: *std::next(m_targetWorkspaceIndexSet.begin(), 1);
620+
const int min_wsindex = *std::next(m_targetWorkspaceIndexSet.begin(), 1);
622621
g_log.debug() << "Minimum target workspace index = " << min_wsindex << "\n";
623622
delta_wsindex = 1 - min_wsindex;
624623
}

0 commit comments

Comments
 (0)