似乎价值元组打破了SonarC#代码分析器

时间:2017-04-27 14:14:04

标签: sonarqube c#-6.0 valuetuple

我正在尝试使用新的ValueTuple语言功能。虽然它在构建和测试中工作正常,但当SonarC#尝试分析代码时,我收到以下错误:

ERROR: Error during SonarQube Scanner execution
    java.lang.IllegalArgumentException: Start pointer [line=21, lineOffset=36] should be before end pointer [line=21, lineOffset=36]
    at org.sonar.api.internal.google.common.base.Preconditions.checkArgument(Preconditions.java:145)
    at org.sonar.api.batch.fs.internal.DefaultInputFile.newRangeValidPointers(DefaultInputFile.java:265)
    at org.sonar.api.batch.fs.internal.DefaultInputFile.newRange(DefaultInputFile.java:203)
    at org.sonarsource.dotnet.shared.plugins.SensorContextUtils.toTextRange(SensorContextUtils.java:41)
    at org.sonarsource.dotnet.shared.plugins.protobuf.SymbolRefsImporter.consumeFor(SymbolRefsImporter.java:46)
    at org.sonarsource.dotnet.shared.plugins.protobuf.SymbolRefsImporter.consumeFor(SymbolRefsImporter.java:32)
    at org.sonarsource.dotnet.shared.plugins.protobuf.ProtobufImporter.consume(ProtobufImporter.java:49)
    at org.sonarsource.dotnet.shared.plugins.protobuf.RawProtobufImporter.accept(RawProtobufImporter.java:43)
    at org.sonarsource.dotnet.shared.plugins.AbstractSensor.parseProtobuf(AbstractSensor.java:94)
    at org.sonarsource.dotnet.shared.plugins.AbstractSensor.importResults(AbstractSensor.java:87)
    at org.sonar.plugins.csharp.CSharpSensor.executeInternal(CSharpSensor.java:119)
    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:74)
    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(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: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)

我使用以下代码作为测试:

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine("Hello World Test");
        var tuple = gettuple("bob");
        string active = tuple.active ? "Active" : "Inactive";
        Console.WriteLine($"Hello {tuple.name} your id is {tuple.id} and you are {active}");

        Console.ReadLine();
    }

    private static (string name,int id,bool active) gettuple(string name)
    {
        return (name, name.GetHashCode(), true);
    }
}

0 个答案:

没有答案