Handle ternary operator in redundantAssignment check (#5964)