Fix Sonar major violation: Collapsible If Statements