SonarQube 分析问题 Line is out of range for [英] SonarQube analyses issue Line is out of range for

查看:90
本文介绍了SonarQube 分析问题 Line is out of range for的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行 SonarQube 的本地实例并使用默认 SonarC# 插件执行 Xamarin.Forms 项目,该插件使用 SonarQube Scanner for MSBuild 进行分析.以下是我收到的错误:

I am running a local instance of SonarQube and executed a Xamarin.Forms project using default SonarC# plugin analyzed using SonarQube Scanner for MSBuild. Below is the error i am getting:

错误:SonarQube 扫描仪执行期间出错

ERROR: Error during SonarQube Scanner execution

错误:第 736 行超出文件/xxxx.cs 的范围.文件有 735 行.

ERROR: Line 736 is out of range for file /xxxx.cs. File has 735 lines.

错误:SonarQube 扫描仪未成功完成

ERROR: The SonarQube Scanner did not complete successfully

09:26:04.772 创建摘要 Markdown 文件...

09:26:04.772 Creating a summary markdown file...

09:26:04.78 后处理失败.退出代码:1

09:26:04.78 Post-processing failed. Exit code: 1

我在 SonarCloud 上执行时也遇到了同样的问题.

环境详情:

SonarQube:7.4

SonarQube: 7.4

用于 MSBuild 4.4.2 的 SonarScanner

SonarScanner for MSBuild 4.4.2

SonarQube 扫描仪 3.2.0.1227

SonarQube Scanner 3.2.0.1227

Java 1.8.0_131 Oracle Corporation(64 位)

Java 1.8.0_131 Oracle Corporation (64-bit)

Mac OS X 10.13.6 x86_64

Mac OS X 10.13.6 x86_64

声纳扫描仪命令:

  1. mono/SonarScanner.MSBuild.exe 开始/k:"ProjectKey"/d:sonar.host.url="url"/d:sonar.login="token"

  1. mono /SonarScanner.MSBuild.exe begin /k:"ProjectKey" /d:sonar.host.url="url" /d:sonar.login="token"

MSbuild/t:rebuild

MSbuild /t:rebuild

mono/SonarScanner.MSBuild.exe end/d:sonar.login="token"

mono /SonarScanner.MSBuild.exe end /d:sonar.login="token"

日志:

SonarScanner for MSBuild 4.4.2
Using the .NET Framework version of the Scanner for MSBuild
Default properties file was found at <SonarScanner Path>/SonarQube.Analysis.xml
Loading analysis properties from <SonarScanner Path>/SonarQube.Analysis.xml
Post-processing started.
SONAR_SCANNER_OPTS is not configured. Setting it to the default value of -Xmx1024m
Calling the SonarQube Scanner...
INFO: Scanner configuration file: <Path>sonar-scanner.properties
INFO: Project root configuration file: <Path>/.sonarqube/out/sonar-project.properties
INFO: SonarQube Scanner 3.2.0.1227
INFO: Java 1.8.0_131 Oracle Corporation (64-bit)
INFO: Mac OS X 10.13.6 x86_64
INFO: SONAR_SCANNER_OPTS=-Xmx1024m
INFO: User cache: xxxx
INFO: SonarQube server 7.4.0
INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Publish mode
INFO: Load global settings
INFO: Load global settings (done) | time=53ms
INFO: Server id: xxxxx
INFO: User cache: xxxxx
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=32ms
INFO: Load/download plugins (done) | time=51ms
INFO: Loaded core extensions: 
INFO: Process project properties
INFO: Load project repositories
INFO: Load project repositories (done) | time=89ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=52ms
INFO: Load active rules
INFO: Load active rules (done) | time=811ms
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=15ms
INFO: Project key: xxxxx
INFO: Project base dir: ….
INFO: -------------  Scan xxxx
INFO: Base dir: …
INFO: Working dir: ……
INFO: Source encoding: UTF-8, default locale: en_US
INFO: Load server rules
INFO: Load server rules (done) | time=227ms
INFO: Index files
INFO: 160 files indexed
INFO: Quality profile for cs: Sonar way
INFO: Quality profile for xml: Sonar way
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=6ms
INFO: Sensor C# Properties [csharp]
INFO: Sensor C# Properties [csharp] (done) | time=1ms
INFO: Sensor SonarJavaXmlFileSensor [java]
INFO: 29 source files to be analyzed
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=107ms
INFO: 29/29 source files have been analyzed
INFO: Sensor XML Sensor [xml]
WARNING: WARN: Metric 'comment_lines_data' is deprecated. Provided value is ignored.
INFO: Sensor XML Sensor [xml] (done) | time=277ms
INFO: SCM Publisher is disabled
INFO: -------------  Scan xxxxx
INFO: Base dir: <Path>
INFO: Working dir: <Path>
INFO: Source paths: ……
INFO: Source encoding: UTF-8, default locale: en_US
INFO: Index files
INFO: 291 files indexed
INFO: Quality profile for cs: Sonar way
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=1ms
INFO: Sensor C# Properties [csharp]
INFO: Sensor C# Properties [csharp] (done) | time=0ms
INFO: Sensor SonarJavaXmlFileSensor [java]
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=1ms
INFO: SCM Publisher is disabled
INFO: -------------  Scan xxxxx
INFO: Base dir: <Path>
INFO: Working dir: <Path>
INFO: Source paths: …….
INFO: Source encoding: UTF-8, default locale: en_US
INFO: Index files
INFO: 112 files indexed
INFO: Quality profile for cs: Sonar way
INFO: Quality profile for xml: Sonar way
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=1ms
INFO: Sensor C# Properties [csharp]
INFO: Sensor C# Properties [csharp] (done) | time=0ms
INFO: Sensor SonarJavaXmlFileSensor [java]
INFO: 4 source files to be analyzed
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=14ms
INFO: 4/4 source files have been analyzed
INFO: Sensor XML Sensor [xml]
WARNING: WARN: Metric 'comment_lines_data' is deprecated. Provided value is ignored.
INFO: Sensor XML Sensor [xml] (done) | time=24ms
INFO: SCM Publisher is disabled
INFO: -------------  Scan xxxxx
INFO: Base dir: <Path>
INFO: Working dir: <Path>
INFO: Source paths: …..
INFO: Source encoding: UTF-8, default locale: en_US
INFO: Index files
INFO: 42 files indexed
INFO: Quality profile for cs: Sonar way
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=0ms
INFO: Sensor C# Properties [csharp]
INFO: Sensor C# Properties [csharp] (done) | time=1ms
INFO: Sensor SonarJavaXmlFileSensor [java]
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=0ms
INFO: SCM Publisher is disabled
INFO: -------------  Scan xxxxx
INFO: Base dir: <Path>
INFO: Working dir: <Path>
INFO: Source encoding: UTF-8, default locale: en_US
INFO: Index files
INFO: 0 files indexed
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=0ms
INFO: Sensor SonarJavaXmlFileSensor [java]
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=1ms
INFO: Sensor C# [csharp]
INFO: Importing results from 6 proto files in ‘<Path>/.sonarqube/out/0/output-cs'
INFO: Importing results from 6 proto files in ‘<Path>/.sonarqube/out/1/output-cs'
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 4.903s
INFO: Final Memory: 23M/646M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
ERROR: Line 736 is out of range for file <Path>/xxxxx.cs. File has 735 lines.
ERROR: 
The SonarQube Scanner did not complete successfully
10:03:23.755  Creating a summary markdown file...
10:03:23.763  Post-processing failed. Exit code: 1

推荐答案

就我而言,这是因为 Sonarqube 无法处理的文件编码.通过使用十六进制编辑器检查文件,我看到文件以 00 0d 00 0a 00 结尾.将编码更改为 UTF-8 后,现在以 0d 0a 结尾,Sonarqube 再次工作.

In my case this happend because of a file encoding Sonarqube could not handle. By inspecting the file with a hex editor, I saw that the file ended with 00 0d 00 0a 00. After changing the encoding to UTF-8, it now ends with 0d 0a and Sonarqube works again.

这篇关于SonarQube 分析问题 Line is out of range for的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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