Line 247 is out of range for file File.cs. File has 246 lines

  • Sonar: 7.9.1.27448
  • Scanner: 4.1.0.1829
  • SonarScanner for MSBuild 4.7.1
ERROR: Error during SonarQube Scanner execution
java.lang.IllegalArgumentException: Line 247 is out of range for file *****/CategoryPicker.cs. File has 246 lines.
	at com.google.common.base.Preconditions.checkArgument(Preconditions.java:145)
	at org.sonar.scanner.DefaultFileLinesContext.checkLineRange(DefaultFileLinesContext.java:64)
	at org.sonar.scanner.DefaultFileLinesContext.setIntValue(DefaultFileLinesContext.java:57)
	at org.sonarsource.dotnet.shared.plugins.protobuf.MetricsImporter.consumeFor(MetricsImporter.java:72)
	at org.sonarsource.dotnet.shared.plugins.protobuf.MetricsImporter.consumeFor(MetricsImporter.java:38)
	at org.sonarsource.dotnet.shared.plugins.protobuf.ProtobufImporter.consume(ProtobufImporter.java:74)
	at org.sonarsource.dotnet.shared.plugins.protobuf.RawProtobufImporter.accept(RawProtobufImporter.java:49)
	at org.sonarsource.dotnet.shared.plugins.ProtobufDataImporter.parseProtobuf(ProtobufDataImporter.java:104)
	at org.sonarsource.dotnet.shared.plugins.ProtobufDataImporter.importResults(ProtobufDataImporter.java:72)
	at org.sonarsource.dotnet.shared.plugins.DotNetSensor.executeInternal(DotNetSensor.java:95)
	at org.sonarsource.dotnet.shared.plugins.DotNetSensor.execute(DotNetSensor.java:73)
	at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:62)
	at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
	at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:400)
	at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:395)
	at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:358)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
	at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:141)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
	at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:73)
	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:567)
	at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
	at com.sun.proxy.$Proxy0.execute(Unknown Source)
	at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:185)
	at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:137)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
	at org.sonarsource.scanner.cli.Main.main(Main.java:61)
ERROR:
The SonarQube Scanner did not complete successfully
10:31:25.059  Post-processing failed. Exit code: 1

Hey, I am getting the Error “Line 247 is out of range for file File.cs. File has 246 lines”. The named File has 256 lines…
I searched a lot and did not found any solution.
Every File in my Project is encoded with UTF-8 with BOM but the error just appears at this File.

Any solutions?

Thanks!

Hello,
Can you please attach the whole analysis log ?
This error is typical of an old coverage report.
You need to generate the coverage report during each analysis so it correspond to the analysed version of the source code.
Alex.