查看sonar api接口:http://{ip}:9000/web_api

可以通过接口:

http://my.sonar.com/drilldown/measures/My-Project-Name?metric=line_coverage

官方说这个接口也是可以获取的,但是尝试返回404

通过接口:(接口resource=componentKey)

http://my.sonar.com/api/resources?resource=com.suning.plppss:plppss-pom:1.1.1&metrics=ncloc,conditions_to_cover,uncovered_conditions,lines_to_cover,uncovered_lines,coverage,new_coverage,line_coverage,new_line_coverage,branch_coverage,it_conditions_to_cover,it_uncovered_conditions,it_lines_to_cover,it_uncovered_lines,it_coverage,it_line_coverage,it_branch_coverage,overall_conditions_to_cover,overall_uncovered_conditions,overall_lines_to_cover,overall_uncovered_lines,overall_coverage,overall_line_coverage,overall_branch_coverage

返回:

<resources>
<resource>
<id>8393640</id>
<key>com.suning.plppss:plppss-pom:1.1.1</key>
<name>plppss-pom 1.1.1</name>
<lname>plppss-pom 1.1.1</lname>
<branch>1.1.1</branch>
<scope>PRJ</scope>
<qualifier>TRK</qualifier>
<version>4.5.1</version>
<date>2018-05-02T15:16:41+0800</date>
<creationDate>2018-04-09T09:49:28+0800</creationDate>
<msr>
<key>coverage</key>
<val>15.5</val>
<frmt_val>15.5%</frmt_val>
</msr>
<msr>
<key>uncovered_lines</key>
<val>31866.0</val>
<frmt_val>31,866</frmt_val>
</msr>
<msr>
<key>conditions_to_cover</key>
<val>11293.0</val>
<frmt_val>11,293</frmt_val>
</msr>
<msr>
<key>uncovered_conditions</key>
<val>10064.0</val>
<frmt_val>10,064</frmt_val>
</msr>
<msr>
<key>lines_to_cover</key>
<val>38301.0</val>
<frmt_val>38,301</frmt_val>
</msr>
<msr>
<key>ncloc</key>
<val>105198.0</val>
<frmt_val>105,198</frmt_val>
</msr>
<msr>
<key>line_coverage</key>
<val>16.8</val>
<frmt_val>16.8%</frmt_val>
</msr>
<msr>
<key>branch_coverage</key>
<val>10.9</val>
<frmt_val>10.9%</frmt_val>
</msr>
</resource>
</resources>

但是这个接口没有返回 new_coverage信息

---------------------------------------------------------------------------------------------------------------------------

通过接口

http://my.sonar.com/api/measures/component?componentKey=com.suning.o2oms:o2oms-pom:1.0.0&metricKeys=new_uncovered_conditions,new_uncovered_lines,new_duplicated_blocks,new_lines_to_cover,bugs,files,new_bugs,new_vulnerabilities,new_code_smells,new_duplicated_lines,new_violations,uncovered_conditions,new_branch_coverage,new_coverage,new_lines,new_sqale_debt_ratio,new_maintainability_rating&additionalFields=metrics,periods

返回:

{"component":{"id":"AWMCo0vcw6x9hRrwyONR","key":"com.suning.o2oms:o2oms-pom:1.0.0","name":"o2oms-pom 1.0.0","qualifier":"TRK","measures":[{"metric":"new_uncovered_conditions","periods":[{"index":1,"value":"198"},{"index":2,"value":"0"},{"index":3,"value":"198"}]},{"metric":"new_lines","periods":[{"index":1,"value":"22097"},{"index":2,"value":"39"},{"index":3,"value":"22097"}]},{"metric":"new_uncovered_lines","periods":[{"index":1,"value":"577"},{"index":2,"value":"3"},{"index":3,"value":"577"}]},{"metric":"new_maintainability_rating","periods":[{"index":1,"value":"1.0"},{"index":2,"value":"1.0"},{"index":3,"value":"1.0"}]},{"metric":"new_lines_to_cover","periods":[{"index":1,"value":"1704"},{"index":2,"value":"19"},{"index":3,"value":"1704"}]},{"metric":"files","value":"456","periods":[{"index":1,"value":"1"},{"index":2,"value":"0"},{"index":3,"value":"1"}]},{"metric":"new_violations","periods":[{"index":1,"value":"90"},{"index":2,"value":"3"},{"index":3,"value":"90"}]},{"metric":"bugs","value":"125","periods":[{"index":1,"value":"-49"},{"index":2,"value":"-3"},{"index":3,"value":"-49"}]},{"metric":"new_vulnerabilities","periods":[{"index":1,"value":"0"},{"index":2,"value":"0"},{"index":3,"value":"0"}]},{"metric":"new_bugs","periods":[{"index":1,"value":"14"},{"index":2,"value":"0"},{"index":3,"value":"14"}]},{"metric":"new_duplicated_blocks","periods":[{"index":1,"value":"49"},{"index":2,"value":"0"},{"index":3,"value":"49"}]},{"metric":"new_coverage","periods":[{"index":1,"value":"62.70452358036574"},{"index":2,"value":"85.71428571428571"},{"index":3,"value":"62.70452358036574"}]},{"metric":"new_duplicated_lines","periods":[{"index":1,"value":"150"},{"index":2,"value":"0"},{"index":3,"value":"150"}]},{"metric":"new_code_smells","periods":[{"index":1,"value":"76"},{"index":2,"value":"3"},{"index":3,"value":"76"}]},{"metric":"new_sqale_debt_ratio","periods":[{"index":1,"value":"0.6193306224585549"},{"index":2,"value":"1.3888888888888888"},{"index":3,"value":"0.6193306224585549"}]},{"metric":"new_branch_coverage","periods":[{"index":1,"value":"47.05882352941177"},{"index":2,"value":"100.0"},{"index":3,"value":"47.05882352941177"}]},{"metric":"uncovered_conditions","value":"1762","periods":[{"index":1,"value":"1474"},{"index":2,"value":"-2"},{"index":3,"value":"1474"}]}]},"metrics":[{"key":"new_lines","name":"Lines on New Code","description":"Non commenting lines on new code","domain":"Size","type":"INT","higherValuesAreBetter":false,"qualitative":false,"hidden":false,"custom":false},{"key":"files","name":"Files","description":"Number of files","domain":"Size","type":"INT","higherValuesAreBetter":false,"qualitative":false,"hidden":false,"custom":false},{"key":"new_coverage","name":"Coverage on New Code","description":"Coverage of new/changed code","domain":"Coverage","type":"PERCENT","higherValuesAreBetter":true,"qualitative":true,"hidden":false,"custom":false,"decimalScale":1,"bestValue":"100.0","worstValue":"0.0"},{"key":"new_lines_to_cover","name":"Lines to Cover on New Code","description":"Lines to cover on new code","domain":"Coverage","type":"INT","higherValuesAreBetter":false,"qualitative":false,"hidden":false,"custom":false},{"key":"new_uncovered_lines","name":"Uncovered Lines on New Code","description":"Uncovered lines on new code","domain":"Coverage","type":"INT","higherValuesAreBetter":false,"qualitative":false,"hidden":false,"custom":false,"bestValue":"0"},{"key":"uncovered_conditions","name":"Uncovered Conditions","description":"Uncovered conditions","domain":"Coverage","type":"INT","higherValuesAreBetter":false,"qualitative":false,"hidden":false,"custom":false,"bestValue":"0"},{"key":"new_uncovered_conditions","name":"Uncovered Conditions on New Code","description":"Uncovered conditions on new code","domain":"Coverage","type":"INT","higherValuesAreBetter":false,"qualitative":false,"hidden":false,"custom":false,"bestValue":"0"},{"key":"new_branch_coverage","name":"Condition Coverage on New Code","description":"Condition coverage of new/changed code","domain":"Coverage","type":"PERCENT","higherValuesAreBetter":true,"qualitative":true,"hidden":false,"custom":false,"decimalScale":1,"bestValue":"100.0","worstValue":"0.0"},{"key":"new_duplicated_lines","name":"Duplicated Lines on New Code","description":"Duplicated Lines on New Code","domain":"Duplications","type":"INT","higherValuesAreBetter":false,"qualitative":true,"hidden":false,"custom":false,"bestValue":"0"},{"key":"new_duplicated_blocks","name":"Duplicated Blocks on New Code","description":"Duplicated blocks on new code","domain":"Duplications","type":"INT","higherValuesAreBetter":false,"qualitative":true,"hidden":false,"custom":false,"bestValue":"0"},{"key":"new_violations","name":"New Issues","description":"New issues","domain":"Issues","type":"INT","higherValuesAreBetter":false,"qualitative":true,"hidden":false,"custom":false,"bestValue":"0"},{"key":"new_code_smells","name":"New Code Smells","description":"New Code Smells","domain":"Maintainability","type":"INT","higherValuesAreBetter":false,"qualitative":true,"hidden":false,"custom":false,"bestValue":"0"},{"key":"bugs","name":"Bugs","description":"Bugs","domain":"Reliability","type":"INT","higherValuesAreBetter":false,"qualitative":false,"hidden":false,"custom":false,"bestValue":"0"},{"key":"new_bugs","name":"New Bugs","description":"New Bugs","domain":"Reliability","type":"INT","higherValuesAreBetter":false,"qualitative":true,"hidden":false,"custom":false,"bestValue":"0"},{"key":"new_vulnerabilities","name":"New Vulnerabilities","description":"New Vulnerabilities","domain":"Security","type":"INT","higherValuesAreBetter":false,"qualitative":true,"hidden":false,"custom":false,"bestValue":"0"},{"key":"new_maintainability_rating","name":"Maintainability Rating on New Code","description":"Maintainability rating on new code","domain":"Maintainability","type":"RATING","higherValuesAreBetter":false,"qualitative":true,"hidden":false,"custom":false,"bestValue":"1.0","worstValue":"5.0"},{"key":"new_sqale_debt_ratio","name":"Technical Debt Ratio on New Code","description":"Technical Debt Ratio of new/changed code.","domain":"Maintainability","type":"PERCENT","higherValuesAreBetter":false,"qualitative":true,"hidden":false,"custom":false,"decimalScale":1,"bestValue":"0.0","worstValue":"100.0"}],"periods":[{"index":1,"mode":"previous_version","date":"2018-04-26T23:48:42+0800"},{"index":2,"mode":"previous_analysis","date":"2018-05-02T15:35:53+0800","parameter":"2018-05-02"},{"index":3,"mode":"days","date":"2018-04-26T23:48:42+0800","parameter":"30"}]}

转化为json:

{"component": {"id": "AWMCo0vcw6x9hRrwyONR", "key": "com.suning.o2oms:o2oms-pom:1.0.0", "name": "o2oms-pom 1.0.0", "qualifier": "TRK", "measures": [{"metric": "new_uncovered_conditions", "periods": [{"index": 1, "value": "198"}, {"index": 2, "value": "0"}, {"index": 3, "value": "198"}]}, {"metric": "new_lines", "periods": [{"index": 1, "value": "22097"}, {"index": 2, "value": "39"}, {"index": 3, "value": "22097"}]}, {"metric": "new_uncovered_lines", "periods": [{"index": 1, "value": "577"}, {"index": 2, "value": "3"}, {"index": 3, "value": "577"}]}, {"metric": "new_maintainability_rating", "periods": [{"index": 1, "value": "1.0"}, {"index": 2, "value": "1.0"}, {"index": 3, "value": "1.0"}]}, {"metric": "new_lines_to_cover", "periods": [{"index": 1, "value": "1704"}, {"index": 2, "value": "19"}, {"index": 3, "value": "1704"}]}, {"metric": "files", "value": "456", "periods": [{"index": 1, "value": "1"}, {"index": 2, "value": "0"}, {"index": 3, "value": "1"}]}, {"metric": "new_violations", "periods": [{"index": 1, "value": "90"}, {"index": 2, "value": "3"}, {"index": 3, "value": "90"}]}, {"metric": "bugs", "value": "125", "periods": [{"index": 1, "value": "-49"}, {"index": 2, "value": "-3"}, {"index": 3, "value": "-49"}]}, {"metric": "new_vulnerabilities", "periods": [{"index": 1, "value": "0"}, {"index": 2, "value": "0"}, {"index": 3, "value": "0"}]}, {"metric": "new_bugs", "periods": [{"index": 1, "value": "14"}, {"index": 2, "value": "0"}, {"index": 3, "value": "14"}]}, {"metric": "new_duplicated_blocks", "periods": [{"index": 1, "value": "49"}, {"index": 2, "value": "0"}, {"index": 3, "value": "49"}]}, {"metric": "new_coverage", "periods": [{"index": 1, "value": "62.70452358036574"}, {"index": 2, "value": "85.71428571428571"}, {"index": 3, "value": "62.70452358036574"}]}, {"metric": "new_duplicated_lines", "periods": [{"index": 1, "value": "150"}, {"index": 2, "value": "0"}, {"index": 3, "value": "150"}]}, {"metric": "new_code_smells", "periods": [{"index": 1, "value": "76"}, {"index": 2, "value": "3"}, {"index": 3, "value": "76"}]}, {"metric": "new_sqale_debt_ratio", "periods": [{"index": 1, "value": "0.6193306224585549"}, {"index": 2, "value": "1.3888888888888888"}, {"index": 3, "value": "0.6193306224585549"}]}, {"metric": "new_branch_coverage", "periods": [{"index": 1, "value": "47.05882352941177"}, {"index": 2, "value": "100.0"}, {"index": 3, "value": "47.05882352941177"}]}, {"metric": "uncovered_conditions", "value": "1762", "periods": [{"index": 1, "value": "1474"}, {"index": 2, "value": "-2"}, {"index": 3, "value": "1474"}]}]}, "metrics": [{"key": "new_lines", "name": "Lines on New Code", "description": "Non commenting lines on new code", "domain": "Size", "type": "INT", "higherValuesAreBetter": false, "qualitative": false, "hidden": false, "custom": false}, {"key": "files", "name": "Files", "description": "Number of files", "domain": "Size", "type": "INT", "higherValuesAreBetter": false, "qualitative": false, "hidden": false, "custom": false}, {"key": "new_coverage", "name": "Coverage on New Code", "description": "Coverage of new/changed code", "domain": "Coverage", "type": "PERCENT", "higherValuesAreBetter": true, "qualitative": true, "hidden": false, "custom": false, "decimalScale": 1, "bestValue": "100.0", "worstValue": "0.0"}, {"key": "new_lines_to_cover", "name": "Lines to Cover on New Code", "description": "Lines to cover on new code", "domain": "Coverage", "type": "INT", "higherValuesAreBetter": false, "qualitative": false, "hidden": false, "custom": false}, {"key": "new_uncovered_lines", "name": "Uncovered Lines on New Code", "description": "Uncovered lines on new code", "domain": "Coverage", "type": "INT", "higherValuesAreBetter": false, "qualitative": false, "hidden": false, "custom": false, "bestValue": "0"}, {"key": "uncovered_conditions", "name": "Uncovered Conditions", "description": "Uncovered conditions", "domain": "Coverage", "type": "INT", "higherValuesAreBetter": false, "qualitative": false, "hidden": false, "custom": false, "bestValue": "0"}, {"key": "new_uncovered_conditions", "name": "Uncovered Conditions on New Code", "description": "Uncovered conditions on new code", "domain": "Coverage", "type": "INT", "higherValuesAreBetter": false, "qualitative": false, "hidden": false, "custom": false, "bestValue": "0"}, {"key": "new_branch_coverage", "name": "Condition Coverage on New Code", "description": "Condition coverage of new/changed code", "domain": "Coverage", "type": "PERCENT", "higherValuesAreBetter": true, "qualitative": true, "hidden": false, "custom": false, "decimalScale": 1, "bestValue": "100.0", "worstValue": "0.0"}, {"key": "new_duplicated_lines", "name": "Duplicated Lines on New Code", "description": "Duplicated Lines on New Code", "domain": "Duplications", "type": "INT", "higherValuesAreBetter": false, "qualitative": true, "hidden": false, "custom": false, "bestValue": "0"}, {"key": "new_duplicated_blocks", "name": "Duplicated Blocks on New Code", "description": "Duplicated blocks on new code", "domain": "Duplications", "type": "INT", "higherValuesAreBetter": false, "qualitative": true, "hidden": false, "custom": false, "bestValue": "0"}, {"key": "new_violations", "name": "New Issues", "description": "New issues", "domain": "Issues", "type": "INT", "higherValuesAreBetter": false, "qualitative": true, "hidden": false, "custom": false, "bestValue": "0"}, {"key": "new_code_smells", "name": "New Code Smells", "description": "New Code Smells", "domain": "Maintainability", "type": "INT", "higherValuesAreBetter": false, "qualitative": true, "hidden": false, "custom": false, "bestValue": "0"}, {"key": "bugs", "name": "Bugs", "description": "Bugs", "domain": "Reliability", "type": "INT", "higherValuesAreBetter": false, "qualitative": false, "hidden": false, "custom": false, "bestValue": "0"}, {"key": "new_bugs", "name": "New Bugs", "description": "New Bugs", "domain": "Reliability", "type": "INT", "higherValuesAreBetter": false, "qualitative": true, "hidden": false, "custom": false, "bestValue": "0"}, {"key": "new_vulnerabilities", "name": "New Vulnerabilities", "description": "New Vulnerabilities", "domain": "Security", "type": "INT", "higherValuesAreBetter": false, "qualitative": true, "hidden": false, "custom": false, "bestValue": "0"}, {"key": "new_maintainability_rating", "name": "Maintainability Rating on New Code", "description": "Maintainability rating on new code", "domain": "Maintainability", "type": "RATING", "higherValuesAreBetter": false, "qualitative": true, "hidden": false, "custom": false, "bestValue": "1.0", "worstValue": "5.0"}, {"key": "new_sqale_debt_ratio", "name": "Technical Debt Ratio on New Code", "description": "Technical Debt Ratio of new/changed code.", "domain": "Maintainability", "type": "PERCENT", "higherValuesAreBetter": false, "qualitative": true, "hidden": false, "custom": false, "decimalScale": 1, "bestValue": "0.0", "worstValue": "100.0"}], "periods": [{"index": 1, "mode": "previous_version", "date": "2018-04-26T23:48:42+0800"}, {"index": 2, "mode": "previous_analysis", "date": "2018-05-02T15:35:53+0800", "parameter": "2018-05-02"}, {"index": 3, "mode": "days", "date": "2018-04-26T23:48:42+0800", "parameter": "30"}]
}

这个接口返回new_coverage信息,这个接口最后面添加additionalFields=metrics,periods,会返回metric字段信息,和对应的index构建的时间。

sonar api 获取质量数据相关推荐

  1. sonar 分析的质量数据在数据库表中的存储和质量维度数值的研究

    首先sonar分析的质量数据维度明细在metric表中: 图中很关键的数据:覆盖率,新增覆盖率:代码行覆盖率,代码行新增覆盖率 覆盖率是字节码的比值,代码覆盖率是代码行层面的统计,所以一般代码行覆盖率 ...

  2. 如何使用 Yahoo! Finance stock API 获取股票数据

    本站曾介绍过,通过代码添加雅虎财经的股票走势图到自己网站的方法(添加美国股市 ,添加沪深股市 ),调用的是一张图片.今天在德馨 网站,看到了从雅虎财经频道获取股票数据的API(Yahoo! Finan ...

  3. 用python读取股票价格_雅虎API获取股票数据--Python

    好久不学Python,计划用Tkinter写一个利用雅虎免费股票查询API的可视化程序 Yahoo股票报价API 获取实时数据 请求url:http://finance.yahoo.com/d/quo ...

  4. 【Power Automate系列教程】利用API获取JSON数据定时每日自动写入List

    利用API获取JSON数据定时每日自动写入List 在知识星球的后台有个看数据的界面: 通过简单的抓包可以看到是个json数据,那么就有了想法! 获取到请求的api,发现规律: https://api ...

  5. python tushare获取股票数据_Python 金融: TuShare API 获取股票数据 (1)

    多多教Python 金融 是我为金融同行,自由职业投资人 做的一个专栏.这里包含了我自己作为量化交易员,在做研究时所用到的Python技巧和实用案例.这个栏目专业性会比较强:本人29岁,量化工作5年的 ...

  6. 在树莓派上使用 PowerShell 调用 Azure 上的 .NET Core API 获取疫情数据

    点击上方蓝字关注"汪宇杰博客" 导语 最近因为疫情被关在家里,做了个无聊成就:我们将在树莓派上用 PowerShell 调用 Azure 上的一个 .NET Core 写的 API ...

  7. 进阶1·调用高德API获取交通数据(多个URL访问,字典提取,while无限循环下的程序间断运行)

    调用高德开放API获取实时交通数据 想法及思路 现在大型网站都提供了好多开放API,根据这些开放API可以做一些比较有趣的东西,本次调用高德开放api实时获取你想知道的道路拥堵状况 工具及技术: Py ...

  8. 不通过twitter API获取Twitter数据的方法

    不通过twitter API调用Twitter数据 前言 1.Python库的导入 2.网络问题的解决 2.1.可能遇到的错误 2.1.1.Cannot Connect to host twitter ...

  9. 从天气预报网页API获取天气预报数据

    用Java代码获取中央气象局的天气预报数据 版权声明:数据版权归中央气象局所有,仅供学习交流之用.本文内容若有侵权,请联系我删除~ 文章目录 用Java代码获取中央气象局的天气预报数据 1 获取相关接 ...

最新文章

  1. 个人博客打不开时检查下github.com的ip地址是否更改/修改博客内容字体、颜色及大小
  2. Windows Presentation Foundation(介绍外连接)
  3. Python 爬虫实现天气查询(可视化界面版)
  4. visual studio xcopy /exclude测试
  5. 使用QT创建PythonGUI程序
  6. java jframe全屏_Java-将JFrame设置为全屏时,屏幕变黑
  7. ospf lesson 3
  8. AI 开发者如何摆脱只有“人工”没有“智能?
  9. linux服务器学习笔记:linux如何远程登录?
  10. 分寸:切记别把话说得太死 — 《别输在不会表达上》
  11. 【渝粤教育】电大中专幼儿园课程论作业 题库
  12. idea中maven项目,输出在控制台上的中文乱码问题
  13. 裸辞计算机考研,一位工作三年,裸辞,跨考,347学姐的考研经验 - 考研 - 小木虫 - 学术 科研 互动社区...
  14. 函数强凸 strong convexity
  15. C# 复制Word(复制全部内容、部分内容、页眉页脚)
  16. Java获取基金接口天天基金_天天基金网数据接口
  17. 自然语言处理入门(一)
  18. 【思维导图】零基础如何把握Python学习方向
  19. PDF打开正常打印后却被放大,如何调整到正常?
  20. Python基础——科赫雪花绘制

热门文章

  1. 為什麼system32中放的是64位dll,syswow64中放的是32位dll
  2. storm java开发环境搭建,看这里!Storm【单机版】环境搭建
  3. 计算机信息加工的类型及举例,3.1.2计算机信息加工的过程和类型
  4. 面试题解(2):loop相关
  5. python全栈_007_Python3格式化输出
  6. Pandas Timestamp 和 python 中 datetime 的互相转换
  7. 理解JWT(JSON Web Token)认证及python实践
  8. 如何正确的在一个循环中删除ArrayList中的元素。
  9. error-2016-2-15
  10. nginx利用image_filter动态生成缩略图