API lines of Code not matching Sonar Admin panel

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)+ 8.3.1.34397
  • what are you trying to achieve
    Accurate Line of Code Report per project through API
  • what have you tried so far to achieve this
    Generating a Line of Code report per project, however the numbers are not lining up.

We are nearing our 1m LoC threshold and trying to do some investigation as to where that is being eaten up, or what we can clean up. When I grab LoC per project through the API, I’m getting a number that is about 300,000 LoC short of what the Administration → License panel is showing. Suggestions?

API Steps: Grabbing all projects using api/projects/search then looping through each project and using /api/measures/component?component={Project}&metricKeys=ncloc

Hi,

For licensing purposes, the largest branch of each project is counted. I’m not sure what APIs you’re using but you probably need to look at the count of the project’s main branch and all the other branches to find the right numbers.

 
HTH,
Ann