1:部門上司想看代碼品質情況,怎麼辦?找工具啊 Sonar,https://www.sonarqube.org
2:電腦:mac
環境:java:1.8
mysql:Server version: 5.7.20 MySQL Community Server (GPL)
建立資料庫 sonar 和 使用者sonar :
CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER ‘sonar’ IDENTIFIED BY ‘sonar’;
GRANT ALL ON sonar.* TO ‘sonar’@’%’ IDENTIFIED BY ‘sonar’;
GRANT ALL ON sonar.* TO ‘sonar’@’localhost’ IDENTIFIED BY ‘sonar’;
FLUSH PRIVILEGES;
sonar:sonar–runer:
https://pan.baidu.com/s/1i4NYSW9 提取碼:ja37
檔案放置在/usr/local 下 并配置相應的環境變量:
完成後配置bin環境變量PATH~
3: 修改sonarQube 下的配置檔案:sonar.properties配置檔案/usr/local/sonar/conf/sonar.properties
配置資料庫登陸賬号密碼
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
sonar-runner配置:sonar-runner.properties配置檔案/usr/local/sonar-runner/conf/sonar-runner.properties。
onar.host.url=http://localhost:9000
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
sonar.sourceEncoding=UTF-8
sonar.login=admin
sonar.password=admin
以上3:如果自己下載下傳需要自己手動的配置,假如下載下傳我的網盤資料完全不用,隻需要修改配置即可
4:進入sonarqube: /usr/local/sonar/bin/macosx-universal-64/
sudo ./sonar.sh start 啟動sonar。在浏覽器打開localhost:9000檢視
5: 使用Homebrew來安裝xctool、oclint、gcovr。
brew install xctool
brew tap oclint/formulae
brew install oclint
brew install gcovr
注意使用過程中,可能存在指令找不到的情況,假如存在選擇手動下載下傳配置環境變量
6: https://github.com/zgbilltalent/runtimedemo 示例代碼
參考網址:http://www.jianshu.com/p/6b61783b9a38
7: oclint: error: one compiler command contains multiple jobs:
請參考網址:http://www.jianshu.com/p/4f505e92d557 在示例代碼中已經做了更新
8:還有 root 使用者問題,估計版本有問題,還有就是資料庫啟動有問題,配置有問題,
看看成果: