Sonar Scan Failure for Line Out-of-Range

Dear Sonar experts,

We keep getting Sonar error complaining code line out of range. The error message is:

java.lang.IllegalStateException: Line 92 is out of range in the file xxxxx.cpp (lines: 90)

The code it complains on has only 90 lines, we don’t understand how Sonar would expect line 92. Our CI does not use any cache, all analysis are from clean checkout and clean build.

This error can be eliminated by adding some empty lines in the end of the file, but we don’t want to keep empty lines in our code base for this reason.

Could anyone help on how to solve this ?

Many thanks,

Hey there.

You’ve not included some information from the template post:

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)

It would also be helpful for you to provide a wider range of logs, to understand where in the scan you are getting this error.