1. Write a violation rules file;

  2. Import it into Sonar as a Quality Profile named as "MyRules";

  3. Add the following properties to ant script:

  4. Run Ant script, and you can get the report at $PROJECT_HOME/.sonar/checkstyle-result.xml;

  5. Use the following python script to extract data from the report:

    from xml.etree import ElementTree as ET
    tree = ET.parse('/path/to/checkstyle-result.xml')
    root = tree.getroot()
    cycleCnt = 0
    nestCnt = 0
    for error in root.iter('error'):
    msg = error.get('message')
    if msg.startswith('Cyclomatic'):
    cycleCnt += 1
    if msg.startswith('Nested'):
    nestCnt += 1
    print "Cyclomatic:",cycleCnt,"Nested:",nestCnt

See "Section 19.7: xml.etree.ElementTree" of documentation of Python 2.7.5 for details.

Reuse Sonar Checkstyle Violation Report for Custom Data Analysis的更多相关文章

  1. Custom Data Service Providers

    Custom Data Service Providers Introduction Data Services sits above a Data Service Provider, which i ...

  2. [TypeScript] Custom data structures in TypeScript with iterators

    We usually think of types as something that can define a single layer of an object: with an interfac ...

  3. An Introduction to Stock Market Data Analysis with R (Part 1)

    Around September of 2016 I wrote two articles on using Python for accessing, visualizing, and evalua ...

  4. Generic recipe for data analysis with general linear model

    Generic recipe for data analysis with general linear model Courtesy of David Schneider State populat ...

  5. 《利用Python进行数据分析: Python for Data Analysis 》学习随笔

    NoteBook of <Data Analysis with Python> 3.IPython基础 Tab自动补齐 变量名 变量方法 路径 解释 ?解释, ??显示函数源码 ?搜索命名 ...

  6. Python for Data Analysis

    Data Analysis with Python ch02 一些有趣的数据分析结果 Male描述的是美国新生儿男孩纸的名字的最后一个字母的分布 Female描述的是美国新生儿女孩纸的名字的最后一个字 ...

  7. Learning Spark: Lightning-Fast Big Data Analysis 中文翻译

    Learning Spark: Lightning-Fast Big Data Analysis 中文翻译行为纯属个人对于Spark的兴趣,仅供学习. 如果我的翻译行为侵犯您的版权,请您告知,我将停止 ...

  8. 深入浅出数据分析 Head First Data Analysis Code 数据与代码

    <深入浅出数据分析>英文名为Head First Data Analysis Code, 这本书中提供了学习使用的数据和程序,原书链接由于某些原因不 能打开,这里在提供一个下载的链接.去下 ...

  9. How to use data analysis for machine learning (example, part 1)

    In my last article, I stated that for practitioners (as opposed to theorists), the real prerequisite ...

随机推荐

  1. JDK8安装包的下载安装方式以及环境变量的配置

    前面我们介绍了 <Java是什么?>.<OracleJDK是什么?OracleJDK的版本怎么选择?>.<OpenJDK是什么?>以及<OracleJDK 与 ...

  2. Java数据库开发(二)之——DBCP连接数据库

    1.载入jar包 DBCP需要以下几个jar包,可到apache及mysql的官网下载 2.程序编写 public static BasicDataSource ds = null; static f ...

  3. IP地址详解

    讲之前了解一些网络设备的作用: 交换机:组建局域网 路由器:连接内外网 网关:一个网络的出口(Gate Way = GW)一般网关在路由器上 局域网(也称内网) 一个简单的局域网的基本组成设备:交换机 ...

  4. CF277E Binary Tree on Plane

    CF277E Binary Tree on Plane 题目大意 给定平面上的 \(n\) 个点,定义两个点之间的距离为两点欧几里得距离,求最小二叉生成树. 题解 妙啊. 难点在于二叉的限制. 注意到 ...

  5. Tuleap administration 管理员页面中项目的配置页面

    1) 进入Administration界面,点击[Browse All] 2) 所有的项目会在项目页面中展示出来 3)在Details后面点击按钮,选择 [go to project administ ...

  6. 鸟哥的Linux私房菜基础学习篇--进程(process)一 归纳总结

    权限!权限!权限! 没有权限,一些资源你是没办法使用的.在Linux中cat filename,结果屏幕显示了filename的内容,为什么你能看见,而我不能?权限.与UID/GID有关,与文件的属性 ...

  7. python 得到汉字的拼音

    import pypinyin # 不带声调的(style=pypinyin.NORMAL) def pinyin(word): s = '' for i in pypinyin.pinyin(wor ...

  8. java面向对象程序设计(下)-枚举类

    在某些情况下,一个类的对象是有限而且固定的,比如季节类,它只有4个对象;再比如行星类,目前只有8个对象,这些实例有限而且固定的类,在Java中被称为枚举类 JDK1.5新增了一个enum关键字,(它与 ...

  9. Windows内核开发-3-内核编程基础

    Windows内核开发-3-内核编程基础 这里会深入讲解kernel内核的API.结构体.和一些定义.考察代码在内核驱动中运行的机制.最后把所有知识合在一起写一个有用的驱动. 本章学习要点: 1:通用 ...

  10. 使用deepin系统自带命令切割视频使用lossless免费软件切割

    1,使用ffmpeg命令:ffmpeg -ss 00:00:10 -i gaodengshuxue.mp4 -vcodec copy -acodec copy -t 00:00:20 output.m ...