Sonar consider changed file names as "new code" and how to handle legacy code

Template for a good bug report, formatted with Markdown:

  • versions used (SonarQube, Scanner, Plugin, and any relevant extension)
    EE Version 8.9.1 (build 44547)

  • error observed (wrap logs/code around triple quote ``` for proper formatting)
    I have some legacy code that have limited test coverage (< 60%). File name changes are recognized as “new code”. Beside that if you have legacy code with test coverage (<60%) and you have one file in that you change some lines and test them the quality gate will also fail (new code > 80%) as not only the changed lines are considered but the whole class that has previously < 60% and needs to have > 80 % with the current quality gate

  • steps to reproduce

  1. file changes

You need to change a file name and this is considered as "“new code”.

  1. Legacy code and coverage only on class level considered for coverage

You have legacy code with test coverage (<60%)
You have one file in that you change some lines and test them
The quality gate will also fail (new code > 80%) as the whole class is considered for the coverage instead of only the changes (in that case some lines)
As the class had previously < 60% it needs with the new quality gate to have > 80 %

Hi,

Welcome to the community!

Unfortunately, you’ve stumbled across this:

SONAR-13579 - File move not detected in P/Rs

 
:slightly_frowning_face:
Ann