ERROR: Error during SonarScanner execution java.lang.IllegalArgumentException: Line xx is out of range for file IService.cs. File has xx lines

ERROR: Error during SonarScanner execution java.lang.IllegalArgumentException: Line xx is out of range for file IService.cs. File has xx lines

我正在尝试使用 SonarScanner 来扫描和分析我的项目 C# 源代码。我可以毫无错误地构建我所有的项目。我成功地 运行 所有这些命令。

dotnet tool install --global dotnet-sonarscanner

dotnet sonarscanner begin /k:"test" /d:sonar.host.url="http://localhost:9000" /d:sonar.login="token"

dotnet build

但是当我运行下面的最后一个命令时,出现错误

dotnet sonarscanner end /d:sonar.login="51bae4230d438e567f84b8310f129938c73dd3f2"

这是错误信息:

ERROR: Error during SonarScanner execution INFO: ------------------------------------------------------------------------ java.lang.IllegalArgumentException: Line 15 is out of range for file xx/IService.cs. File has 14 lines. at org.sonar.api.utils.Preconditions.checkArgument(Preconditions.java:43) at org.sonar.scanner.DefaultFileLinesContext.checkLineRange(DefaultFileLinesContext.java:63) at org.sonar.scanner.DefaultFileLinesContext.setIntValue(DefaultFileLinesContext.java:56) at org.sonarsource.dotnet.shared.plugins.protobuf.MetricsImporter.consumeFor(MetricsImporter.java:66) at org.sonarsource.dotnet.shared.plugins.protobuf.MetricsImporter.consumeFor(MetricsImporter.java:38) at org.sonarsource.dotnet.shared.plugins.protobuf.ProtobufImporter.consume(ProtobufImporter.java:73) at org.sonarsource.dotnet.shared.plugins.protobuf.RawProtobufImporter.accept(RawProtobufImporter.java:49) at org.sonarsource.dotnet.shared.plugins.ProtobufDataImporter.parseProtobuf(ProtobufDataImporter.java:97) at org.sonarsource.dotnet.shared.plugins.ProtobufDataImporter.importResults(ProtobufDataImporter.java:72) at org.sonarsource.dotnet.shared.plugins.DotNetSensor.importResults(DotNetSensor.java:101) at org.sonarsource.dotnet.shared.plugins.DotNetSensor.execute(DotNetSensor.java:81) at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48) at org.sonar.scanner.sensor.ProjectSensorsExecutor.execute(ProjectSensorsExecutor.java:49) at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:360) at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137) at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123) at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:150) at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137) at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123) at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72) at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66) at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) 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:189) at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138) 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 SonarScanner did not complete successfully 14:43:25.558 Post-processing failed. Exit code: 1

我去查看了IService.cs,是14行,没发现问题。事实上,如前所述,我可以毫无错误地构建我的所有项目。

这是我能找到的最相似的问题:

SonarQube analyses issue Line is out of range for

基本上你是在寻找文件中的任何隐藏字符