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的自动化安全代码检测平台
一.背景和目的 近年来,随着新业务.新技术的快速发展,应用软件安全缺陷层出不穷.虽然一般情况下,开发者基本都会有单元测试.每日构建.功能测试等环节来保证应用的可用性.但在安全缺陷方面,缺乏安全意识.技 ...
随机推荐
- 【Python】【学习笔记】持续更新
调用模块的两种方式: #方式1 from decimal import Decimal Decimal('1.00') #方式2 import decimal decimal.Decimal('1.0 ...
- 规则引擎集成接口(四)SQL执行语句
SQL执行语句 右键点击数据库连接文件“hr”—“添加SQL执行语句”,如下图: 弹出窗体,如下图: 将显示名称改为“部门名称”,返回至类型设置为“string”,在编写sql语句,如下图: 点击确定 ...
- 如何创建vss2005的数据库
配置如下 VSS手工创建数据库的步骤(设数据库根目录为D:\VSS): 1.在根目录中创建名为srcsafe.ini(全局配置文件)的文件,文件内容如下: Data_Path = data Temp_ ...
- win7远程桌面恢复全屏状态快捷键
不同的电脑可能有不同的快捷键(有些笔记本电脑甚至没有相应的键值):①台式机:ctrl+alt+break 组合键.②CTRL+ALT+PAGEDOWN 组合键.③有的笔记本没有break键,可以尝试加 ...
- 大冰--寻人启事--one
看得懂的,都不是命运,说得清的,都不叫爱情. 忘得了的,都不是遗憾,听得见的,都不是伤心. 躲的开的,都不是缘分,猜得透的,都不叫人生.
- java 分布式锁方案
第一步,自身的业务场景: 在我日常做的项目中,目前涉及了以下这些业务场景: 场景一: 比如分配任务场景.在这个场景中,由于是公司的业务后台系统,主要是用于审核人员的审核工作,并发量并不是很高,而且任务 ...
- CSAPP学习笔记(第一,二章)
1:文本文件指的是ASCII码文件,二进制文件指的是除文本文件以外,其他文件. 2:区分数据对象的唯一判别方法是数据的上下文. 3:描述一下一个hello.c文件的处理过程.首先hello.c文件我们 ...
- FAST特征点检测features2D
#include <opencv2/core/core.hpp> #include <opencv2/features2d/features2d.hpp> #include & ...
- html5+css 图片自适应
<div style="position:absolute; width:100%; height:100%; z-index:-1; left:0; top:0;"> ...
- delphi 开发者 linux 实务(转)
Linux Essentials for Delphi Developers There is currently no way using Delphi to target Linux. Lon ...