如何在声纳REST api中获取特定指标的所有值

时间:2014-05-12 14:07:44

标签: web-services rest sonarqube

我能够使用以下java代码

从声纳REST API获取项目(资源)列表
Sonar sonar = Sonar.create("wwww.example.com/sonar/api/resources?metrics=nloc");
ResourceQuery query = new ResourceQuery();
List resourceList = sonar.findAll(query);
for(Resource resource : resourceList){
  System.out.println(resource.getid()+":"+resource.getMetricIntValue("nloc"));
}

但这导致了

1001:null
1002:null
1003:null
1004:null

为什么代码行的值返回null?

1 个答案:

答案 0 :(得分:5)

docs显示metrics参数,其值为ncloc,而不是nloc。我想你刚收到一个错字。