From 174de5921dcfe6cc3f8886c4c05bbee63ef1b5ed Mon Sep 17 00:00:00 2001 From: jerrrrycho Date: Thu, 3 Dec 2026 06:48:14 +0100 Subject: [PATCH] fix: SonarQube reliability finding of the buffer stops report The lambda that writes the buffer stop cell captured the notice by reference, which the analyser took for a possible null dereference; it now captures the values it needs explicitly. A dead store of the frame-hit loop removed. --- physics/bufferstop.cpp | 1 - simulation/simulation.cpp | 8 +++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/physics/bufferstop.cpp b/physics/bufferstop.cpp index 6d05fb2ca..419a4c266 100644 --- a/physics/bufferstop.cpp +++ b/physics/bufferstop.cpp @@ -447,7 +447,6 @@ contact_result contact(definition const &Stop, state &Stop_state, contact_input result.travel += hit.crush1 + hit.crush2; result.duration = std::min(Input.dt, result.duration + hit.duration); velocity = hit.velocity; - time = Input.dt; if (climbs(vehiclecrush)) { auto const climbed{after_override(Stop, now, Input.mass, velocity)}; result.climbed = true; diff --git a/simulation/simulation.cpp b/simulation/simulation.cpp index cf0d56887..76ad51566 100644 --- a/simulation/simulation.cpp +++ b/simulation/simulation.cpp @@ -158,12 +158,14 @@ void state_manager::report_buffer_stop( TDynamicObject const &Vehicle, bufferstop::notice const &Notice ) { auto const text { bufferstop::cell_text( Notice ) }; - auto const tell { [ & ]( std::string const &Name ) { + auto const velocity { Notice.velocity }; + auto const result { static_cast( static_cast( Notice.result ) ) }; + auto const tell { [ &text, velocity, result, &Vehicle ]( std::string const &Name ) { if( auto *cell { Memory.find( Name ) } ) { cell->UpdateValues( text, - Notice.velocity, - static_cast( static_cast( Notice.result ) ), + velocity, + result, basic_event::flags::text | basic_event::flags::value1 | basic_event::flags::value2 ); } if( auto *launched { Events.FindEvent( Name ) } ) {