• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Sonarqube+sonar scanner 扫描代码(C#,Java)

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
  • 环境要求:windows 10,SonarQube 6.6,JDK 1.8,MySQL 5.7,sonar-scanner 3.3
  • SonarQube下载页面:https://www.sonarqube.org/downloads/
  • SonarQube中文文档https://legacy.gitbook.com/book/revolyw/sonarqube/details
  • SonarQube:能够提供对代码的一整套检查扫描和分析功能,拥有一套服务器端程序,然后再通过客户端或者别的软件的插件的形式完成对各开发环境和软件的支持
  • 注意:对于扫描C#代码,SonarQube 7.1和SonarQube 7.7没有成功,所以降低版本下载SonarQube 6.6
  • 运行SonarQube 6.6:下载SonarQube 6.6之后,到解压目录下的bin\windows-x86-64目录中,双击StartSonar.bat,就能启动SonarQube;打开浏览器,输入http://localhost:9000,如果能够进入界面则证明安装成功
  • 安装数据库MySQL 2.7:对于SonarQube对数据库MySQL的版本支持为 >=5.6 && <8.0,对于其他数据库的版本支持可查看sonarqube-6.6\conf\sonar.properties文件;并创建数据库sonar
  • 进行sonarqube配置:sonarqube-6.6\conf\sonar.properties文件
1 sonar.jdbc.username=root      # 数据库用户名
2 sonar.jdbc.password=123456    # 数据库密码
3 # 数据库连接地址
4 sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false
5 sonar.sorceEncoding=UTF-8     # 设置编码格式为UTF-8
6 sonar.login=admin             # sonarqube的登录名
7 sonar.password=admin          # sonarqube的密码
8 sonar.web.host=0.0.0.0        # 
9 sonar.web.port=9100           # 修改snoar端口,默认为9000
1 Key=ce532a92558fa41465ea97dbb5f1a42673d9b67e
  • cmd测试:输入sonar-scanner -v,测试环境变量是否配置正确
  • 修改配置文件:sonar-scanner-3.3.0.1492-windows\confsonar-scanner.properties
1 sonar.host.url=http://localhost:9000    # sonarqube服务地址
2 sonar.jdbc.username=root                # 数据库用户名
3 sonar.jdbc.password=123456              # 数据库密码
4 # 数据库连接地址
5 sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false
6 sonar.sorceEncoding=UTF-8               # 设置编码格式为UTF-8
7 sonar.login=admin                       # sonarqube的登录名
8 sonar.password=admin                    # sonarqube的密码
  • 配置sonar-project.properties文件:进入C#项目的根目录,新建sonar-project.properties文件
 1 # must be unique in a given SonarQube instance
 2 sonar.projectKey=CS-project
 3 # this is the name displayed in the SonarQube UI
 4 sonar.projectName=CS-project
 5 # 自定义版本号
 6 sonar.projectVersion=1.0.0.0
 7  
 8 # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
 9 # Since SonarQube 4.2, this property is optional if sonar.modules is set. 
10 # If not set, SonarQube starts looking for source code from the directory containing 
11 # the sonar-project.properties file.
12 sonar.sources=.
13 
14 # Encoding of the source code. Default is default system encoding
15 sonar.sourceEncoding=UTF-8
16 # C# => "cs"
17 # CSS => "css"
18 # SCSS => "scss"
19 # Less => "less"
20 # Java => "java"
21 # Web => "web"
22 # XML => "xml"
23 # JSON => "json"
24 # JavaScript => "js"
25 sonar.language=cs
 
 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C#读写socket的常用方式发布时间:2022-07-13
下一篇:
合并一个图层选择对象C# arcengine - gisoracle发布时间:2022-07-13
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap