Objective c 将Sonarqube与Xcode一起使用
我将在下面的文章中集成SonarQube和Xcode,并分析Objective-C代码。尽管安装程序可以正常运行,并且在运行shell脚本后不会收到任何错误/警告,但仪表板中不会显示任何冲突。我所看到的只是一些基本指标,比如代码行数、文件数等等。 有没有人尝试过这一点,并进一步指导我。Objective c 将Sonarqube与Xcode一起使用,objective-c,xcode,sonarqube,Objective C,Xcode,Sonarqube,我将在下面的文章中集成SonarQube和Xcode,并分析Objective-C代码。尽管安装程序可以正常运行,并且在运行shell脚本后不会收到任何错误/警告,但仪表板中不会显示任何冲突。我所看到的只是一些基本指标,比如代码行数、文件数等等。 有没有人尝试过这一点,并进一步指导我。 您应该使用较旧版本的SonarQube(通常使用系统->更新中心->可用插件(安装所需插件) 添加pligin后,您必须重新启动sonar以完成安装,并在安装插件后添加许可证密钥 通过终端转到要sonar检查的
您应该使用较旧版本的SonarQube(通常使用<4.0)进行尝试。除了您上面指定的文章之外,我没有什么补充。您可以按照以下步骤操作 先决条件:
- 声纳
- 声纳转轮
- SonarQube Objective-C插件(许可)
- XCTool
- OCLint(违规)和gcovr(代码覆盖率)
- MySql和JDK
export SONAR_HOME=/usr/local/Cellar/sonar-runner/2.4/libexec
export SONAR=$SONAR_HOME/bin
export PATH=$SONAR:$PATH
export PATH=${PATH}:/usr/local/mysql/bin
mysql -u root;
CREATE DATABASE sonar_firstdb;
CREATE USER 'sonar'@'localhost' IDENTIFIED BY 'sonar';
GRANT ALL PRIVILEGES ON sonar_firstdb.* TO 'sonar'@'localhost';
FLUSH PRIVILEGES;
exit
vi /usr/local/Cellar/sonar/5.1.2/libexec/conf/sonar.properties
- 下载并安装MySql-dmg。然后从系统首选项或通过命令行启动MySQL服务器,如果重新启动,则必须使用命令行
- 要启动-
sudo/usr/local/mysql/support files/mysql.server启动
- 要重新启动-
sudo/usr/local/mysql/support files/mysql.server restart
- 要停止-
sudo/usr/local/mysql/support files/mysql.server停止
- 下载并安装最新的JDK版本
- 转到终端并输入以下命令以安装
先决条件。(软件包是自制的
Mac操作系统的管理系统。要安装自制软件,请输入以下命令-
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)")
- Sonar-
brew安装Sonar
- Sonar runner-
brew安装Sonar runner
- XCTool-
brew安装XCTool
- OCLint-
或brew安装OCLint
brew install https://gist.githubusercontent.com/TonyAnhTran/e1522b93853c5a456b74/raw/157549c7a77261e906fb88bc5606afd8bd727a73/oclint.rb for version 0.8.1(updated))
- gcovr-
brew安装gcovr
export SONAR_HOME=/usr/local/Cellar/sonar-runner/2.4/libexec
export SONAR=$SONAR_HOME/bin
export PATH=$SONAR:$PATH
export PATH=${PATH}:/usr/local/mysql/bin
mysql -u root;
CREATE DATABASE sonar_firstdb;
CREATE USER 'sonar'@'localhost' IDENTIFIED BY 'sonar';
GRANT ALL PRIVILEGES ON sonar_firstdb.* TO 'sonar'@'localhost';
FLUSH PRIVILEGES;
exit
vi /usr/local/Cellar/sonar/5.1.2/libexec/conf/sonar.properties
-设置声纳的环境路径:
export SONAR_HOME=/usr/local/Cellar/sonar-runner/2.4/libexec
export SONAR=$SONAR_HOME/bin
export PATH=$SONAR:$PATH
export PATH=${PATH}:/usr/local/mysql/bin
mysql -u root;
CREATE DATABASE sonar_firstdb;
CREATE USER 'sonar'@'localhost' IDENTIFIED BY 'sonar';
GRANT ALL PRIVILEGES ON sonar_firstdb.* TO 'sonar'@'localhost';
FLUSH PRIVILEGES;
exit
vi /usr/local/Cellar/sonar/5.1.2/libexec/conf/sonar.properties
最后,命令echo$SONAR\u HOME应该返回路径-/usr/local/ceral/SONAR runner/2.4/libexec
-设置MySql数据库:
export SONAR_HOME=/usr/local/Cellar/sonar-runner/2.4/libexec
export SONAR=$SONAR_HOME/bin
export PATH=$SONAR:$PATH
export PATH=${PATH}:/usr/local/mysql/bin
mysql -u root;
CREATE DATABASE sonar_firstdb;
CREATE USER 'sonar'@'localhost' IDENTIFIED BY 'sonar';
GRANT ALL PRIVILEGES ON sonar_firstdb.* TO 'sonar'@'localhost';
FLUSH PRIVILEGES;
exit
vi /usr/local/Cellar/sonar/5.1.2/libexec/conf/sonar.properties
-设置声纳配置设置:
export SONAR_HOME=/usr/local/Cellar/sonar-runner/2.4/libexec
export SONAR=$SONAR_HOME/bin
export PATH=$SONAR:$PATH
export PATH=${PATH}:/usr/local/mysql/bin
mysql -u root;
CREATE DATABASE sonar_firstdb;
CREATE USER 'sonar'@'localhost' IDENTIFIED BY 'sonar';
GRANT ALL PRIVILEGES ON sonar_firstdb.* TO 'sonar'@'localhost';
FLUSH PRIVILEGES;
exit
vi /usr/local/Cellar/sonar/5.1.2/libexec/conf/sonar.properties
您可以注释掉除凭据和mysql之外的大多数选项,并确保输入正确的数据库名称
例如:
sonar.jdbc.url=jdbc:mysql://localhost:3306/**sonar_firstdb**?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar_firstdb?useUnicode=true&characterEncoding=utf8
。
vi/usr/local/ceral/sonar-runner/2.4/libexec/conf/sonar-runner.properties
您可以注释掉除凭据和mysql之外的大多数选项,并确保输入正确的数据库名称
例如:
sonar.jdbc.url=jdbc:mysql://localhost:3306/**sonar_firstdb**?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar_firstdb?useUnicode=true&characterEncoding=utf8
- 使用命令启动声纳-
sonar start
- 现在您必须安装Objective-C或Swift插件。
- 通过终端转到要sonar检查的项目的根目录,并使用以下命令创建特定于项目的属性文件:
vi sonar-project.properties
// Required configuration
sonar.projectKey=**com.payoda.wordsudoku**
sonar.projectName=**DragDrop**
sonar.projectVersion=**1.0**
sonar.language=**objc**
// Project description
sonar.projectDescription=**Sample description**
// Path to source directories
sonar.sources=**~/path to your project**
// Path to test directories (comment if no test)
//sonar.tests=testSrcDir
// Xcode project configuration (.xcodeproj or .xcworkspace)
// -> If you have a project: configure only sonar.objectivec.project
// -> If you have a workspace: configure sonar.objectivec.workspace and sonar.objectivec.project
// and use the later to specify which project(s) to include in the analysis (comma separated list)
sonar.objectivec.project=**DragDrop.xcodeproj**
// sonar.objectivec.workspace=myApplication.xcworkspace
// Scheme to build your application
sonar.objectivec.appScheme=**DragDrop**
// Scheme to build and run your tests (comment following line of you don't have any tests)
//sonar.objectivec.testScheme=myApplicationTests
/////////////////////////
// Optional configuration
// Encoding of the source code
sonar.sourceEncoding=**UTF-8**
// JUnit report generated by run-sonar.sh is stored in sonar-reports/TEST-report.xml
// Change it only if you generate the file on your own
// Change it only if you generate the file on your own
// The XML files have to be prefixed by TEST- otherwise they are not processed
// sonar.junit.reportsPath=sonar-reports/
// Cobertura report generated by run-sonar.sh is stored in sonar-reports/coverage.xml
// Change it only if you generate the file on your own
// sonar.objectivec.coverage.reportPattern=sonar-reports/coverage*.xml
// OCLint report generated by run-sonar.sh is stored in sonar-reports/oclint.xml
// Change it only if you generate the file on your own
// sonar.objectivec.oclint.report=sonar-reports/oclint.xml
// Paths to exclude from 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://...
- 保存该文件,您可以将其重新用于其他项目
- 在项目根目录中运行命令-
sonarrunner