加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

objective-c – 使用Sonarqube和Xcode

发布时间:2020-12-14 20:00:57 所属栏目:百科 来源:网络整理
导读:我正在关注 this文章,将SonarQube与Xcode集成并分析Objective-C代码.虽然设置功能正常,并且在运行shell脚本后没有出现错误/警告,但仪表板中不会显示任何违规.我所看到的只是基本指标.代码行,没有.文件等 有没有人试过这个并引导我进一步. 解决方法 除了您在
我正在关注 this文章,将SonarQube与Xcode集成并分析Objective-C代码.虽然设置功能正常,并且在运行shell脚本后没有出现错误/警告,但仪表板中不会显示任何违规.我所看到的只是基本指标.代码行,没有.文件等
有没有人试过这个并引导我进一步.

解决方法

除了您在上面指定的文章之外,我几乎没有添加任何内容.您可以按照以下步骤操作,

先决条件:

>声纳
>声纳跑步者
> SonarQube Objective-C插件(许可)
> XCTool
> OCLint(违规)和gcovr(代码覆盖)
> MySql和JDK

安装步骤:

>下载并安装MySql dmg.然后从系统偏好设置或通过命令行启动MySQL服务器,或者如果重新启动它必须是命令行.
>要开始 – sudo /usr/local/mysql/support-files/mysql.server start
>要重新启动 – sudo /usr/local/mysql/support-files/mysql.server restart
>要停止 – sudo /usr/local/mysql/support-files/mysql.server停止
>下载并安装最新的JDK版本.
>转到终端并输入以下命令进行安装
???先决条件. (Homebrew是包
???Mac操作系统管理系统.安装自制软件,输入命令 –

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)")

>声纳 – brew安装声纳
> Sonar-runner – brew安装声纳 – 跑步者
> XCTool – brew install xctool
> OCLint – brew install 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

最后命令echo $SONAR_HOME应返回路径 – /usr/local/Cellar/sonar-runner/2.4/libexec

– 设置MySql DB:

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

.
????vi /usr/local/Cellar/sonar-runner/2.4/libexec/conf/sonar-runner.properties

您可以注释掉除凭据和mysql之外的大多数选项,并确保输入正确的数据库名称.

例如:

sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar_firstdb?useUnicode=true&characterEncoding=utf8

>使用命令启动声纳 –

sonar start

该命令将启动声纳,因此在您选择的浏览器中导航到http://localhost:9000.登录(admin / admin)并浏览一下.

>现在你必须安装Objective-C或Swift插件.

移至设置 – >系统 – >更新中心 – >可用插件(安装所需的插件).

添加pligin后,必须重新启动声纳才能完成安装,并在安装插件后添加许可证密钥.

>通过终端转到您希望声纳检查的项目的根目录,并使用以下命令创建项目特定的属性文件:

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://...

>保存文件,您可以将其重复用于其他项目.>在项目根目录中运行命令 – sonar-runner

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读