SONARJAVA-776 Simplify code