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. Java程序设计(2021春)——第二章笔记与思考

    Java程序设计(2021春)--第二章笔记与思考 本章概览: 面向对象方法的特征 抽象:从同类型对象中抽象出共同属性 封装:把数据和处理数据的方法封到一个类中 继承:在已有的类的基础上开发新的类 多 ...

  2. 1.3.8、通过RemoteAddr匹配

    server: port: 8080 spring: application: name: gateway cloud: gateway: routes: - id: guo-system4 uri: ...

  3. Python调用shell命令常用方法

    Python调用shell指令 方法一.使用os模块的system方法:os.system(cmd),其返回值是shell指令运行后返回的状态码,int类型,0表示shell指令成功执行,256表示未 ...

  4. XCTF reverse maze

    一.查壳 二.拖入ida64,静态调试,找到主函数F5反编译 二.1 思路分析(逆向是真的费时间,每个函数都要分析过去): 1.发现每个if最终都会进入LABEL-15 点进去,看看这个函数是干啥的. ...

  5. CG-CTF 签到

    int __cdecl sub_401340(unsigned __int8 *a1) { int v2; // [esp+18h] [ebp-D0h] int v3; // [esp+1Ch] [e ...

  6. pod调度

    Pod调度 在默认情况下,一个pod在哪个node节点上运行,是由scheduler组件采用相应的算法计算出来的,这个过程是不受人工控制的. 但是在实际过程中,这并不满足需求,因为很多情况下,我们想控 ...

  7. 20道Java实习生笔试面试选择题(内附答案解析)

    ​1.以下对继承的描述错误的是(A) A.Java中的继承允许一个子类继承多个父类 B.父类更具有通用性,子类更具体 C.Java中的继承存在的传递性 D.当实例化子类时会递归调用父类中的构造方法 解 ...

  8. python05篇 json和函数

    一.json json就是一个字符串,只不过是所有语言能解析这个字符串.1.1 把python的数据类型转为json import json d = {'name': 'xiaohei', 'cars ...

  9. 自动化测试 如何快速提取Json数据

    Json作为一种轻量级的交换数据形式,由于其自身的一些优良特性比如包含有效信息多,易于阅读和解析. 使用Json的场景也很多,比如读取解析系列化的Json格式的数据,我们需要将一个Json的字符串解析 ...

  10. dev c++自动添加初始源代码

    1.打开 dec v++ 2.工具--编辑器属性 3."代码"选项卡,点击"缺省源" 7.选择"向项目初始源文件插入代码" 8.下面插入下面 ...