SONARJS-297 fix false-prositive and extract code to be re-use.