Sonarcloud API Endpoint

We have been using the SonarCloud API to try and delete old redundant projects , but we have encountered an issue where the
“Last anaylzed” endpoint is being called but there are examples of projects/repos that haven’t analysed in a long time, but still use SonarCloud for Quality Gate Analysis, and have PR from github very recently that used Sonarcloud.

Any way to get round this issue to show the correct data requested by the API?

Hi,

Welcome to the community!

If a project still has PRs being analyzed, why wouldn’t you consider it active?

You’ve said you’re looking for redundant projects. That implies that perhaps the PR analyses are misdirected to the wrong copy of the project? In which case, it seems like cleaning up the PR analysis configuration is the way to go…

 
Ann

Hi Ann thanks for the response,

I’m sorry if I wasn’t clear earlier.

we can see it’s not been analyzed recently (lastAnalyzed date is old), but it does still have active PRs. How can we get data on these as well, plus are there any other data points that would contribute to a Project still be active, other than these two?

Tim

Hi Tim,

I guess you mean you’re directly calling https://sonarcloud.io/api/projects/search? and setting the analyzedBefore parameter?

There’s no smooth way to narrow down that list of projects to those that don’t have active PRs / branches. For each project returned, you’ll probably need to query api/project_branches/list and look at each branch’s analysisDate. And for PRs, api/project_pull_requets/list.

And, I need to ask again why you would have active PRs on defunct projects. Because eventually those PRs are going to be merged (right?) and that should trigger a re-analysis of the main branch.

 
Ann