Lines of Code (LoC) count for Pull Requests (PR) counts test code


  • GitLab Free self-managed 13.12.2-ee
  • Jenkins CI 2.289.1 with GitLab Branch Source Plugin 1.5.7
  • Gradle 6.6.1 Java 8 library project with SonarQube plugin in version 3.2.0
  • SonarQube self-managed developer edition 8.9

How to Reproduce

  1. Create a git project with at lease a main and a feature branch
  2. Create a pull request from feature too main
  3. Publish a scan to SonarQube from main
  4. Publish a scan to SonarQube from feature
  5. Publish a scan to SonarQube from the Pull Request build

Observed behavior

  • test code in branches are not count into the LoC
  • test code in pull requests are count into the LoC

Expected behavior

  • test code are not count into the LoC


Welcome to the community!

In fact, for PRs Lines (including comments, blank lines and yes, test lines) are counted rather than Lines of Code.


Thanks for the reply.

This means that PRs raise my LoC count which raises my license costs?


What counts toward LoC for license purposes is the Lines of Code of the largest branch of each project. It appears that Lines of Code aren’t even calculated for branches, so no they don’t raise your license cost.