i following this article integrate sonarqube xcode , analyse objective-c code. though setup functional , getting no error/warnings after running shell script, no violations shown in dashboard. see basic metrics no. of lines of code, no. of files, etc. there has tried , guide me further.
in addition article have specified above, have few additions that. can follow steps below,
prerequisites:
- sonar
- sonar-runner
- sonarqube objective-c plugin (licensed)
- xctool
- oclint (violations) , gcovr (code coverage)
- mysql , jdk
installation steps:
- download , install mysql dmg. , start mysql server system preferences or via command line or if restarted has command line.
- to start -
sudo /usr/local/mysql/support-files/mysql.server start
- to restart -
sudo /usr/local/mysql/support-files/mysql.server restart
to stop -
sudo /usr/local/mysql/support-files/mysql.server stop
download , install latest jdk version.
go terminal , enter following commands install prerequisites. (homebrew package management system mac operating system. install homebrew, enter command -
ruby -e "$(curl -fssl https://raw.githubusercontent.com/homebrew/install/master/install)")
sonar -
brew install sonar
- sonar-runner -
brew install sonar-runner
- xctool -
brew install xctool
oclint -
brew install oclint
orbrew install https://gist.githubusercontent.com/tonyanhtran/e1522b93853c5a456b74/raw/157549c7a77261e906fb88bc5606afd8bd727a73/oclint.rb version 0.8.1(updated))
gcovr -
brew install gcovr
configuration:
- set environment path of sonar:
export sonar_home=/usr/local/cellar/sonar-runner/2.4/libexec export sonar=$sonar_home/bin export path=$sonar:$path
finally command echo $sonar_home
should return path - /usr/local/cellar/sonar-runner/2.4/libexec
- set mysql db:
export path=${path}:/usr/local/mysql/bin mysql -u root; create database sonar_firstdb; create user 'sonar'@'localhost' identified 'sonar’; grant privileges on sonar_firstdb.* 'sonar'@'localhost’; flush privileges; exit
- set sonar configuration settings:
vi /usr/local/cellar/sonar/5.1.2/libexec/conf/sonar.properties
you can comment out options except credentials , mysql , make sure enter correct database name.
eg:
sonar.jdbc.url=jdbc:mysql://localhost:3306/**sonar_firstdb**?useunicode=true&characterencoding=utf8&rewritebatchedstatements=true vi /usr/local/cellar/sonar-runner/2.4/libexec/conf/sonar-runner.properties
you can comment out options except credentials , mysql , make sure enter correct database name.
eg:
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar_firstdb?useunicode=true&characterencoding=utf8
start sonar using command -
sonar start
the command launch sonar navigate http://localhost:9000 in browser of choice. login (admin/admin) , have around.
- now have install objective-c or swift plugin.
move settings -> system -> update center -> available plugins (install required plugin).
you have restart sonar complete installation once pligin added, , add license key once plugin installed.
through terminal go root directory of project want sonar inspect, , create project specific properties file following command:
vi sonar-project.properties
add following project specific properties , edit bolded sections per project.
// required configuration sonar.projectkey=**com.payoda.wordsudoku** sonar.projectname=**dragdrop** sonar.projectversion=**1.0** sonar.language=**objc** // project description sonar.projectdescription=**sample description** // path source directories sonar.sources=**~/path project** // path test directories (comment if no test) //sonar.tests=testsrcdir // xcode project configuration (.xcodeproj or .xcworkspace) // -> if have project: configure sonar.objectivec.project // -> if have workspace: configure sonar.objectivec.workspace , sonar.objectivec.project // , use later specify project(s) include in analysis (comma separated list) sonar.objectivec.project=**dragdrop.xcodeproj** // sonar.objectivec.workspace=myapplication.xcworkspace // scheme build application sonar.objectivec.appscheme=**dragdrop** // scheme build , run tests (comment following line of don't have tests) //sonar.objectivec.testscheme=myapplicationtests ///////////////////////// // optional configuration // encoding of source code sonar.sourceencoding=**utf-8** // junit report generated run-sonar.sh stored in sonar-reports/test-report.xml // change if generate file on own // change if generate file on own // xml files have prefixed test- otherwise not processed // sonar.junit.reportspath=sonar-reports/ // cobertura report generated run-sonar.sh stored in sonar-reports/coverage.xml // change if generate file on own // sonar.objectivec.coverage.reportpattern=sonar-reports/coverage*.xml // oclint report generated run-sonar.sh stored in sonar-reports/oclint.xml // change if generate file on own // sonar.objectivec.oclint.report=sonar-reports/oclint.xml // paths exclude coverage report (tests, 3rd party libraries etc.) // sonar.objectivec.excludedpathsfromcoverage=pattern1,pattern2 sonar.objectivec.excludedpathsfromcoverage=.*tests.* // project scm settings // sonar.scm.enabled=true // sonar.scm.url=scm:git:https://...
- save file , can reuse same other projects.
- in project root directory run command -
sonar-runner