SonarQube C# 分析失败“不是指针的有效行偏移" [英] SonarQube C# Analysis Fails to 'Not a Valid Line Offset for Pointer'

查看:38
本文介绍了SonarQube C# 分析失败“不是指针的有效行偏移"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 SonarQube 成功分析了一段时间的项目,但现在我遇到了一些错误.确切的错误是:

I have projects that I've been analysing with SonarQube succesfully for a while, but now I'm having some errors. The exact error is:

12:26:01.413 ERROR: Error during SonarQube Scanner execution
java.lang.IllegalArgumentException: 74 is not a valid line offset for pointer. File [blaablaablaa...] has 70 character(s) at line 118
    at org.sonar.api.internal.google.common.base.Preconditions.checkArgument(Preconditions.java:145)
    at org.sonar.api.batch.fs.internal.DefaultInputFile.checkValid(DefaultInputFile.java:252)
    at org.sonar.api.batch.fs.internal.DefaultInputFile.newPointer(DefaultInputFile.java:186)
    at org.sonar.api.batch.fs.internal.DefaultInputFile.newRange(DefaultInputFile.java:202)
    at org.sonarsource.dotnet.shared.plugins.AbstractSensor$SarifParserCallbackImplementation.onIssue(AbstractSensor.java:160)
    at org.sonarsource.dotnet.shared.sarif.SarifParser10.handleResultFileElement(SarifParser10.java:130)
    at org.sonarsource.dotnet.shared.sarif.SarifParser10.handleLocationsElement(SarifParser10.java:102)
    at org.sonarsource.dotnet.shared.sarif.SarifParser10.handleIssue(SarifParser10.java:73)
    at org.sonarsource.dotnet.shared.sarif.SarifParser10.handleIssues(SarifParser10.java:62)
    at org.sonarsource.dotnet.shared.sarif.SarifParser10.accept(SarifParser10.java:54)
    at org.sonarsource.dotnet.shared.sarif.SarifParser10.accept(SarifParser10.java:37)
    at org.sonar.plugins.csharp.CSharpSensor.importRoslynReport(CSharpSensor.java:188)
    at org.sonar.plugins.csharp.CSharpSensor.executeInternal(CSharpSensor.java:123)
    at org.sonar.plugins.csharp.CSharpSensor.execute(CSharpSensor.java:79)
    at org.sonar.scanner.sensor.SensorWrapper.analyse(SensorWrapper.java:53)
    at org.sonar.scanner.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:57)
    at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:49)
    at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:78)
    at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:175)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:143)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:128)
    at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:262)
    at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:257)
    at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:255)
    at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:247)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:143)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:128)
    at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:47)
    at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:86)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:143)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:128)
    at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:118)
    at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:117)
    at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:63)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
12:26:01.419 DEBUG: Execution getVersion
12:26:01.420 DEBUG: Execution stop
    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:233)
    at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151)
    at org.sonarsource.scanner.cli.Main.runAnalysis(Main.java:123)
    at org.sonarsource.scanner.cli.Main.execute(Main.java:77)
    at org.sonarsource.scanner.cli.Main.main(Main.java:61)

我已将 C# 分析器更新到最新版本(已安装 5.10.1 (build 1411)).至少更新中心不提供更新的?

I have updated the C# analyzer to the latest (5.10.1 (build 1411) installed). At least the update center doesn't provide a newer?

我还将扫描仪更新为 sonar-scanner-msbuild-2.3.2.573

我正在使用 SQ 6.3.1.21392

在 SO 中有很多类似的帖子,但它们都很旧,他们认为这要么是分析器中的已知错误,要么是编码问题.我尝试将问题文件编码更改为纯 UTF-8,但这并不能解决问题.Notepad++ 显示编码为 UTF-8-BOM.我也使用了 bomremover,但这根本不会改变错误.

There are quite a few similar posts here in SO, but all of them are pretty old and they suggest that it's either a known bug in the analyzer or an encoding issue. I've tried to change the problem file encoding to plain UTF-8, but that doesn't resolve the issue. Notepad++ shows the encoding is UTF-8-BOM. I've also used the bomremover, but that doesn't change the error at all.

除了从分析中排除所有问题文件之外,还有什么建议可以尝试吗?

Any suggestions what to try except to exclude all the problem files from the analyse?

编辑
该文件的编码是 UTF-8-BOM,但将其转换为纯 UTF-8 没有区别.

EDIT
The encoding of the file is UTF-8-BOM, but it makes no difference to convert it to plain UTF-8.

我使用 Notepad++ 转换为 UTF-8 并重新运行分析.结果相同的错误,这是新编码的屏幕截图:

I used Notepad++ convert to UTF-8 and re-run the analysis. Same error as a result and here's a screenshot of the new encoding:

推荐答案

通过重新克隆 repo 并再次运行分析解决了该问题.问题的根本原因仍然未知.

The issue was resolved by re-cloning the repo and running the analysis again. The root cause of the problem remains unknown.

如果您遇到同样的问题,请尝试通过将 repo 克隆到其他位置或将文件内容复制粘贴到新创建的文件中来重新创建文件.

If you are having the same issue, try to re-create the file again by either cloning the repo to different location or by copy-paste the file contents inside newly created file.

这篇关于SonarQube C# 分析失败“不是指针的有效行偏移"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆