SonarQube web API for Code smells - Technical Debt Count

4.2k views Asked by At

SonarQube Version: 6.7

Is there any REST API for getting Code smells (Technical Debt) from SonarQube, I have searched many forums but I couldn't able to find.

I need rest API where we can pass the project key to get the days count of code smells.

3

There are 3 answers

1
Val On

If I am not missing something, the following Web API should be the one you are looking for: https://sonarcloud.io/web_api/api/issues?query=issues%2Fsearch

Look for effort in the Response Example tab and you will find the estimated time to fix each issue. The format is a bit unusual, but still it should not be difficult to parse.

0
Josef Prochazka On

There is web api for measures: https://sonar.instance/api/measures/component

Metric for Technical debt is "sqale_index" https://docs.sonarqube.org/7.4/user-guide/metric-definitions/

Query to search technical debt is:

https://sonar.instance/api/measures/component?component=project_key&metricKeys=sqale_index

0
Mohankumar Rathinam On

Finally, I got the specific API for Technical Debt count for Code Smells type.

Use the below API which gives debtTotal count, take this figure and divide with mins configured in sonar Number of working hours in a day

Rest API: http://sonarinstance/api/issues/search?componentKeys=sample-project:sample-projec-key&facetMode=effort&facets=types&types=CODE_SMELL

Sample Response:

enter image description here

For Example, if 8 Hrs configured divide with 480 Mins