Fix multiple recently introduced SonarCloud warnings (#10896)