SonarQube 未更新报告 - "Line 5 is out of range for file Program.cs. File has 4 lines"
SonarQube Not Updating Report - "Line 5 is out of range for file Program.cs. File has 4 lines"
我创建了一个只有 1 个文件的 .NET Core 应用程序 - Program.cs
它只是从 1-100
打印
for (var i = 1; i <= 100; i++)
{
try
{
Console.WriteLine(i);
}
catch (Exception)
{
throw new Exception("This is a sample exception");
}
}
我还在本地设置了 SonarQube,运行 我第一次使用命令进行扫描
dotnet sonarscanner end /d:sonar.login="<TOKEN>"
它很成功,我收到了 CodeSmells 的报告(我有意识地用它们来测试 SonarCube)
但是一旦我更正了代码并重新 运行 命令,我就收到了来自声纳扫描仪的磨损错误。可能是什么原因?
ERROR: Error during SonarScanner execution
java.lang.IllegalArgumentException: Line 5 is out of range for file Program.cs. File has 4 lines.
来自https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-msbuild/:
Build
Between the begin and end steps, you need to build your project, execute tests and generate code coverage data. This part is specific to your needs and it is not detailed here.
所以,
dotnet sonarscanner end /d:sonar.login="<TOKEN>"
还不够,我们必须:
dotnet sonarscanner begin /k:"project-key" /d:sonar.login="<token>"
dotnet build <path to solution.sln>
dotnet sonarscanner end /d:sonar.login="<TOKEN>"
.
我创建了一个只有 1 个文件的 .NET Core 应用程序 - Program.cs
它只是从 1-100
打印for (var i = 1; i <= 100; i++)
{
try
{
Console.WriteLine(i);
}
catch (Exception)
{
throw new Exception("This is a sample exception");
}
}
我还在本地设置了 SonarQube,运行 我第一次使用命令进行扫描
dotnet sonarscanner end /d:sonar.login="<TOKEN>"
它很成功,我收到了 CodeSmells 的报告(我有意识地用它们来测试 SonarCube)
但是一旦我更正了代码并重新 运行 命令,我就收到了来自声纳扫描仪的磨损错误。可能是什么原因?
ERROR: Error during SonarScanner execution
java.lang.IllegalArgumentException: Line 5 is out of range for file Program.cs. File has 4 lines.
来自https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-msbuild/:
Build
Between the begin and end steps, you need to build your project, execute tests and generate code coverage data. This part is specific to your needs and it is not detailed here.
所以,
dotnet sonarscanner end /d:sonar.login="<TOKEN>"
还不够,我们必须:
dotnet sonarscanner begin /k:"project-key" /d:sonar.login="<token>"
dotnet build <path to solution.sln>
dotnet sonarscanner end /d:sonar.login="<TOKEN>"
.