SonarQube-5.6.3 代码分析平台搭建使用
python代码分析 官网主页:
http://docs.sonarqube.org/display/PLUG/Python+Plugin
Windows下安装使用:
快速使用:
1.下载jdk http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
2.下载解压sonar:http://www.sonarqube.org/downloads/
下载解压sonar scanner:http://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner
3. 启动sonar,运行sonarqube-5.6.3\bin\windows-x86-64\StartSonar.bat
4. 进入目录sonar-examples-master\projects\languages\java\sonar-runner\java-sonar-runner-simple, 运行sonar-scanner-2.8\bin\sonar-scanner.bat, 跑了一个实例了(如果不能正常运行,检查jdk)
5.可在这查看运行结果: http://localhost:9000 (首次登陆账号密码:admin)
6.设置中文:登陆后 Administration -> System -> Update Center -> Available -> 搜索( Chinese 插件) -> 安装后提示重启,生效
进阶:
1、安装MySQL,配置sonar数据库;
mysql -u root -p
CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'sonar' IDENTIFIED BY 'sonar';
GRANT ALL ON sonar.* TO 'sonar'@'%' IDENTIFIED BY 'sonar';
GRANT ALL ON sonar.* TO 'sonar'@'localhost' IDENTIFIED BY 'sonar';
FLUSH PRIVILEGES;
2、 修改配置文件 /conf/sonar.properties:
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
sonar.login=admin
sonar.password=admin
3、修改配置文件sonar-scanner.properties:
#Configure here general information about the environment, such as SonarQube DB details for example
#No information about specific project should appear here
#----- Default SonarQube server
sonar.host.url=http://localhost:9000
#----- Default source code encoding
sonar.sourceEncoding=UTF-8
#----- Global database settings (not used for SonarQube 5.2+)
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
#----- PostgreSQL
#sonar.jdbc.url=jdbc:postgresql://localhost/sonar
#----- MySQL
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8
#----- Oracle
#sonar.jdbc.url=jdbc:oracle:thin:@localhost/XE
#----- Microsoft SQLServer
#sonar.jdbc.url=jdbc:jtds:sqlserver://localhost/sonar;SelectMethod=Cursor
#----- Security (when 'sonar.forceAuthentication' is set to 'true')
sonar.login=admin
sonar.password=admin
4、运行setup更新一下, http://localhost:9000/setup
5、检测代码:
- 因为sonar服务器默认没安装python检测插件,此处用python代码做例子下载插件:主页->配置->系统->更新中心->Available->搜索Python插件,安装后按提示重启sonar
- 进入需要检测的项目根目录下,新建配置文件sonar-project.properties (这里是检测python代码):
# Required metadata
sonar.projectKey=org.sonarqube:python-simple-sonar-scanner
sonar.projectName=Python :: Simple Project : SonarQube Scanner
sonar.projectVersion=1.0
# Comma-separated paths to directories with sources (required)
sonar.sources=src
Language
sonar.language=py
# Encoding of the source files
sonar.sourceEncoding=UTF-8
- 增加 C:\sonar-scanner-2.8\bin 为全局环境变量
- 进入项目 根目录,运行 sonar-runner
- 分析成功:

http://localhost:9000/overview?id=org.sonarqube%3Apython-simple-sonar-scanner 查看

扩展:
- 自定义规则:
http://docs.sonarqube.org/display/DEV/Adding+Coding+Rules+using+XPath
- Login as an Quality Profile Administrator
- Go to Rules page
- Select the Language for which you want to create the XPath rule
- Tick the Template criterion and select "Show Templates Only"
- Look for the XPath rule template:

- Click on it to create a new instance of XPath rule:

- Feed the form:

- Paste in the XPath query (it should comply to XPath 1.0) you wrote and tested using the SSLR toolkit:
- Once your rule is added to SonarQube, activate it in a Quality Profile and run an analysis.
SonarQube-5.6.3 代码分析平台搭建使用的更多相关文章
- GitHub代码托管平台搭建
GitHub代码托管平台搭建 注册账户以及创建仓库 要想使用github第一步当然是注册github账号了, github官网地址:https://github.com/. 之后就可以创建仓库了(免费 ...
- ELK日志分析平台搭建
ELK平台介绍 在搜索ELK资料的时候,发现这篇文章比较好,于是摘抄一小段: 以下内容来自:http://baidu.blog.51cto.com/71938/1676798 日志主要包括系统日志.应 ...
- Storm on Yarn :原理分析+平台搭建
Storm on YARN: Storm on YARN被视为大规模Web应用与传统企业应用之间的桥梁.它将Storm事件处理平台与YARN(Yet Another Resource Negotiat ...
- ElasticSearch+Logstash+Filebeat+Kibana集群日志管理分析平台搭建
一.ELK搜索引擎原理介绍 在使用搜索引擎是你可能会觉得很简单方便,只需要在搜索栏输入想要的关键字就能显示出想要的结果.但在这简单的操作背后是搜索引擎复杂的逻辑和许多组件协同工作的结果. 搜索引擎的组 ...
- sonarqube使用maven进行代码分析
修改setting.xml文件,增加并激活profile <profile> <id>sonar</id> <properties> <sonar ...
- win7搭建本地SonarQube环境进行c#代码分析
1.SonarQube需要正常运行,首先需要安装Java环境,我这里安装的是jdk-8u181版本,可以在下面网站找适的版本去下载安装 https://www.oracle.com/technetwo ...
- ELKF-分布式日志收集分析平台搭建 最小化 配置过程 - 查看收集日志(windows10下搭建)
前言 Elasticsearch是与名为Logstash的数据收集和日志解析引擎以及名为Kibana的分析和可视化平台一起开发的.这三个产品被设计成一个集成解决方案,称为“Elastic Stack” ...
- ELK日志分析平台搭建全过程
一.使用背景 当生产环境有很多服务器.很多业务模块的日志需要每时每刻查看时 二.环境 系统:centos 6.5 JDK:1.8 Elasticsearch-5.0.0 Logstash-5.0.0 ...
- 搭建基于SornaQube的自动化安全代码检测平台
一.背景和目的 近年来,随着新业务.新技术的快速发展,应用软件安全缺陷层出不穷.虽然一般情况下,开发者基本都会有单元测试.每日构建.功能测试等环节来保证应用的可用性.但在安全缺陷方面,缺乏安全意识.技 ...
随机推荐
- 在Win2008上运行ASP.NET 1.1程序
在之前的文章<将Web站点由IIS6迁移至IIS7>中已经提到了关于在Win2008下运行ASP.NET 1.1程序的问题,但还不够完整,因此在这里重新整理一下. 1.要安装.net fr ...
- vs2010 打包 SQL server compact 4.0 驱动程序
sqlce 3.5应该是.net3.5环境下的.不知道最初的时候数据库的创建是用的3.5还是4.0 .这两天测试的时候,将4.0卸载了.就运行不上.报错为“未能加载文件或程序集“System.Data ...
- linux dns 配置
今天线上出现一个bug,图片上传失败. 经过排查发现,上传图片接口调用失败,ping 域名提示 unknow host,ping IP正常. 猜想可能是dns的问题.解决过程如下: /etc 下没有 ...
- MYSQL性能优化分享(分库分表)
1.分库分表 很明显,一个主表(也就是很重要的表,例如用户表)无限制的增长势必严重影响性能,分库与分表是一个很不错的解决途径,也就是性能优化途径,现在的案例是我们有一个1000多万条记录的用户表mem ...
- 横向图片墙排列算法及demo
演示地址: http://codeman35.itongyin.com:19005/v1/9gg_v2.html 功能: 按照不同的图片比例,进行横向9宫格排列,原则是尽量排列的整齐,不要多余出来格子 ...
- 【转】Java集合类
http://blog.csdn.net/zhangerqing/article/details/8122075 http://android.blog.51cto.com/268543/400557 ...
- rt—移植笔记2(Lwip)
首先参考f107已经有的目录结构添加Lwip这一组,添加各种.c文件及.文件. 还有drive下边的很重要的eth.c 到此,工程编译通过.(刚开始,小编是一个一个 的比对...一个一个错误排查... ...
- 关于angularJS绑定数据时自动转义html标签
关于angularJS绑定数据时自动转义html标签 angularJS在进行数据绑定时默认是会以文本的形式输出,也就是对你数据中的html标签不进行转义照单全收,这样提高了安全性,防止了html标签 ...
- jQuery中的end()
要说end(),我们就不得不说prevObject. 在jQuery中,每个jQuery对象都有一个prevObject属性 var $p = $('p'); 这个属性是做什么的呢? jQuery内部 ...
- 使用HTML5新支持的搭建WebRtc环境来作为视频通讯
发现如果再重新设计这块的话,又会有不同的思路.对于可定位能力,我们可以全息日志采集,将每个用户在整个系统的走向异步的抓取下来,再同步到专门的日志分析系统,在这个系统中可以根据用户号码.订单号进行过滤分 ...