SonarQube扫描程序执行期间出错 - 非法参数异常

时间:2016-11-14 14:59:43

标签: msbuild sonarqube

我安装了SonarQube 6.1和MSBuild.SonarQube.Runner-2.2.0.24来分析C#解决方案。当我运行分析时,我收到以下错误:

  

警告:SCM提供程序自动检测失败。没有SCM提供商声称   支持这个项目。请使用sonar.scm.provider来定义SCM   你的项目。   错误:SonarQube扫描程序执行期间出错   java.lang.IllegalArgumentException:开始指针[line = 90,   lineOffset = 89]应该在结束指针之前[line = 90,lineOffset = 89]   在   org.sonar.api.internal.google.common.base.Preconditions.checkArgument(Preconditions.java:145)   在   org.sonar.api.batch.fs.internal.DefaultInputFile.newRangeValidPointers(DefaultInputFile.java:254)   在   org.sonar.api.batch.fs.internal.DefaultInputFile.newRange(DefaultInputFile.java:238)   在   org.sonarsource.dotnet.shared.plugins.AbstractSensor $ SarifParserCallbackImplementation.onIssue(AbstractSensor.java:144)   在   org.sonarsource.dotnet.shared.sarif.SarifParser01And04.handleAnalysisTargetElement(SarifParser01And04.java:109)   在   org.sonarsource.dotnet.shared.sarif.SarifParser01And04.handleIssue(SarifParser01And04.java:73)   在   org.sonarsource.dotnet.shared.sarif.SarifParser01And04.handleIssues(SarifParser01And04.java:55)   在   org.sonarsource.dotnet.shared.sarif.SarifParser01And04.parse(SarifParser01And04.java:43)   在   org.sonar.plugins.csharp.CSharpSensor.importRoslynReport(CSharpSensor.java:183)   在   org.sonar.plugins.csharp.CSharpSensor.executeInternal(CSharpSensor.java:118)   在org.sonar.plugins.csharp.CSharpSensor.execute(CSharpSensor.java:85)   在   org.sonar.scanner.sensor.SensorWrapper.analyse(SensorWrapper.java:53)   在   org.sonar.scanner.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:57)   在   org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:49)   在   org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:78)   在   org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:182)   在   org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)   在   org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)   在   org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:247)   在   org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:242)   在   org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:240)   在   org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:232)   在   org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)   在   org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)   在org.sonar.scanner.task.ScanTask.execute(ScanTask.java:47)at   org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:86)   在   org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)   在   org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)   在   org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:115)   在org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:118)at   org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:62)   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at   sun.reflect.NativeMethodAccessorImpl.invoke(未知来源)at   sun.reflect.DelegatingMethodAccessorImpl.invoke(未知来源)at   java.lang.reflect.Method.invoke(未知来源)at   org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)   在com.sun.proxy。$ Proxy0.execute(未知来源)at   org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:233)   在   org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151)   在org.sonarsource.scanner.cli.Main.runAnalysis(Main.java:110)at   org.sonarsource.scanner.cli.Main.execute(Main.java:74)at   org.sonarsource.scanner.cli.Main.main(Main.java:61)错误:错误:   使用-X开关重新运行SonarQube扫描仪以启用完全调试   日志记录。 SonarQube扫描仪未成功完成   08:42:09.074后处理失败退出代码:1

当我使用-X启动SonarQube扫描仪时,错误消息中建议使用它,我得到了这个:

2016-11-14T14:33:27.2720044Z ##[error]15:33:27.238  Unrecognized command line argument: -X
2016-11-14T14:33:27.2720044Z ##[error]15:33:27.261  Expecting at least the following command line argument:
2016-11-14T14:33:27.2730045Z ##[error]- SonarQube project key
2016-11-14T14:33:27.2730045Z ##[error]When connecting to a SonarQube server earlier than version 6.1, the following command line arguments are also required:
2016-11-14T14:33:27.2740046Z ##[error]- SonarQube project name
2016-11-14T14:33:27.2740046Z ##[error]- SonarQube project version
2016-11-14T14:33:27.2750047Z ##[error]The full path to a settings file can also be supplied. If it is not supplied, the exe will attempt to locate a default settings file in the same directory as the SonarQube Scanner for MSBuild.
2016-11-14T14:33:27.2750047Z ##[error]15:33:27.261  Pre-processing failed. Exit code: 1

我用以下方式启动扫描仪:

SonarQube.Scanner.MSBuild.exe begin /k:ProjectKey /n:ProjectName /v:4.0.70 

结束命令是

SonarQube.Scanner.MSBuild.exe end

开始在结束前被默认调用。 可能有什么不对?

2 个答案:

答案 0 :(得分:1)

我遇到了同样的麻烦,可能是因为没有UTF-8或支持BOM的UTF-8编码,请参阅此处参考:

Analysis of Visual Studio Solutions containing some C# source files using a non UTF-8 encoding fails

作为可能的WA等待修复,尝试强制源编码为UTF-8,如果还不够,则将源显式转换为无BOM的UTF-8编码。

答案 1 :(得分:0)

我遇到同样的问题,我在代码源中发现了一些问题。

    public class Myclass : BaseClass
    {
        public Myclass(OtherClass inputs) : base() => Initialize(); //OK 

        public Myclass(OtherClass inputs) : base() => Initialize(inputs); //NOK
        //Sonar cannot analyze this method because of arguments insides Initiliaze  //method with inline method only when I use : base(...) => Func(With Arguments);
         //Solution is

        public Myclass(OtherClass inputs) : base() 
        {
           Initialize(inputs);} 
        }
    }