From 52fc0e1d07bd4bfb8187ead482bc39b843d9f066 Mon Sep 17 00:00:00 2001 From: Julien Esseiva Date: Wed, 27 Nov 2024 12:23:50 -0800 Subject: [PATCH 01/13] fix lints --- app/celer-dump-data.cc | 8 ++++---- app/celer-g4/DetectorConstruction.cc | 1 + app/celer-geo/celer-geo.cc | 1 + src/accel/ExceptionConverter.cc | 2 +- src/accel/detail/HitProcessor.cc | 2 +- src/celeritas/ext/detail/CelerOpticalPhysics.cc | 6 +++++- src/celeritas/geo/GeoMaterialParams.cc | 8 +++++--- src/celeritas/global/CoreState.cc | 2 +- src/celeritas/optical/OpticalCollector.cc | 1 + src/celeritas/optical/detail/OpticalLaunchAction.cc | 9 +++++---- src/celeritas/user/SlotDiagnostic.cc | 11 ++++++++++- src/corecel/data/CollectionMirror.hh | 2 +- src/corecel/io/ColorUtils.cc | 1 + src/corecel/io/ExceptionOutput.cc | 1 + src/corecel/io/LoggerTypes.cc | 2 +- src/corecel/io/detail/ReprImpl.cc | 1 + src/corecel/sys/MultiExceptionHandler.cc | 2 ++ src/corecel/sys/ScopedMem.cc | 4 +++- src/corecel/sys/ScopedSignalHandler.cc | 1 + src/corecel/sys/TracingSession.cc | 2 +- src/corecel/sys/TypeDemangler.cc | 1 + src/geocel/GeoParamsInterface.hh | 2 +- src/geocel/GeoVolumeFinder.cc | 1 + src/geocel/ScopedGeantLogger.cc | 4 ++++ src/geocel/g4/GeantGeoParams.cc | 7 +++---- src/geocel/g4vg/Converter.cc | 11 ++++++----- src/geocel/g4vg/SolidConverter.cc | 6 +++--- src/geocel/rasterize/ImageWriter.libpng.cc | 2 +- src/geocel/vg/detail/VecgeomNavCollection.cc | 5 +++-- src/orange/OrangeParams.cc | 2 ++ src/orange/OrangeParams.hh | 2 +- src/orange/OrangeTypes.cc | 1 + src/orange/detail/OrangeInputIOImpl.json.cc | 1 + src/orange/detail/UnitInserter.cc | 1 + src/orange/detail/UniverseInserter.cc | 1 + src/orange/g4org/SolidConverter.cc | 11 ++++++----- src/orange/orangeinp/InputBuilder.cc | 1 + src/orange/orangeinp/PolySolid.cc | 7 ++++--- src/orange/surf/GeneralQuadric.cc | 1 + src/orange/surf/SimpleQuadric.cc | 2 ++ 40 files changed, 91 insertions(+), 45 deletions(-) diff --git a/app/celer-dump-data.cc b/app/celer-dump-data.cc index 8496cae004..07fc6fb3ba 100644 --- a/app/celer-dump-data.cc +++ b/app/celer-dump-data.cc @@ -810,8 +810,8 @@ class OpticalMfpHelper }; //! Construct helper for given model class out of the models - OpticalMfpHelper(std::vector const& models, optical::ImportModelClass imc) - : mfps_(nullptr) + OpticalMfpHelper(std::vector const& models, + optical::ImportModelClass imc) { auto iter = std::find_if(models.begin(), models.end(), [imc] (auto const& m) { return m.model_class == imc; }); if (iter != models.end()) @@ -831,7 +831,7 @@ class OpticalMfpHelper } private: - std::vector const* mfps_; + std::vector const* mfps_{nullptr}; }; /*! @@ -968,7 +968,7 @@ void print_optical_materials(std::vector const& io_models, /*! * Execute and run. */ -int main(int argc, char* argv[]) +int main(int argc, char* argv[]) // NOLINT(bugprone-exception-escape) { using namespace celeritas; using namespace celeritas::app; diff --git a/app/celer-g4/DetectorConstruction.cc b/app/celer-g4/DetectorConstruction.cc index be5ea6bce5..7abe6c7af1 100644 --- a/app/celer-g4/DetectorConstruction.cc +++ b/app/celer-g4/DetectorConstruction.cc @@ -312,6 +312,7 @@ void DetectorConstruction::ConstructSDandField() * Apply a function to the range of volumes for each detector. */ template +// NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward) void DetectorConstruction::foreach_detector(F&& apply_to_range) const { auto start = detectors_.begin(); diff --git a/app/celer-geo/celer-geo.cc b/app/celer-geo/celer-geo.cc index 5d9c0b792d..5aa5837762 100644 --- a/app/celer-geo/celer-geo.cc +++ b/app/celer-geo/celer-geo.cc @@ -132,6 +132,7 @@ void run_trace(Runner& run_trace, std::ofstream image_file(trace_setup.bin_file, std::ios::binary); std::vector image_data(img_params.num_pixels()); image->copy_to_host(make_span(image_data)); + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) image_file.write(reinterpret_cast(image_data.data()), image_data.size() * sizeof(int)); } diff --git a/src/accel/ExceptionConverter.cc b/src/accel/ExceptionConverter.cc index e307b24a5d..d6c897064a 100644 --- a/src/accel/ExceptionConverter.cc +++ b/src/accel/ExceptionConverter.cc @@ -166,7 +166,7 @@ void ExceptionConverter::operator()(std::exception_ptr eptr) const msg << "\n[error while exporting state: " << e.what() << "]"; } - catch (...) + catch (...) // NOLINT(bugprone-empty-catch) { /* Do nothing */ } diff --git a/src/accel/detail/HitProcessor.cc b/src/accel/detail/HitProcessor.cc index cc60513bc3..9974376f23 100644 --- a/src/accel/detail/HitProcessor.cc +++ b/src/accel/detail/HitProcessor.cc @@ -141,7 +141,7 @@ HitProcessor::~HitProcessor() { CELER_LOG_LOCAL(debug) << "Deallocating hit processor"; } - catch (...) + catch (...) // NOLINT(bugprone-empty-catch) { // Ignore anything bad that happens while logging } diff --git a/src/celeritas/ext/detail/CelerOpticalPhysics.cc b/src/celeritas/ext/detail/CelerOpticalPhysics.cc index 0119a89917..2fe35f8300 100644 --- a/src/celeritas/ext/detail/CelerOpticalPhysics.cc +++ b/src/celeritas/ext/detail/CelerOpticalPhysics.cc @@ -335,10 +335,14 @@ void CelerOpticalPhysics::ConstructProcess() idxPostStep); } } + // NOLINTBEGIN(bugprone-unused-return-value, + // clang-analyzer-cplusplus.NewDeleteLeaks) boundary.release(); cerenkov.release(); scint.release(); -} + // NOLINTEND(bugprone-unused-return-value, + // clang-analyzer-cplusplus.NewDeleteLeaks) +} // NOLINT(clang-analyzer-cplusplus.NewDeleteLeaks) } // namespace detail } // namespace celeritas diff --git a/src/celeritas/geo/GeoMaterialParams.cc b/src/celeritas/geo/GeoMaterialParams.cc index 0296c3eaf7..001982a8ef 100644 --- a/src/celeritas/geo/GeoMaterialParams.cc +++ b/src/celeritas/geo/GeoMaterialParams.cc @@ -40,9 +40,11 @@ using MapLabelMatId = std::unordered_map; * The input is effectively an "unzipped" unordered list of (volume label, * material id) pairs. */ -MapLabelMatId build_label_map(MaterialParams const& mat_params, - std::vector