How do I fetch the NCLOC value that is accounted on license?

I’m using an tool to automatically fetch the NCLOC value of a project using SonarQube’s WebAPI (/api/measures/search_history?component=$COMPONENT_NAME&metrics=ncloc)

  • Enterprise Edition
  • Version 9.9.1 (build 69595)

What my tool does is simply iterate through a list of previously saved project-keys and fetch their NCLOC value using the endpoint mentioned above, adding the details into a csv file. However, I’ve stumbled upon a doubt…

Question: Does the endpoint above return the ncloc of the component’s master branch or the project’s ncloc that’s accounted for in the license?

Cheers,

Hey there.

Unless you specify the branch, the main branch is being returned.

Check out this script written by my colleague to iterate through all branches of a project:

1 Like