SonarQube

作者: 白敏鸢 | 来源:发表于2018-04-23 20:23 被阅读0次

    是什么?

    SonarQube是管理代码质量一个开放平台,可以快速的定位代码中潜在的或者明显的错误,简单来说就是检查代码质量,找bug的这么一个东西。
    怎么使用

    安装
    1、jdk(不再介绍)
    2、sonarqube:http://www.sonarqube.org/downloads/
    3、SonarQube+Scanner:https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/sonar-scanner-2.5.zip
    4、mysql数据库(不再介绍)
    
    启动
    D:\sonar\sonarqube-5.3\sonarqube-5.3\bin\windows-x86-64\StartSonar.bat
    访问http://localhost:9000
    
    添加mysql配置
    D:\sonar\sonarqube-5.3\sonarqube-5.3\conf\sonar.properties
    在mysql5.X节点下
    sonar.jdbc.url=jdbc:mysql://172.16.30.228:3306/qjfsonar?
    useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
    sonar.jdbc.username=gmsd
    sonar.jdbc.password=gmsdtrade
    sonar.sorceEncoding=UTF-8
    sonar.login=admin
    sonar.password=admin
    
    添加环境变量
    name=SONAR_RUNNER_HOME。value=D:\sonar\sonar-scanner-2.5
    
    添加运行文件
    D:\sonar\sonar-scanner-2.5\conf\sonar-runner.properties
    sonar.jdbc.url=jdbc:mysql://172.16.30.228:3306/qjfsonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
    sonar.jdbc.username=gmsd
    sonar.jdbc.password=gmsdtrade
    
    在代码分析的项目根目录,新建sonar-project.properties
    # must be unique in a given SonarQube instance
    sonar.projectKey=my:project
    # this is the name displayed in the SonarQube UI
    sonar.projectName=apiautocore
    sonar.projectVersion=1.0
    
    # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
    # Since SonarQube 4.2, this property is optional if sonar.modules is set. 
    # If not set, SonarQube starts looking for source code from the directory containing 
    # the sonar-project.properties file.
    sonar.sources=src
    
    # Encoding of the source code. Default is default system encoding
    #sonar.sourceEncoding=UTF-8
    
    启动:
    在cmd进入项目所在的根目录,输入命令:sonar-runner,分析成功后会出现下图
    
    
    image.png

    不错的文章
    https://testerhome.com/topics/8113
    https://www.cnblogs.com/qiumingcheng/p/7253917.html

    遗留的问题

    相关文章

      网友评论

          本文标题:SonarQube

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