熱搜:win11繞過硬件限制安裝 一鍵重裝Win10系統(tǒng) 最干凈的u盤啟動(dòng)盤 真正純凈版的win7系統(tǒng)
時(shí)間:2015-07-22 13:59:10 作者:zhijie 來源:系統(tǒng)之家 1. 掃描二維碼隨時(shí)看資訊 2. 請使用手機(jī)瀏覽器訪問: https://m.xitongzhijia.net/xtjc/20150722/53510.html 手機(jī)查看 評(píng)論 反饋
在Linux系統(tǒng)中sonar主要是用于管理代碼質(zhì)量,而其中兩個(gè)重要的參數(shù)就是違規(guī)數(shù)和代碼行數(shù)了。本文就來介紹一下,Linux用sonar取得違規(guī)數(shù)和代碼行數(shù)的方法。
demo如下:
public class SonarDemo {
static String host = “https://xxx:9000”;
static String username = “xxx”;
static String password = “xxx”;
static String resourceKey = “org.codehaus.sonar:sonar-ws-client”;
static String[] MEASURES_TO_GET = new String[] { “violations”, “lines” };
public static void main(String[] args) {
DecimalFormat df = new DecimalFormat(“#.##”);
//創(chuàng)建Sonar
Sonar sonar = new Sonar(new HttpClient4Connector(new Host(host, username, password)));
//執(zhí)行資源請求
ResourceQuery query = ResourceQuery.createForMetrics(resourceKey, MEASURES_TO_GET);
query.setIncludeTrends(true);
Resource resource = sonar.find(query);
// 循環(huán)遍歷獲取“violations”, “lines”
List《Measure》 allMeasures = resource.getMeasures();
for (Measure measure : allMeasures) {
System.out.println((measure.getMetricKey() + “: ” +
df.format(measure.getValue())));
}
}
}
發(fā)表評(píng)論
共0條
評(píng)論就這些咯,讓大家也知道你的獨(dú)特見解
立即評(píng)論以上留言僅代表用戶個(gè)人觀點(diǎn),不代表系統(tǒng)之家立場