运行时的SonarQube扫描仪错误"声纳扫描仪"命令

时间:2017-10-18 16:07:00

标签: java android sonarqube sonarqube-scan software-quality

我想用sonarQube来分析一个android项目。 当我尝试安装SonarQube扫描仪时,我遇到了一些问题。

从项目目录运行sonar-scanner命令时收到以下错误。

*我已按照此链接https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner

中的安装步骤进行操作

*我正在使用SonarQube 6.5和SonarScanner 3.0.3

    ERROR: Error during SonarQube Scanner execution
  org.sonar.squidbridge.api.AnalysisException: Please provide compiled 
  classes of
  your project with sonar.java.binaries property
    at org.sonar.java.JavaClasspath.init(JavaClasspath.java:59)
    at org.sonar.java.AbstractJavaClasspath.getElements (AbstractJavaClasspath.java:281)
    at org.sonar.java.SonarComponents.getJavaClasspath(SonarComponents.java:
  141)
    at org.sonar.java.JavaSquid.<init>(JavaSquid.java:83)
    at org.sonar.plugins.java.JavaSquidSensor.execute(JavaSquidSensor.java:8
   3)
    at org.sonar.scanner.sensor.SensorWrapper.analyse(SensorWrapper.java:53)

    at org.sonar.scanner.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:88)
    at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java
  :82)
    at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java
 :68)
    at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseE
 xecutor.java:78)
    at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanCon
 tainer.java:179)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentC
ontainer.java:144)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer
    .java:129)
    at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer
.java:261)
    at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectSc
anContainer.java:256)
    at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanC
     ontainer.java:245)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentC
      ontainer.java:144)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer
      .java:129)
    at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:47)
    at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:
       84)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentC
      ontainer.java:144)
    at 



       org.sonar.core.platform.ComponentContainer.execute (ComponentContainerjava:129)
    at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContain
         er.java:119)
    at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:116)
    at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.exec
        ute(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(Iso
        latedLauncherProxy.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(EmbeddedScann
      er.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)
   ERROR:
   ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug 
 logging

如果您有任何解决此问题的方法,请帮助我。

1 个答案:

答案 0 :(得分:0)

您需要在分析之前构建项目。让我们说你的项目结构等于:

public class SocialAuthService
    {
        private SocialConfig SocialConfig { get; set; }

        public SocialAuthService(SocialConfig socialConfig)
        {
            SocialConfig = socialConfig;
        }

        public async Task<User> VerifyTokenAsync(ExternalToken exteralToken)
        {
            switch (exteralToken.Provider)
            {
                case "Facebook":
                    return await VerifyFacebookTokenAsync(exteralToken.Token);
                default:
                    return null;
            }
        }

        private async Task<User> VerifyFacebookTokenAsync(string token)
        {
            var user = new User();
            var client = new HttpClient();

            var verifyTokenEndPoint = string.Format("https://graph.facebook.com/me?access_token={0}&fields=email,name", token);
            var verifyAppEndpoint = string.Format("https://graph.facebook.com/app?access_token={0}", token);

            var uri = new Uri(verifyTokenEndPoint);
            var response = await client.GetAsync(uri);

            if (response.IsSuccessStatusCode)
            {
                var content = await response.Content.ReadAsStringAsync();
                dynamic userObj = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(content);

                uri = new Uri(verifyAppEndpoint);
                response = await client.GetAsync(uri);
                content = await response.Content.ReadAsStringAsync();
                dynamic appObj = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(content);

                if (appObj["id"] == SocialConfig.Facebook.AppId)
                {
                    //token is from our App
                    user.SocialUserId = userObj["id"];
                    user.Email = userObj["email"];
                    user.Name = userObj["name"];
                    user.IsVerified = true;
                }

                return user;
            }
            return user;
        }
    }

然后你应该配置:

project
|- src
|- dependencies
|- classes

阅读详情:Java Plugin and Bytecode