Lines of Code in stable branches

Template for a good new topic, formatted with Markdown:

  • ALM used: GitHub
  • CI system used: Jenkins
  • Languages of the repository: Java / Kotlin
  • Error observed

Last week we activated a new set of conditions for our repository so it’s included in our Quality Gate. Among the new conditions, we activated a hardcoded limit of new lines added. It works flawlessly on PRs, but when sonar runs on our main branch, it reports an error as there are thousands of lines added.

I do understand this number comes from the last “30 days of code added” in that branch. I was wondering if it makes sense at all to run these checks on long live branches at all. I’d like to know what would be the best way to restrict this “lines added” condition to run only on PRs, or to set different behaviours per branch.