fix: narrowing and implicit conversion fixes done by AI#5313
Open
asalzburger wants to merge 3 commits intoacts-project:mainfrom
Open
fix: narrowing and implicit conversion fixes done by AI#5313asalzburger wants to merge 3 commits intoacts-project:mainfrom
asalzburger wants to merge 3 commits intoacts-project:mainfrom
Conversation
Contributor
Member
|
There's a number of new issues. |
Contributor
Author
Yeah, many of them are:
where SonarCloud is giving the opposite recommendation than Athena coding rules, as far as I remember. |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Address Sonar implicit conversion and narrowing findings
*** This has been done using our SonarCloud output by cursor ***
Summary
This change set makes implicit numeric conversions explicit across Core, Alignment, and related headers/sources, targeting SonarCloud rules around implicit conversion and narrowing (integer precision loss,
double→float, andstd::size_tmixed with narrower index or arithmetic types). The intent is mechanical clarity for static analysis and alignment with strict floating-point warnings (for example-Wfloat-conversion), without altering algorithms.Motivation
Sonar reported a large cluster of findings where:
std::size_t(or other wide integers) were used where API types expectint, trajectory index types, orfloat-backed binning.UnitConstants(typicallydouble) were assigned tofloatconfiguration fields without an explicit cast.std::size_tplus a negativeint).Making these conversions explicit documents intent and removes or reduces the corresponding static-analysis noise.
Approach
static_cast<T>(…)at boundaries (sizes to index types, integrals todoublefor division,doubletofloatfor stored parameters).…fliterals where afloatis clearly intended.static_cast<int>(idx)before adding signed offsets, andstatic_cast<int>(getNBins())where a narrowintrange is required.fastCathetus: promotehypotenusetodoublebefore the difference/sum undersqrtso mixed-type call sites stay well defined.hypotSquarewas not changed to always returndouble; doing so altered deduced return types forfastHypotand broke a lambda that mixedfastHypotand scalar returns. Instead,BroadTripletSeedFilter’sgetTopRlambda is explicitly-> floatwithstatic_cast<float>(fastHypot(…)).Areas touched (high level)
doublecasts for counts.floatχ² assignment; fitter result indices aligned withTrackIndexTypewhere applicable.size()/distance→ explicit index oruint32_tcasts.floatpaths: explicit casts fromdoubleor Eigen scalars.UnitConstants, GbTS filter literals, geometrynumOfBins/numLayers, graph-seeder floats, triplet/doubletfsuffixes.FacesHelper:ankerand half-count geometry use explicit casts.MeasurementSelector,TrackParamsLookupAccumulator:floatχ₂ anddoublepromotion for count-weighted parameters.Axis,BinAdjustment(+ volume variant),BinningData,Polynomials(product→double),MathHelpers(fastCathetus).GaussianGridTrackDensityconfig:binSizeand literals.EventDataView3D,Interpolation3D: loop indices promoted fordoublemath.ParticleDataSEMF terms, seed/space-pointreserve,VectorMultiTrajectory/VectorTrackContainer, geometry builders (Cuboid/Cylinder/LayerArray/CylinderVolumeHelper).Verification
-Wfloat-conversionenabled in project flags:ActsCoreandActsAlignmentlink successfully.Follow-up (optional)
sc_issues.json(same housekeeping as for other rule batches).narrowing_issues.tsv(~179 rows) was a one-off extract from an export; refresh or remove from the repo if it should not be tracked.Related
--- END COMMIT MESSAGE ---
Any further description goes here, @-mentions are ok here!
feat,fix,refactor,docs,choreandbuildtypes.