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反射用法总结都告诉你们

    摘要:Java反射是一种非常强大的机制,它可以在同一个系统中去检测内部的类的字段.方法和构造函数.它非常多的Java框架中,都大量应用了反射技术,如Hibernate和Spring.可以说,反射机制的 ...

  2. keycloak~账号密码认证和授权码认证

    用户名密码登录 POST /auth/realms/demo/protocol/openid-connect/token 请求体 x-www-form-urlencoded grant_type:pa ...

  3. ThreadLocal底层原理学习

    1. 是什么? 首先ThreadLocal类是一个线程数据绑定类, 有点类似于HashMap<Thread, 你的数据> (但实际上并非如此), 它所有线程共享, 但读取其中数据时又只能是 ...

  4. Java:Java中static关键字作用

    static关键字最基本的用法是: 1.被static修饰的变量属于类变量,可以通过类名.变量名直接引用,而不需要new出一个类来 2.被static修饰的方法属于类方法,可以通过类名.方法名直接引用 ...

  5. nacos服务注册,ClientWorker狂刷日志的问题

    日志,启动项目就疯狂的刷ClientWorker日志 配置 本身项目中配置的依赖 nacos-discovery,nacos-config版本都是2021.1,但是编译版本是1.4.1 升级nacos ...

  6. head tail 用法

    tail 显示最后几行,-n后面的数字无符号,表示行数 tail -n 1000:显示最后1000行 tail -n +1000:从1000行开始显示到最后 tail -n -1000:从负1000行 ...

  7. redis的基本操作指令

    https://www.cnblogs.com/woshimrf/p/5198361.html

  8. vsftpd配置文件详解(转)

      vsftpd配置文件详解     1.默认配置: 1>允许匿名用户和本地用户登陆.      anonymous_enable=YES      local_enable=YES 2> ...

  9. leetcode第156场周赛5205

    思路分析:先用哈希表统计各个数字的次数,再将每个值放进set集合中,之后如果有重复得,说明比原个数少了,如果都是独一无二的,那么个数是相同的 这波把collection集合,强转成set是真的灵性.想 ...

  10. C语言:异或

    异或运算符"∧"也称XOR运算符.它的规则是若参加运算的两个二进位同号,则结果为0(假):异号则为1(真).即 0∧0=0,0∧1=1, 1^0=1,1∧1=0. 相同为0,不相同 ...