Oclint is a powerful static code analysis tool that can be used to improve code quality, find potential bugs, and focus on static analysis of c,c++ and Objective-c.
Sonar is an open platform for code quality management. Through the plug-in mechanism, Sonar can integrate different test tools, code analysis tools, and continuous integration tools.
Sonarqube Installation
Sonarqube of Chinese
Chinese-Typed plugin
Https://github.com/SonarQubeCommunity/sonar-l10n-zh
After downloading, put in the following directory:
| 1 |
/usr/local/cellar/sonarqube/6.5/libexec/extensions/plugins |
MySQL Installation
Create a Sonar database
Configuring sonar to connect to MySQL
| 123456 |
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useunicode=true&characterencoding=utf8& Rewritebatchedstatements=true&useconfigs=maxperformance&usessl=falsesonar.jdbc.username= Rootsonar.jdbc.password=rootsonar.sorceencoding=utf-8sonar.login=adminsonar.password=admin |
Installing Xcpretty
Installing Oclint
| 12 |
Brew Tap Oclint/formulabrew Install Oclint |
Installing Sonar-scanner
| 1 |
Brew Install Sonar-scanner |
Installing Sonar-objective-c-plugin
Backelite-sonar-objective-c-plugin-0.6.2.jar
After downloading, put in the following directory:
| 1 |
/usr/local/cellar/sonarqube/6.5/libexec/extensions/plugins |
Restart Sonar
To this sonar environment has been basically configured, open http://127.0.0.1:9000
Project configuration
Place run-sonar.sh and sonar-project.properties template in the root directory, modify .properties the contents of the file, and then execute run-sonar.sh it. File Address Https://github.com/LeoXu92/SonarShell-iOS
Final effect
(Ps. The accumulation of technical debt is much more, it is time to change.) )
The problem encountered when executing Sonar-scanner prompt "The rule ' XXX ' does not exist"
In the new version of Oclint, there are additional rules that need to update the corresponding list of rules on the sonar server.
Download the HTTPS://GITHUB.COM/LEOXU92/SONAR-OBJECTIVE-C code first.
And then after the path: Sonar-objective-c-develop/sonar-objective-c-plugin/src/main/resources/org/sonar/plugins/oclint under the profile-oclint.xml rules.txtthese two files. Add the corresponding rule.
build-and-deploy.shThe new jar package is then compiled and executed.
If you can't start Sonarqube
Remove the folder restart and try sonarqube/6.7.1/libexec/temp again.
Using Oclint and sonar for iOS code analysis and quality management