Skip to content

Commit

Permalink
Merge pull request #38584 from peterfpeterson/38332_nexus_sorted_incl…
Browse files Browse the repository at this point in the history
…udes

Remove clang-format suppressions
  • Loading branch information
AndreiSavici authored Jan 10, 2025
2 parents f579a71 + 9c6d1b1 commit a411fec
Show file tree
Hide file tree
Showing 43 changed files with 116 additions and 255 deletions.
7 changes: 2 additions & 5 deletions Framework/API/src/FileBackedExperimentInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@
// SPDX - License - Identifier: GPL - 3.0 +
#include "MantidAPI/FileBackedExperimentInfo.h"
#include "MantidKernel/Logger.h"
#include "MantidNexusCpp/NeXusException.hpp"
#include "MantidNexusCpp/NeXusFile.hpp"

#include <sstream>
#include <utility>

// clang-format off
#include "MantidNexusCpp/NeXusFile.hpp"
#include "MantidNexusCpp/NeXusException.hpp"
// clang-format on

namespace Mantid::API {

namespace {
Expand Down
32 changes: 8 additions & 24 deletions Framework/API/test/WorkspaceHistoryIOTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,11 @@ class WorkspaceHistoryIOTest : public CxxTest::TestSuite {
testHistory.addHistory(std::make_shared<AlgorithmHistory>(algHist));
}

// clang-format off
auto savehandle = std::make_shared< ::NeXus::File >("WorkspaceHistoryTest_test_SaveNexus.nxs",NXACC_CREATE5);
// clang-format on
auto savehandle = std::make_shared<::NeXus::File>("WorkspaceHistoryTest_test_SaveNexus.nxs", NXACC_CREATE5);
TS_ASSERT_THROWS_NOTHING(testHistory.saveNexus(savehandle.get()));
savehandle->close();

// clang-format off
auto loadhandle = std::make_shared< ::NeXus::File >("WorkspaceHistoryTest_test_SaveNexus.nxs");
// clang-format on
auto loadhandle = std::make_shared<::NeXus::File>("WorkspaceHistoryTest_test_SaveNexus.nxs");
std::string rootstring = "/process/";
for (int i = 1; i < 5; i++) {
TS_ASSERT_THROWS_NOTHING(
Expand All @@ -237,15 +233,11 @@ class WorkspaceHistoryIOTest : public CxxTest::TestSuite {
algHist.addChildHistory(std::make_shared<AlgorithmHistory>(childHist));
testHistory.addHistory(std::make_shared<AlgorithmHistory>(algHist));

// clang-format off
auto savehandle = std::make_shared< ::NeXus::File >("WorkspaceHistoryTest_test_SaveNexus.nxs",NXACC_CREATE5);
// clang-format on
auto savehandle = std::make_shared<::NeXus::File>("WorkspaceHistoryTest_test_SaveNexus.nxs", NXACC_CREATE5);
TS_ASSERT_THROWS_NOTHING(testHistory.saveNexus(savehandle.get()));
savehandle->close();

// clang-format off
auto loadhandle = std::make_shared< ::NeXus::File >("WorkspaceHistoryTest_test_SaveNexus.nxs");
// clang-format on
auto loadhandle = std::make_shared<::NeXus::File>("WorkspaceHistoryTest_test_SaveNexus.nxs");
std::string rootstring = "/process/";
TS_ASSERT_THROWS_NOTHING(loadhandle->openPath(rootstring + "MantidAlgorithm_1/"));
TS_ASSERT_THROWS_NOTHING(loadhandle->openPath(rootstring + "MantidAlgorithm_1/author"));
Expand All @@ -264,15 +256,11 @@ class WorkspaceHistoryIOTest : public CxxTest::TestSuite {
void test_SaveNexus_Empty() {
WorkspaceHistory testHistory;

// clang-format off
auto savehandle = std::make_shared< ::NeXus::File >("WorkspaceHistoryTest_test_SaveNexus.nxs",NXACC_CREATE5);
// clang-format on
auto savehandle = std::make_shared<::NeXus::File>("WorkspaceHistoryTest_test_SaveNexus.nxs", NXACC_CREATE5);
TS_ASSERT_THROWS_NOTHING(testHistory.saveNexus(savehandle.get()));
savehandle->close();

// clang-format off
auto loadhandle = std::make_shared< ::NeXus::File >("WorkspaceHistoryTest_test_SaveNexus.nxs");
// clang-format on
auto loadhandle = std::make_shared<::NeXus::File>("WorkspaceHistoryTest_test_SaveNexus.nxs");
std::string rootstring = "/process/";
TS_ASSERT_THROWS_NOTHING(loadhandle->openPath(rootstring));
TS_ASSERT_THROWS_NOTHING(loadhandle->openPath(rootstring + "MantidEnvironment"));
Expand All @@ -284,9 +272,7 @@ class WorkspaceHistoryIOTest : public CxxTest::TestSuite {

void test_LoadNexus() {
std::string filename = FileFinder::Instance().getFullPath("GEM38370_Focussed_Legacy.nxs");
// clang-format off
auto loadhandle = std::make_shared< ::NeXus::File >(filename);
// clang-format on
auto loadhandle = std::make_shared<::NeXus::File>(filename);
loadhandle->openPath("/mantid_workspace_1");

WorkspaceHistory emptyHistory;
Expand All @@ -306,9 +292,7 @@ class WorkspaceHistoryIOTest : public CxxTest::TestSuite {

void test_LoadNexus_NestedHistory() {
std::string filename = FileFinder::Instance().getFullPath("HistoryTest_CreateTransmissionAuto.nxs");
// clang-format off
auto loadhandle = std::make_shared< ::NeXus::File >(filename);
// clang-format on
auto loadhandle = std::make_shared<::NeXus::File>(filename);
loadhandle->openPath("/mantid_workspace_1");

WorkspaceHistory wsHistory;
Expand Down
6 changes: 2 additions & 4 deletions Framework/Algorithms/test/RebinByPulseTimesTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,8 @@ class RebinByPulseTimesTest : public CxxTest::TestSuite, public Super {
//=====================================================================================
// Performance Tests
//=====================================================================================
// clang-format off
class RebinByPulseTimesTestPerformance : public CxxTest::TestSuite, public RebinByTimeBaseTestPerformance<RebinByPulseTimes>
// clang-format on
{
class RebinByPulseTimesTestPerformance : public CxxTest::TestSuite,
public RebinByTimeBaseTestPerformance<RebinByPulseTimes> {

public:
static RebinByPulseTimesTestPerformance *createSuite() { return new RebinByPulseTimesTestPerformance(); }
Expand Down
7 changes: 2 additions & 5 deletions Framework/Algorithms/test/RebinByTimeAtSampleTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,8 @@ class RebinByTimeAtSampleTest : public CxxTest::TestSuite, public Super {
//=====================================================================================
// Performance Tests
//=====================================================================================
// clang-format off
class RebinByTimeAtSampleTestPerformance: public CxxTest::TestSuite,
public RebinByTimeBaseTestPerformance<RebinByTimeAtSample>
// clang-format on
{
class RebinByTimeAtSampleTestPerformance : public CxxTest::TestSuite,
public RebinByTimeBaseTestPerformance<RebinByTimeAtSample> {

public:
static RebinByTimeAtSampleTestPerformance *createSuite() { return new RebinByTimeAtSampleTestPerformance(); }
Expand Down
5 changes: 2 additions & 3 deletions Framework/Crystal/src/AddPeakHKL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ const std::string AddPeakHKL::summary() const { return "Add a peak in the hkl fr
void AddPeakHKL::init() {
declareProperty(std::make_unique<WorkspaceProperty<Mantid::API::IPeaksWorkspace>>("Workspace", "", Direction::InOut),
"An input workspace.");
// clang-format off
declareProperty(std::make_unique<ArrayProperty<double>>("HKL", std::make_shared<ArrayLengthValidator<double> > (3)), "HKL point to add");
// clang-format on
declareProperty(std::make_unique<ArrayProperty<double>>("HKL", std::make_shared<ArrayLengthValidator<double>>(3)),
"HKL point to add");
}

//----------------------------------------------------------------------------------------------
Expand Down
6 changes: 2 additions & 4 deletions Framework/Crystal/src/SetUB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ void SetUB::init() {
auto reasonableAngle = std::make_shared<BoundedValidator<double>>();
reasonableAngle->setLower(5.0);
reasonableAngle->setUpper(175.0);
// clang-format off
auto mustBe3D = std::make_shared<ArrayLengthValidator<double> >(3);
auto threeVthree = std::make_shared<ArrayLengthValidator<double> >(9);
// clang-format on
auto mustBe3D = std::make_shared<ArrayLengthValidator<double>>(3);
auto threeVthree = std::make_shared<ArrayLengthValidator<double>>(9);
std::vector<double> zeroes(9, 0.), u0(3, 0), v0(3, 0);
u0[0] = 1.;
v0[1] = 1.;
Expand Down
4 changes: 1 addition & 3 deletions Framework/Crystal/src/TransformHKL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ void TransformHKL::init() {
identity_matrix[0] = 1;
identity_matrix[4] = 1;
identity_matrix[8] = 1;
// clang-format off
auto threeBythree = std::make_shared<ArrayLengthValidator<double> >(9);
// clang-format on
auto threeBythree = std::make_shared<ArrayLengthValidator<double>>(9);
this->declareProperty(
std::make_unique<ArrayProperty<double>>("HKLTransform", std::move(identity_matrix), std::move(threeBythree)),
"Specify 3x3 HKL transform matrix as a comma separated list of 9 "
Expand Down
16 changes: 4 additions & 12 deletions Framework/Crystal/test/IndexPeaksTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,12 @@ PeaksWorkspace_sptr createTestPeaksWorkspaceMainReflOnly() {
0.0045884, 0.0273738, -0.08973560, 0.0252595};
// peaks from TOPAZ_3007.peaks: 0, 1, 2, 10, 42 with sign for Q swapped
// as we don't use the crystallographic convention
// clang-format off
GNU_DIAG_OFF("missing-braces")
// clang-format on
GNU_DIAG_OFF("missing-braces");
constexpr std::array<MinimalPeak, npeaks> testPeaksInfo = {
MinimalPeak{3008, V3D(-3.52961, 3.13589, 1.0899)}, MinimalPeak{3007, V3D(-2.42456, 2.29581, 1.71147)},
MinimalPeak{3007, V3D(-3.04393, 3.05739, 2.03727)}, MinimalPeak{3007, V3D(-4.02271, 2.4073, 1.62228)},
MinimalPeak{3008, V3D(-4.04552, 1.59916, 3.71776)}};
// clang-format off
GNU_DIAG_ON("missing-braces")
// clang-format on
GNU_DIAG_ON("missing-braces");
return createPeaksWorkspace<npeaks>(testPeaksInfo, ub);
}

Expand All @@ -91,19 +87,15 @@ PeaksWorkspace_sptr createTestPeaksWorkspaceWithSatellites(const int maxOrder =
const bool crossTerms = false) {
constexpr int npeaks{5};
const std::vector<double> ub = {0.269, -0.01, 0.033, 0.081, -0.191, -0.039, 0.279, 0.347, -0.02};
// clang-format off
GNU_DIAG_OFF("missing-braces")
// clang-format on
GNU_DIAG_OFF("missing-braces");
constexpr std::array<MinimalPeak, npeaks> testPeaksInfo = {
MinimalPeak{1, V3D(-3.691, -0.694, 3.762)}, // main
MinimalPeak{2, V3D(-1.234, -0.225, 1.25212)}, // satellite
MinimalPeak{1, V3D(-3.824, 0.728, 1.711)}, // main
MinimalPeak{1, V3D(0.872, -0.1998, 2.7476)}, // satellite
MinimalPeak{2, V3D(-1.54093, 0.129343, 1.445)}, // satellite
};
// clang-format off
GNU_DIAG_ON("missing-braces")
// clang-format on
GNU_DIAG_ON("missing-braces");
return createPeaksWorkspace<npeaks>(testPeaksInfo, ub, maxOrder, modVectors, crossTerms);
}

Expand Down
5 changes: 1 addition & 4 deletions Framework/Crystal/test/IntegratePeaksUsingClustersTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,7 @@ class IntegratePeaksUsingClustersTest : public CxxTest::TestSuite, public Cluste
//=====================================================================================
// Performance Tests
//=====================================================================================
// clang-format off
class IntegratePeaksUsingClustersTestPerformance : public CxxTest::TestSuite, public ClusterIntegrationBaseTest
// clang-format on
{
class IntegratePeaksUsingClustersTestPerformance : public CxxTest::TestSuite, public ClusterIntegrationBaseTest {

private:
// Input data
Expand Down
34 changes: 15 additions & 19 deletions Framework/DataHandling/inc/MantidDataHandling/LoadEventNexus.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,16 @@
#include "MantidKernel/Exception.h"
#include "MantidKernel/NexusHDF5Descriptor.h"
#include "MantidKernel/OptionalBool.h"
#include "MantidKernel/TimeSeriesProperty.h"

#include <Poco/Path.h>
#include <boost/lexical_cast.hpp>
#include <boost/scoped_array.hpp>
#include "MantidKernel/TimeSeriesProperty.h"

// clang-format off
#include "MantidNexusCpp/NeXusFile.hpp"
#include "MantidNexusCpp/NeXusException.hpp"
// clang-format on
#include "MantidNexusCpp/NeXusFile.hpp"

#include <Poco/Path.h>
#include <algorithm>
#include <boost/lexical_cast.hpp>
#include <boost/scoped_array.hpp>
#include <cstdint>
#include <functional>
#include <memory>
Expand Down Expand Up @@ -389,9 +387,9 @@ void adjustTimeOfFlightISISLegacy(::NeXus::File &file, T localWorkspace, const s
if (classType == "NXmonitor") {
std::vector<std::string> bankNames;
for (string_map_t::const_iterator it = entries.begin(); it != entries.end(); ++it) {
std::string entryName(it->first);
std::string entry_class(it->second);
const std::string entry_class(it->second);
if (entry_class == classType) {
const std::string entryName(it->first);
bankNames.emplace_back(entryName);
}
}
Expand Down Expand Up @@ -703,17 +701,15 @@ void LoadEventNexus::loadEntryMetadata(const std::string &nexusfilename, T WS, c
file.getDataCoerce(duration);
if (duration.size() == 1) {
// get the units
// clang-format off
std::vector< ::NeXus::AttrInfo> infos = file.getAttrInfos();
std::string units;
for (std::vector< ::NeXus::AttrInfo>::const_iterator it = infos.begin();
it != infos.end(); ++it) {
if (it->name == "units") {
units = file.getStrAttr(*it);
break;
std::vector<::NeXus::AttrInfo> infos = file.getAttrInfos();
std::string units;
for (auto it = infos.begin(); it != infos.end(); ++it) {
// cppcheck-suppress useStlAlgorithm
if (it->name == "units") {
units = file.getStrAttr(*it);
break;
}
}
}
// clang-format on

// set the property
WS->mutableRun().addProperty("duration", duration[0], units, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,7 @@ class MANTID_DATAHANDLING_DLL LoadISISNexus2 : public API::IFileLoader<Kernel::N
/// Personal wrapper for sqrt to allow msvs to compile
static double dblSqrt(double in);
// Handle to the NeXus file
// clang-format off
boost::scoped_ptr< ::NeXus::File> m_nexusFile;
// clang-format on
boost::scoped_ptr<::NeXus::File> m_nexusFile;

bool findSpectraDetRangeInFile(const NeXus::NXEntry &entry, std::vector<specnum_t> &spectrum_index, int64_t ndets,
int64_t n_vms_compat_spectra, const std::map<specnum_t, std::string> &monitors,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
// STL

// NeXus
// clang-format off
#include "MantidNexusCpp/NeXusException.hpp"
#include "MantidNexusCpp/NeXusFile.hpp"
// clang-format on

// Poco
#include <Poco/DOM/DOMParser.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
#include "MantidDataObjects/EventWorkspace.h"
#include "MantidDataObjects/Workspace2D_fwd.h"
#include "MantidGeometry/Instrument/RectangularDetector.h"
#include <climits>
// clang-format off
#include "MantidNexusCpp/NeXusFile.hpp"
#include "MantidNexusCpp/NeXusException.hpp"
// clang-format on
#include "MantidNexusCpp/NeXusFile.hpp"

#include <climits>

namespace Mantid {
namespace DataHandling {
Expand Down
6 changes: 3 additions & 3 deletions Framework/DataHandling/src/CreateChunkingFromInstrument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
#include "MantidGeometry/IDetector.h"
#include "MantidKernel/ListValidator.h"
#include "MantidKernel/OptionalBool.h"

#include "MantidKernel/StringTokenizer.h"
// clang-format off
#include "MantidNexusCpp/NeXusFile.hpp"

#include "MantidNexusCpp/NeXusException.hpp"
// clang-format on
#include "MantidNexusCpp/NeXusFile.hpp"

#include <algorithm>

Expand Down
12 changes: 3 additions & 9 deletions Framework/DataHandling/src/CreateSimulationWorkspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,23 @@
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#include "MantidDataHandling/CreateSimulationWorkspace.h"
#include "LoadRaw/isisraw2.h"
#include "MantidAPI/Axis.h"
#include "MantidAPI/FileProperty.h"
#include "MantidAPI/MatrixWorkspace.h"
#include "MantidAPI/Run.h"
#include "MantidAPI/WorkspaceFactory.h"
#include "MantidDataHandling/StartAndEndTimeFromNexusFileExtractor.h"

#include "MantidDataHandling/LoadRawHelper.h"
#include "MantidDataHandling/StartAndEndTimeFromNexusFileExtractor.h"
#include "MantidKernel/ArrayProperty.h"
#include "MantidKernel/ListValidator.h"
#include "MantidKernel/MandatoryValidator.h"
#include "MantidKernel/OptionalBool.h"
#include "MantidKernel/RebinParamsValidator.h"
#include "MantidKernel/UnitFactory.h"
#include "MantidKernel/VectorHelper.h"

#include "LoadRaw/isisraw2.h"
// clang-format off
#include "MantidNexusCpp/NeXusFile.hpp"
#include "MantidNexusCpp/NeXusException.hpp"
// clang-format on

#include <Poco/File.h>
#include "MantidNexusCpp/NeXusFile.hpp"

namespace {

Expand Down
5 changes: 1 addition & 4 deletions Framework/DataHandling/src/DetermineChunking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@
#include "MantidDataHandling/LoadTOFRawNexus.h"
#include "MantidKernel/BinaryFile.h"
#include "MantidKernel/BoundedValidator.h"

// clang-format off
#include "MantidNexusCpp/NeXusFile.hpp"
#include "MantidNexusCpp/NeXusException.hpp"
// clang-format on
#include "MantidNexusCpp/NeXusFile.hpp"

#include <Poco/File.h>
#include <exception>
Expand Down
5 changes: 1 addition & 4 deletions Framework/DataHandling/src/LoadBankFromDiskTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@
#include "MantidKernel/Unit.h"
#include "MantidKernel/VectorHelper.h"
#include "MantidNexus/NexusIOHelper.h"

// clang-format off
#include "MantidNexusCpp/NeXusFile.hpp"
#include "MantidNexusCpp/NeXusException.hpp"
// clang-format on
#include "MantidNexusCpp/NeXusFile.hpp"

#include <algorithm>
#include <utility>
Expand Down
4 changes: 1 addition & 3 deletions Framework/DataHandling/src/LoadMcStasNexus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@
#include "MantidAPI/WorkspaceFactory.h"
#include "MantidAPI/WorkspaceGroup.h"
#include "MantidKernel/Unit.h"
// clang-format off
#include "MantidNexusCpp/NeXusFile.hpp"
#include "MantidNexusCpp/NeXusException.hpp"
// clang-format on
#include "MantidNexusCpp/NeXusFile.hpp"

namespace Mantid::DataHandling {
using namespace Kernel;
Expand Down
Loading

0 comments on commit a411fec

Please sign in to comment.