Conversation
|
| // Set the alignment mask | ||
| auto iter_it = alignOptions.iterationState.find(iIter); | ||
| if (iter_it != alignOptions.iterationState.end()) { | ||
| if (auto iter_it = alignOptions.iterationState.find(iIter); |
There was a problem hiding this comment.
| if (auto iter_it = alignOptions.iterationState.find(iIter); | |
| if (const auto iter_it = alignOptions.iterationState.find(iIter); |
| alignOptions.fitOptions.geoContext, alignOptions.alignedDetElements, | ||
| alignOptions.alignedTransformUpdater, alignResult); | ||
| if (!updateRes.ok()) { | ||
| if (auto updateRes = updateAlignmentParameters( |
There was a problem hiding this comment.
| if (auto updateRes = updateAlignmentParameters( | |
| if (const auto updateRes = updateAlignmentParameters( |
| auto isoutliner = ts.typeFlags().isOutlier(); | ||
|
|
||
| if (isoutliner) { | ||
| if (auto isoutliner = ts.typeFlags().isOutlier(); isoutliner) { |
There was a problem hiding this comment.
| if (auto isoutliner = ts.typeFlags().isOutlier(); isoutliner) { | |
| if (const bool isOutliner = ts.typeFlags().isOutlier(); isOutliner) { |
| trajState.nStates++; | ||
| auto typeFlags = state.typeFlags(); | ||
| if (typeFlags.isHole()) { | ||
| if (auto typeFlags = state.typeFlags(); typeFlags.isHole()) { |
There was a problem hiding this comment.
| if (auto typeFlags = state.typeFlags(); typeFlags.isHole()) { | |
| if (const auto typeFlags = state.typeFlags(); typeFlags.isHole()) { |
| trajState.NDF += state.calibratedSize(); | ||
| auto typeFlags = state.typeFlags(); | ||
| if (typeFlags.isHole()) { | ||
| if (auto typeFlags = state.typeFlags(); typeFlags.isHole()) { |
There was a problem hiding this comment.
| if (auto typeFlags = state.typeFlags(); typeFlags.isHole()) { | |
| if (const auto typeFlags = state.typeFlags(); typeFlags.isHole()) { |
| if (auto currentSurface = navigator.currentSurface(state.navigation); | ||
| currentSurface && selector(*currentSurface)) { |
There was a problem hiding this comment.
| if (auto currentSurface = navigator.currentSurface(state.navigation); | |
| currentSurface && selector(*currentSurface)) { | |
| if (const Surface* currentSurface = navigator.currentSurface(state.navigation); | |
| currentSurface != nullptr && selector(*currentSurface)) { |
| if (auto currentVolume = navigator.currentVolume(state.navigation); | ||
| currentVolume && selector(*currentVolume)) { |
There was a problem hiding this comment.
| if (auto currentVolume = navigator.currentVolume(state.navigation); | |
| currentVolume && selector(*currentVolume)) { | |
| if (const Volume* currentVolume = navigator.currentVolume(state.navigation); | |
| currentVolume != nullptr && selector(*currentVolume)) { |
| if (bool passesMask = m_group->mask().at(m_gridItr.globalBinIndex()); | ||
| dimCollection > 0ul && passesMask) { |
There was a problem hiding this comment.
| if (bool passesMask = m_group->mask().at(m_gridItr.globalBinIndex()); | |
| dimCollection > 0ul && passesMask) { | |
| if (const bool passesMask = m_group->mask().at(m_gridItr.globalBinIndex()); | |
| dimCollection > 0ul && passesMask) { |
| if (precResult_t precResult = | ||
| doPrecFit ? fastPrecFit<fitStraws, fitTime>( | ||
| measurements, initialGuess, precFitDelegate) | ||
| : std::nullopt; | ||
| doPrecFit && !precResult) { |
| if (std::optional<SquareMatrix<N>> inverseH{safeInverse(miniHessian)}; | ||
| inverseH) { |
There was a problem hiding this comment.
| if (std::optional<SquareMatrix<N>> inverseH{safeInverse(miniHessian)}; | |
| inverseH) { | |
| if (const std::optional<SquareMatrix<N>> inverseH = safeInverse(miniHessian); | |
| inverseH.has_value()) { |
There was a problem hiding this comment.
here I would also argue that it hurts readability
| if (SourceLinkRange slRange = sourceLinkAccessor(surface); | ||
| slRange.first != slRange.second) { |
There was a problem hiding this comment.
| if (SourceLinkRange slRange = sourceLinkAccessor(surface); | |
| slRange.first != slRange.second) { | |
| if (const auto slRange = sourceLinkAccessor(surface); | |
| slRange.first != slRange.second) { |
| @@ -113,8 +113,8 @@ struct TrackStateCreator { | |||
| TrackStateContainerBackend& trajectory, const Logger& logger) const { | |||
| TrackStatesResult tsRes = TrackStatesResult::success({}); | |||
| using SourceLinkRange = decltype(sourceLinkAccessor(surface)); | |||
There was a problem hiding this comment.
| using SourceLinkRange = decltype(sourceLinkAccessor(surface)); |
| if (Result<std::pair<typename std::vector<TrackStateProxy>::iterator, | ||
| typename std::vector<TrackStateProxy>::iterator>> | ||
| selectorResult = | ||
| measurementSelector(trackStateCandidates, isOutlier, logger); | ||
| !selectorResult.ok()) { |
There was a problem hiding this comment.
| if (Result<std::pair<typename std::vector<TrackStateProxy>::iterator, | |
| typename std::vector<TrackStateProxy>::iterator>> | |
| selectorResult = | |
| measurementSelector(trackStateCandidates, isOutlier, logger); | |
| !selectorResult.ok()) { | |
| if (const auto selectorResult = | |
| measurementSelector(trackStateCandidates, isOutlier, logger); | |
| !selectorResult.ok()) { |
There was a problem hiding this comment.
also here I fear it hurts the algorithm flow
| // register the face | ||
| auto searchIter = m_glueVolumes.find(bsf); | ||
| if (searchIter == m_glueVolumes.end()) { | ||
| if (auto searchIter = m_glueVolumes.find(bsf); |
There was a problem hiding this comment.
| if (auto searchIter = m_glueVolumes.find(bsf); | |
| if (const auto searchIter = m_glueVolumes.find(bsf); |
| // searching for the glue volumes according | ||
| auto searchIter = m_glueVolumes.find(bsf); | ||
| if (searchIter != m_glueVolumes.end()) { | ||
| if (auto searchIter = m_glueVolumes.find(bsf); |
There was a problem hiding this comment.
| if (auto searchIter = m_glueVolumes.find(bsf); | |
| if (const auto searchIter = m_glueVolumes.find(bsf); |
| if (auto boundsType = m_config.bounds ? m_config.bounds->type() | ||
| : VolumeBounds::BoundsType::eOther; |
There was a problem hiding this comment.
| if (auto boundsType = m_config.bounds ? m_config.bounds->type() | |
| : VolumeBounds::BoundsType::eOther; | |
| if (const VolumeBounds::BoundsType boundsType = m_config.bounds ? m_config.bounds->type() | |
| : VolumeBounds::BoundsType::eOther; |
| !(boundsType == VolumeBounds::BoundsType::eTrapezoid || | ||
| boundsType == VolumeBounds::BoundsType::eCuboid || | ||
| boundsType == VolumeBounds::BoundsType::eDiamond)) { |
There was a problem hiding this comment.
a local using enum could improve readability here



C++17
ifinit-statement (Sonar)***These are fixes done by cursor AI running on (part of) our SonarCloud output ***
Summary
This change addresses Sonar findings that ask to declare a variable in the init-statement of an
if(C++17), instead of declaring it on the preceding line and only using it in the condition and immediate body. The refactor narrows scope, matches modern C++ style, and clears the corresponding “Use the init-statement to declare … inside the if statement” issues (76 in the exported Sonar report used for triage).Pattern
Before:
After:
The same idea applies to pointers, booleans, iterator results,
Resulttypes,dynamic_castresults, and similar “compute once, then branch” code.Notable cases
if/else ifchains: Names introduced in the init-statement are in scope for the entireif/else if/elsechain. This is used for flags such astypeFlagsandcurrentStatewhere several branches need the same value.CompositeSpacePointLineFitter:precResultis initialized in the firstif; the followingelse if (precResult)remains valid because it is part of the sameifstatement.GaussianSumFitter: One branch usesif constexpr (constexpr bool IsMultiParameters = …; !IsMultiParameters)(C++20), consistent with the project standard.VectorHelpers::perp:if constexprwith an init-statement forRowsAtCompileTime.SteppingHelper:farLimitis only needed for the reachability check; it is moved into thatif’s init-statement whilenearLimitstays outside.Files touched (39)
Alignment/include/ActsAlignment/Kernel/Alignment.ippCore/include/Acts/AmbiguityResolution/ScoreBasedAmbiguityResolution.ippCore/include/Acts/EventData/MultiTrajectoryHelpers.hppCore/include/Acts/Propagator/DirectNavigator.hppCore/include/Acts/Propagator/EigenStepper.ippCore/include/Acts/Propagator/MaterialInteractor.hppCore/include/Acts/Propagator/MultiStepperLoop.ippCore/include/Acts/Propagator/Propagator.ippCore/include/Acts/Propagator/StandardAborters.hppCore/include/Acts/Propagator/SurfaceCollector.hppCore/include/Acts/Propagator/VolumeCollector.hppCore/include/Acts/Propagator/detail/SteppingHelper.hppCore/include/Acts/Seeding/BinnedGroupIterator.ippCore/include/Acts/Seeding/CompositeSpacePointLineFitter.ippCore/include/Acts/TrackFinding/CombinatorialKalmanFilter.hppCore/include/Acts/TrackFinding/TrackStateCreator.hppCore/include/Acts/TrackFitting/GaussianSumFitter.hppCore/include/Acts/TrackFitting/GlobalChiSquareFitter.hppCore/include/Acts/TrackFitting/KalmanFitter.hppCore/include/Acts/TrackFitting/detail/GsfActor.hppCore/include/Acts/Utilities/AlgebraHelpers.hppCore/include/Acts/Utilities/Frustum.ippCore/include/Acts/Utilities/TrackHelpers.hppCore/include/Acts/Utilities/TypeDispatcher.hppCore/include/Acts/Utilities/UnitVectors.hppCore/include/Acts/Utilities/VectorHelpers.hppCore/src/EventData/CorrectedTransformationFreeToBound.cppCore/src/Geometry/ConeVolumeBounds.cppCore/src/Geometry/CuboidVolumeStack.cppCore/src/Geometry/CutoutCylinderVolumeBounds.cppCore/src/Geometry/CylinderPortalShell.cppCore/src/Geometry/CylinderVolumeBuilder.cppCore/src/Geometry/CylinderVolumeHelper.cppCore/src/Geometry/CylinderVolumeStack.cppCore/src/Geometry/DiscLayer.cppCore/src/Geometry/GlueVolumesDescriptor.cppCore/src/Geometry/LayerArrayCreator.cppCore/src/Geometry/MultiWireVolumeBuilder.cppVerification
acts build acts-sonarcloud(from~/Documents/work/devwith your usualactsenvironment).acts test acts-sonarcloud(fullctestsuite for the project).No intended behavioral change: only scope and style, except where the previous variable would have leaked into a wider block (now correctly limited to the
ifstatement).--- END COMMIT MESSAGE ---
Any further description goes here, @-mentions are ok here!
feat,fix,refactor,docs,choreandbuildtypes.