Reputation: 595
I need to export all rules by language. I can get a set of 100 rules from the web API for a given language, but it seems the web API is limited to paging through the rules 100 rules at a time. Obviously I can set the pagesize higher (i.e. 500) but what about rule sets that have more than 500 rules (i.e. Java)? Do I need to page through the rules until the end? How do I tell when I have the last page?
Upvotes: 0
Views: 1687
Reputation: 7321
Try and see: https://sonarqube.com/api/rules/search?languages=java,js , returns the list of rules for Java and JavaScript . Response starts by:
{
"total": 537,
"p": 1,
"ps": 100,
"rules": [...] // 100 items
}
The rest of it is just good ol' maths: 537 items in total, page sizes of 100. So, all things considered, page 6 should be the last one: https://sonarqube.com/api/rules/search?languages=java,js&p=6 - 37 rules returned, job is done (and incrementing further p
would anyhow only give you an empty JSON back.
Upvotes: 4