如何使用语言过滤器从 SonarCloud 获取指标?

How can i get the metrics from SonarCloud using language filter?

我参考了 this page 如下所述,并且可以获得一些值。

$ curl -v "https://sonarcloud.io/api/measures/component?metricKeys=violations&component=key" | jq

但是如何使用语言过滤器获取这些值?

无法按语言查询 project-level 指标。正如您在 /api/measures/component 网络服务的描述中看到的那样,没有 language 参数。

如果您对某些问题特别感兴趣(我问您是因为我看到您正在尝试查询 violations 指标),那么您应该使用 /api/issues/search Web 服务你有一个 language 参数。

感谢您的评论和回答!已自行解决。
我尝试 sonar-scanner 使用 -Dsonar.language=c 等语言选项,然后访问 Web API。通过这样做,我可以获得C代码的值。