Untouched Java methods in a java class incorrectly flagged as missing coverage in SonarQube analysis

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube Server / Community Build - Community Build v25.12.0.117093)

  • how is SonarQube deployed: Helm

  • what are you trying to achieve: whenever there is a change in a java class certain methods that are not touched, fails with code coverage

  • what have you tried so far to achieve this, we have set the new code settings to
    Number of days

    Any code that has changed in the last x days is considered new code. If no action is taken on a new issue after x days, this issue will become part of the overall code. Recommended for projects following continuous delivery.
    to 1
    Still this doesnt resolve any immediate PR changes

Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!

Hi,

Welcome to the community!

So you’re saying that your quality gate fails for coverage on new code, and these un-touched methods are highlighted as being new?

If you click in the left margin next to one of these methods, what change date shows up, and is it correct?

 
Ann

thank you for the reply, I will check and let you know

sorry about the delay, so there is a java file with the below addition to a method

so after sonar analysis, it says that line of code is new, where as through out the file it says uncovered, even for a definition “private static final”

finally report says this

can you please advise?

Hi,

Thanks for the screenshots. They’re very helpful!

From what I see, everything lines up:

  • The if statement on line 91 is new.
  • The if statement is not covered.
  • The quality gate fails with 1 uncovered line of code.

 
Ann