sonarqube mysql mac_SonarQube安装/使用 on Mac环境

准备工作

JDK (忽略)

Mysql (忽略)

SonarQubehttps://www.sonarqube.org/downloads/

Sonar-Scannerhttps://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner

Notes:

下载Community Edition 版本的SonarQube, 因为它是Free & Open Source

安装

1. 下载SonarQube之后,打开bin目录下的对应OS文件夹cd /Users/cli/tool/sonarqube-7.6/bin/macosx-universal-64

[cli@cli-mac:macosx-universal-64] sh sonar.sh start

Starting SonarQube...

Started SonarQube.

3. 配置

3.1 打开mysql, 并创建数据库,数据库名称可以任意指定,这里以数据库名为sonar来举例CREATE DATABASE IF NOT EXISTS sonar;

3.2 进入SonarQube安装目录,并编辑conf下的sonar.properties文件cd /Users/cli/tool/sonarqube-7.6/conf

在sonar.properties文件中mysql下添加如下信息sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false

sonar.jdbc.username=root

sonar.jdbc.password=root

sonar.sorceEncoding=UTF-8

sonar.login=admin

sonar.password=admin

sonar.jdbc.url是你的mysql数据库连接url,sonar.jdbc.username是mysql数据库用户名,sonar.jdbc.password是数据库用户密码,sonar.login是SonarQube的登录用户名,sonar.password是SonarQube的登录密码。

3.3 重启SonarQube服务ccli@ccli-mac:macosx-universal-64$ sh sonar.sh restart

Stopping SonarQube...

Waiting for SonarQube to exit...

Stopped SonarQube.

Starting SonarQube.

3.4 打开浏览器,再次访问SonarQube:http://localhost:9000,会稍微有点慢,因为需要初始化SonarQube数据库

e7837c8c3b7c?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

4 安装sonar scanner1. brew install sonar-scanner

2. 应用准备工作中下载的binary  路径为 /Users/cli/tool/sonar-scanner-3.3.0.1492-macosx/bin

export PATH=/Users/cli/tool/sonar-scanner-3.3.0.1492-macosx/bin:$PATH

5.  在你想要分析的code 路径下添加配置文件sonar-project.properties ,配置文件内容如下#----- Default SonarQube server

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

# must be unique in a given SonarQube instance

sonar.projectKey=api_transaction

# this is the name and version displayed in the SonarQube UI.

sonar.projectName=api_transaction

sonar.projectVersion=1.0

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

# This property is optional if sonar.modules is set.

sonar.sources=.

# Encoding of the source code. Default is default system encoding

#sonar.sourceEncoding=UTF-8

sonar.exclusions=**/*_test.go,**/proto/**

sonar.go.coverage.reportPaths=report/cover-all.cov

sonar.go.golint.reportPaths=report/golint-report.out

6. 运行sonar-scanner[cli@cli-mac:transaction$] sonar-scanner

运行最后,会出现这种信息表示成功

e7837c8c3b7c?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

7. click http://localhost:9000/, 选中Projects -> All -> 你的项目名,比如api_transaction, 会出现这个页面

e7837c8c3b7c?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

然后,你可以Click Code Smells上的6, 可以发现code不合适之处,按照提示进行修正,其它比如Duplications也是类似

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值