cogShow how to display Sonar metrics in wiki pages
Developed by

Vincent Massol

Rating
Rate!
0 Votes
LicenseGNU Lesser General Public License 2.1

Description

Sonar offers a REST API (see also Definition of metrics).

Example

Displays some metrics (#ncloc - number of lines of code, tests - number of unit tests, classes - number of classes) from the XWiki Rendering project on Nemo:

{{groovy}}
def url = "http://nemo.sonarsource.org/api/resources?resource=org.xwiki.rendering:xwiki-rendering&metrics=ncloc,tests,classes&format=xml".toURL().text
def root = new XmlSlurper().parseText(url)

root.resource.msr.each() { measure ->
    println "{{box title='**${measure.key}**'}}"
    println "${measure.frmt_val}"
    println "{{/box}}"
    println ""
}
{{/groovy}}

Result:

sonar.jpg

Prerequisites & Installation Instructions

Copy the code snippet to a page and save it.

Created by Vincent Massol on 2011/10/29 20:57
     

Get Connected