错误 - Sonar无法分析文件

时间:2013-11-27 09:41:40

标签: sonarqube

在使用声纳分析CSharp项目时出现此错误。构建成功..但这些错误看起来并不好。造成这种错误的原因是什么。

[WARN] [02:29:08.248] Unknown char: "»" (FisrtFile.cs:1:2)
[WARN] [02:29:08.248] Unknown char: "¿" (FisrtFile.cs:1:3)
[ERROR] [02:29:08.286] Sonar is unable to analyze file : 'F:\jenkins\workspace\sonar-ProjectA-1\ProjectA\ProjectA\DSService\FisrtFile.cs'
com.sonar.sslr.A.E: ------
-->   using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Runtime.InteropServices;
    5 using System.Text;
    7 namespace
------
Expected : <EXTERN type> but was : <ï [IDENTIFIER]> ('FisrtFile.cs': Line 1 / Column 0)
  at externAliasDirective := EXTERN alias IDENTIFIER SEMICOLON

    at com.sonar.sslr.A.F.B(Unknown Source) ~[sonar-csharp-squid-plugin-1.0.jar:na]
    at com.sonar.sslr.A.F.A(Unknown Source) ~[sonar-csharp-squid-plugin-1.0.jar:na]
    at com.sonar.csharp.squid.scanner.CSharpAstScanner.A(Unknown Source) [sonar-csharp-squid-plugin-1.0.jar:na]
    at com.sonar.csharp.squid.scanner.CSharpAstScanner.scanFiles(Unknown Source) [sonar-csharp-squid-plugin-1.0.jar:na]
    at com.sonar.plugins.csharp.squid.C.analyse(Unknown Source) [sonar-csharp-squid-plugin-1.0.jar:na]
    at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:70) [sonar-batch-3.5.1.jar:na]
    at org.sonar.batch.phases.Phases.execute(Phases.java:101) [sonar-batch-3.5.1.jar:na]
    at org.sonar.batch.scan.ScanContainer.doStart(ScanContainer.java:147) [sonar-batch-3.5.1.jar:na]
    at org.sonar.batch.bootstrap.Container.start(Container.java:72) [sonar-batch-3.5.1.jar:na]
    at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:65) [sonar-batch-3.5.1.jar:na]
    at org.sonar.batch.scan.ScanTask.scanRecursively(ScanTask.java:56) [sonar-batch-3.5.1.jar:na]
    at org.sonar.batch.scan.ScanTask.scanRecursively(ScanTask.java:54) [sonar-batch-3.5.1.jar:na]
    at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:49) [sonar-batch-3.5.1.jar:na]
    at org.sonar.batch.bootstrap.TaskContainer.doStart(TaskContainer.java:188) [sonar-batch-3.5.1.jar:na]
    at org.sonar.batch.bootstrap.Container.start(Container.java:72) [sonar-batch-3.5.1.jar:na]
    at org.sonar.batch.bootstrap.TaskBootstrapContainer.executeTask(TaskBootstrapContainer.java:73) [sonar-batch-3.5.1.jar:na]
    at org.sonar.batch.bootstrap.TaskBootstrapContainer.doStart(TaskBootstrapContainer.java:62) [sonar-batch-3.5.1.jar:na]
    at org.sonar.batch.bootstrap.Container.start(Container.java:72) [sonar-batch-3.5.1.jar:na]
    at org.sonar.batch.bootstrap.BootstrapContainer.doStart(BootstrapContainer.java:104) [sonar-batch-3.5.1.jar:na]
    at org.sonar.batch.bootstrap.Container.start(Container.java:72) [sonar-batch-3.5.1.jar:na]
    at org.sonar.batch.bootstrapper.Batch.startBatch(Batch.java:88) [sonar-batch-3.5.1.jar:na]
    at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:72) [sonar-batch-3.5.1.jar:na]
    at org.sonar.maven.SonarMojo.execute(SonarMojo.java:150) [sonar-maven-plugin-3.5.1.jar:na]
    at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490) [maven-2.2.1-uber.jar:2.2.1]
    at org.codehaus.mojo.sonar.Bootstraper.executeMojo(Bootstraper.java:98) [sonar-maven-plugin-1.0-beta-2.jar:na]
    at org.codehaus.mojo.sonar.Bootstraper.start(Bootstraper.java:79) [sonar-maven-plugin-1.0-beta-2.jar:na]
    at org.codehaus.mojo.sonar.SonarMojo.execute(SonarMojo.java:88) [sonar-maven-plugin-1.0-beta-2.jar:na]
    at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490) [maven-2.2.1-uber.jar:2.2.1]
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694) [maven-2.2.1-uber.jar:2.2.1]
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569) [maven-2.2.1-uber.jar:2.2.1]
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539) [maven-2.2.1-uber.jar:2.2.1]
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387) [maven-2.2.1-uber.jar:2.2.1]
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:284) [maven-2.2.1-uber.jar:2.2.1]
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180) [maven-2.2.1-uber.jar:2.2.1]
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328) [maven-2.2.1-uber.jar:2.2.1]
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138) [maven-2.2.1-uber.jar:2.2.1]
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:362) [maven-2.2.1-uber.jar:2.2.1]
    at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60) [maven-2.2.1-uber.jar:2.2.1]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.6.0_21-ea]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[na:1.6.0_21-ea]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[na:1.6.0_21-ea]
    at java.lang.reflect.Method.invoke(Method.java:597) ~[na:1.6.0_21-ea]
    at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315) [classworlds-1.1.jar:1.1]
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255) [classworlds-1.1.jar:1.1]
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430) [classworlds-1.1.jar:1.1]
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375) [classworlds-1.1.jar:1.1]

我是声纳GUI,在组件视图中我可以看到这个文件。但它没有任何指标值。没有行,代码行,covegare,规则合规性等。

请帮我解决这个问题。

1 个答案:

答案 0 :(得分:2)

您应使用"sonar.sourceEncoding" property

为源文件设置正确的编码

例如,在您的情况下,将其放在sonar-project.properties文件中:

sonar.sourceEncoding=UTF-8