最新消息:

使用 Docker 搭建代码质量检测平台 SonarQube

SonarQube 骑猪南下 2756浏览 0评论
 
SonarQube

前言

想成为一名优秀的工程师,代码质量一定要过关!

前提

安装最新版的 Docker !

开始搭建

1、获取 postgresql 的镜像

$ docker pull postgres

2、启动 postgresql

$ docker run --name db -e POSTGRES_USER=sonar -e POSTGRES_PASSWORD=sonar -d postgres

3、获取 sonarqube 的镜像

$ docker pull sonarqube

4、启动 sonarqube

$ docker run --name sq --link db -e SONARQUBE_JDBC_URL=jdbc:postgresql://db:5432/sonar -p 9000:9000 -d sonarqube

至此,平台搭建完毕。

代码质量检验

1、打开 http://localhost:9000/ , 点击 “Log in”

 
sonar平台

登录账号:admin 密码:admin

2、以 Maven 项目为例,此处有一个 security-oauth2-qq 项目:

 
Maven 项目

3、执行命令,检测代码质量

$ mvn sonar:sonar

4、成功之后,返回到浏览器,就可以浏览自己的项目的代码质量了

 
综合评分
 
Code Dashboard
 
精准分析

总结

目前码云上代码分析工具首推的也是 sonarqube,支持各种语言的程序检测,使用简单方便,感觉非常适合微服务的代码评审,强烈推荐。

作者:Anoyi
链接:https://www.jianshu.com/p/a1450aeb3379
來源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

转载请注明:我们的故事 » 使用 Docker 搭建代码质量检测平台 SonarQube


Warning: Use of undefined constant PRC - assumed 'PRC' (this will throw an Error in a future version of PHP) in /www/wwwroot/blog/wp-content/themes/d8/comments.php on line 17
发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

网友最新评论 (4)

  1. 拜读了,多多学习总是好的!
    3566886年前 (2018-05-26)回复
  2. alll the time i used to read smaller posts which as wedll clear their motive, annd tuat iss also happening with this poat whikch I aam reading here.
    3811年前 (2023-01-14)回复
  3. Thanks forr one's mavelous posting! I truly enjoyedd readinhg it, yoou mght bee a great author.I will be sure tto bookmrk your bog and mayy come back soometime soon. I waant tto encourage youu continue yoour gret posts, have a nnice day!
  4. Hello there! Thhis iis kind off off toppic butt I nerd ome guidance fom an established blog. Is it vedry difficult too set uup your own blog? I'm not very techincal but I can figuire thgings out pretty fast. I'm thuinking about settinng uup mmy own but I'm noot surte where to begin. Do yoou have aany ieas oor suggestions? Thank you
    dev.xxxcrunch.com1年前 (2023-02-25)回复