美文网首页Android知识Android技术知识Android开发经验谈
使用sonar-runner进行静态代码分析(Android L

使用sonar-runner进行静态代码分析(Android L

作者: _夏兮 | 来源:发表于2017-06-24 13:08 被阅读540次

    一、sonarQube搭建见sonarLint与IntelliJ IDEA 集成

    sonarqube 需要在更新中心下载Andriod

    二、sonar-runer配置

    2.1下载sonar-runner-dist-2.4.zip,解压

    2.2进入conf->sonar-runner.properties

    #Configure here general information about the environment, such as SonarQube DB details for example

    #No information about specific project should appear here

    #----- Default SonarQube server

    sonar.host.url=http://localhost:9000

    #----- PostgreSQL

    #sonar.jdbc.url=jdbc:postgresql://localhost/sonar

    #----- MySQL

    sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8

    #----- Oracle

    #sonar.jdbc.url=jdbc:oracle:thin:@localhost/XE

    #----- Microsoft SQLServer

    #sonar.jdbc.url=jdbc:jtds:sqlserver://localhost/sonar;SelectMethod=Cursor

    #----- Global database settings

    sonar.jdbc.username=root

    sonar.jdbc.password=****

    #----- Default source code encoding

    #sonar.sourceEncoding=UTF-8

    #----- Security (when 'sonar.forceAuthentication' is set to 'true')

    sonar.login=admin

    sonar.password=admin

    2.3 添加环境变量

    添加变量 添加到path

    2.4 验证

    进入dos命令行,执行sonar-runner -v

    三、执行测试

    3.1 项目配置

    sonar-runner.properties

    # Required metadata

    sonar.projectKey=vga

    sonar.projectName=vga

    sonar.projectVersion=1.0

    # Paths to source directories.

    # Paths are relative to the sonar-project.properties file. Replace "\" by "/" on Windows.

    # Do not put the "sonar-project.properties" file in the same directory with the source code.

    # (i.e. never set the "sonar.sources" property to ".")

    sonar.sources=src

    # The value of the property must be the key of the language.

    sonar.language=java

    sonar.sourceEncoding=UTF-8

    sonar.profile=Android Lint

    3.2 执行代码扫描

    进入配置文件目录,打开dos命令行,执行 sonar-runner -X或者sonar-runner -e

    等等出现 execution success

    四、查看结果

    打开 http://localhost:9000

    Home quality code
    扫一扫,关注TestDev

    相关文章

      网友评论

        本文标题:使用sonar-runner进行静态代码分析(Android L

        本文链接:https://www.haomeiwen.com/subject/bcckcxtx.html