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. yolov5 AssertionError: Image Not Found解决方案

    运行yolov5 train.py报错:AssertionError: Image Not Found ../data/images/xxx.png 运行环境     一开始在笔记本上用显卡跑训练是可 ...

  2. nexus AD 集成配置

    nexus AD 集成配置 管理用户登录 点击设置图标-->LDAP-->Create connection 进入AD 集成配置页面 Connection配置 User and group ...

  3. 1、springboot2新建web项目

    1.添加依赖 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http ...

  4. 淘宝的sign参数js逆向

    前言:现在网站都有很强的反爬机制,都是非常常见的是用js前端加密参数,所以不得不去分析和逆向js混淆后的代码 一. 打开天猫或淘宝,shift+ctrl+F12全局搜索sign参数. 这里发现很多地方 ...

  5. ROS踩坑笔记总结

    2019-07-12 11:32:16 我的第一篇原创博客(当然是站在巨人肩膀上,有些内容参考了其他大神的博客,都一一做了说明),这些是我之前在学习ROS期间经历的一些坑,以及相对应的解决方案,希望可 ...

  6. 虚拟机centos7环境搭建,系统分区,静态IP配置

    文章目录 1.虚拟机安装centos7 2.系统分区 3.配置静态IP centos7下载地址 http://mirrors.aliyun.com/centos/7/isos/x86_64/ Cent ...

  7. 传统.NET 4.x应用容器化体验(1)

    我们都知道.NET Core应用可以跑在Docker上,那.NET Framework 4.x应用呢?借助阿里云ECS主机(Windows Server 2019 with Container版本), ...

  8. POJ 尺取法

    poj3061 Subsequence 题目链接: http://poj.org/problem?id=3061 挑战P146.题意:给定长度为n的数列整数a0,a1,...,a(n-1)以及整数S, ...

  9. python + mysql 实现表更新数据

    实例如下: import pymysqldef Update_Set(): #打开数据库链接 db = pymysql.connect("localhost","root ...

  10. Android Studio(或IntelliJ IDEA )把Android程序运行到由VirtualBox创建 Android x86虚拟机中

    一.运行前相关配置 1.把Android sdk platform-tools目录下的adb程序加入到path环境变量,默认情况下是其路径是: C:/Users/ [User]/AppData/Loc ...