Sonar qube没有显示Android Lint的结果

时间:2016-08-08 04:06:02

标签: android android-gradle sonarqube sonarqube-4.5 sonarqube-scan

enter image description here

这是我的build.gradle,

apply plugin: 'org.sonarqube'

sonarqube {

    properties  {

        property "sonar.host.url", "http://10.52.211.255:9000/sonar"

        property "sonar.sources", "src/main/java"

        property "sonar.language", "java"

        property "sonar.profile", "Android Lint"

    }
}

代码适用于

属性" sonar.profile","声纳方式"。

但我需要这个用于Android Lint。获得零结果可能是什么问题。

5 个答案:

答案 0 :(得分:1)

Sonar Lint不会将问题推送到SonarQube服务器。它旨在为开发人员提供有关本地工作区代码的即时反馈。

要在Sonarqube服务器中显示问题,您需要执行声纳分析。 例如,使用声纳扫描仪(以前称为声纳转轮)

答案 1 :(得分:1)

更改您的声纳属性:

apply plugin: "org.sonarqube"

sonarqube {

    properties {

        property "sonar.projectName", "appa"

        property "sonar.projectKey", "appa_app"

        property "sonar.projectVersion", "1.0"

        property "sonar.analysis.mode", "publish"

        property "sonar.language", "java"

        property 'sonar.sourceEncoding', "UTF-8"

        property "sonar.sources", "./src/main"

        //property "sonar.exclusions", "**/*Entity.java"

      //  property "sonar.exclusions", "src/main/java/com/apparkb/model/**, **/*Entity.java"

        property "sonar.host.url", "http://192.168.21.33:9000"

        property "sonar.login", "admin"

        property "sonar.profile", "testlint"

        property 'sonar.import_unknown_files', true

        property "sonar.android.lint.report", "./build/outputs/lint-results-debug.xml"

        property "sonar.password", "admin"

        property "sonar.java.binaries", "build/"



    }
}

要创建lint-results-debug.xml,您必须在studio终端上运行以下命令:

./gradlew lint

它将生成缺少的XML报告。 要小心,它可以为每个构建变体生成一个报告(默认情况下,Debug将生成build / outputs / lint-results-debug.xml)。所以你可以调用lintDebug,lintRelease ...依赖你的构建变体。

并将lint属性更改为:

lintOptions {
        // set to true to turn off analysis progress reporting by lint

        quiet true

        // if true, stop the gradle build if errors are found

        abortOnError false

        // do not ignore warnings

        warningsAsErrors true
    }

现在如果您运行 ./gradlew sonarqube

您会看到结果显示其实际上是在服务器上托管的本地文件报告

a screen shot after analysis

答案 2 :(得分:0)

此代码更改帮助我解决了这个问题。

在Gradle中,

  • 我已经将lint文件添加到我的项目中。
  • 我将lintOptions添加到gardle。
  • 接下来在Gradle中为sonarqube添加了新属性。
Show Profile activity
  • 接下来更改了Jenkins中的一些配置。(请查看图片)

enter image description here

  • 在jenkins中运行声纳之前,命令运行lint。

然后我得到了与Android Lint相关的输出

感谢。

答案 3 :(得分:0)

您必须提到分析模式为发布才能将结果提交到服务器。

属性“ sonar.analysis.mode”,“发布”

答案 4 :(得分:0)

它为我工作,并开始向声纳仪表板报告android lint问题:

我的Sonar版本是7.6.2

在声纳属性中添加以下内容:

property "sonar.androidLint.reportPaths", "${project.buildDir}/reports/lint-results.xml"

经过以上修改后:./gradlew皮棉声纳波克

它将显示在“代码气味”部分中 android:usesCleartextTraffic =“ true” 属性usesCleartextTraffic仅在API级别23和更高级别(当前最小值为21)android-lint中使用

有关如何向声纳仪表板显示外部分析仪报告的更多详细信息,请参阅。

Import third party issues Sonar Documentation检查Kotlin语言

External Analyzer Reports

相关问题