Skip to content

Commit 0b5ab22

Browse files
bedaHovorkaclaude
andcommitted
fix(context): replace unsafe !! map access with error() guard (kotlin:S6611)
DefaultSimulationContext.kt line 856 used !! to access a map value after a containsKey check, which SonarCloud flags as a potential NPE (kotlin:S6611). Replace with ?: error(...) to provide a clear message if the invariant is ever violated. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent bc988ba commit 0b5ab22

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

core/src/commonMain/kotlin/cz/vutbr/fit/interlockSim/context/DefaultSimulationContext.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,8 @@ open class DefaultSimulationContext(
853853

854854
// Ensure lookups by DynamicTrackBlock (graph values) still work by aliasing to the same wrapper
855855
if (!staticTrackToDynamicMap.containsKey(dynamicBlock)) {
856-
staticTrackToDynamicMap[dynamicBlock] = staticTrackToDynamicMap[staticTrack]!!
856+
staticTrackToDynamicMap[dynamicBlock] = staticTrackToDynamicMap[staticTrack]
857+
?: error("Expected DynamicTrack for $staticTrack to be registered in the map")
857858
}
858859

859860
// Recursively map any internal TrackSection objects

0 commit comments

Comments
 (0)