Difference api/issues/search vs api/measures/component

Hey, I want the number of ALL CodeSmells for a project and used:

http://localhost:9000/api/issues/search?ps=100&types=CODE_SMELL&component={KEY}

this here will give me a huge number.

http://localhost:9000/api/measures/component?metricKeys=code_smells&component={KEY}

This here will give me the same number as in the screenshot.

image

So which method is the right one if I want to know all CodeSmells in a project? How can there be such a difference? I am very confused.

GET api/issues/search is returning all Code Smells ever raised on the project (whether they are now fixed, marked as false-positive, etc.) You can check the Web API documentation for how to further narrow this result set if needed.

GET api/measures/component is returning the existing number of open code smells.

1 Like

http://localhost:9000/api/measures/component?metricKeys=sqale_index&component={KEY}
Is it right, that I would get the debts with this URL? Hence the the JSON file says sqale_index gives the debts in days.

The problem is as you can see above there are only 2h debts but it gives me 130 as value in the JSON file.

Do you know why?

Or are the 2h only the CodeSmells debts?

The data is actually being returned in minutes (130 minutes = 2 hours)

This should be fixed in the GET api/metrics/search response as of SonarQube v7.7 (SONAR-11802) and will be fixed in the Metrics Definitions documentation soon (SONAR-13137)