Sonarcloud is detecting already existing code as new code during PR analysis


I am facing issues during PR analysis. The analysis shows code coverage issue for a piece of code that was pushed and merged 2 years ago. The code is available on the master branch, which is the base branch of this project. The code is written in javascript. Is there a way to work around code coverage? Thanks in advance.


Welcome to the community!

Just to make sure, you’re saying that your PR analysis is picking up a 2-year-old piece of code, and showing it as uncovered?

Can you click in the margin next to this code and verify that the blame date SonarCloud got from your SCM is actually 2 years old?

If so, then this sounds like a problem with the detection of new code, and we’ll need to see your analysis log.

The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.

This guide will help you find them.