2

We have AzureDevops build pipeline. Where we have the following steps.

  1. Prepare Analysis for SonarQube
  2. Run unit tests
  3. Run integration tests
  4. Run code analysis

For #4, when we try to Run Code Analysis, it is giving some weird error from SonarQube scanner.

java.lang.IllegalStateException: Line 92 is out of range in the file

But file has only 90 lines of code. I am not sure why it is complaining this?

Hiren
  • 1,381
  • 5
  • 24
  • 41
  • Possible duplicate of [Line 1203 is out of range when scanning C# file](https://stackoverflow.com/questions/41163335/line-1203-is-out-of-range-when-scanning-c-sharp-file) – Matt Sep 23 '19 at 21:49
  • Any update for this issue? Have you resolved this issue? If not, would you please let me know the latest information about this issue? – Leo Liu Oct 02 '19 at 10:02

1 Answers1

2

SonarQube scanner failing with line out of range

In general, this issue occurred with one file that went down on number of lines, then sonar use the cache, that is why it looked for a line out of range.

Just like user1014639 said:

The problem was due to the old code coverage report that was generated before updating the code. It was fixed after generating coverage reports again. So, please also make sure that the any coverage reports that are left behind from the previous run are cleared and new coverage reports are in place.

So, please try to run the command line:

mvn clean test sonar:sonar

to clean the old report.

Besides, if above not help you, you should make sure analyzed source code is strictly identical to the one used to generate the coverage report:

Check this thread for some details.

Hope this helps.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135