fixing Sonar violations: For-in statement must filter items