首页 > 其他 > 详细

Reuse Sonar Checkstyle Violation Report for Custom Data Analysis

时间:2014-03-18 09:09:14      阅读:460      评论:0      收藏:0      [点我收藏+]
  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,布布扣,bubuko.com

Reuse Sonar Checkstyle Violation Report for Custom Data Analysis

原文:http://www.cnblogs.com/darkmatter/p/3606762.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!