测试开发实践

SonarQube (4) 运行一个Sample

2017-09-28  本文已影响94人  严北

SonarQube系列 目录


拉取sonar-cxx插件源代码

$ git clone https://github.com/SonarOpenCommunity/sonar-cxx.git

其中,sample代码位于/sonar-cxx/sonar-cxx-plugin/src/samples/SampleProject2

$ cd /sonar-cxx/sonar-cxx-plugin/src/samples/SampleProject2

运行sonar-runner

$ sonar-runner

得到结果EXECUTION SUCCESS,运行成功

SonarQube Runner 2.4
Java 1.8.0_121 Oracle Corporation (64-bit)
Linux 3.10.0-514.6.2.el7.x86_64 amd64
INFO: Runner configuration file: /etc/sonar-runner-2.4/conf/sonar-runner.properties
INFO: Project configuration file: /root/sonar-sample/sonar-cxx/sonar-cxx-plugin/src/samples/SampleProject2/sonar-project.properties
INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Work directory: /root/sonar-sample/sonar-cxx/sonar-cxx-plugin/src/samples/SampleProject2/./.sonar
INFO: SonarQube Server 5.6.7
04:45:31.997 INFO  - Load global repositories
...
...
04:45:34.852 INFO  - Analysis report uploaded in 41ms
04:45:34.852 INFO  - ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard/index/CxxPlugin:Sample
04:45:34.852 INFO  - Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
04:45:34.853 INFO  - More about the report processing at http://localhost:9000/api/ce/task?id=AV69XOLms3rpTnB5rfdL
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
Total time: 3.441s
Final Memory: 9M/220M
INFO: ------------------------------------------------------------------------

登录页面查看分析结果

复制根据分析结果中的url

04:45:34.852 INFO  - ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard/index/CxxPlugin:Sample

在浏览器中打开

http://localhost:9000/dashboard/index/CxxPlugin:Sample

代码分析结果展示

Sonar result

代码问题列表

Code smell

参考

https://github.com/SonarOpenCommunity/sonar-cxx/wiki/Running-the-analysis

上一篇下一篇

猜你喜欢

热点阅读