Question about lines of code and cleanup

I am sure this must have been covered before, but I can’t find the answer. If there is already an answer, please point me to it.
We have a license for certain lines of code ( 9.9LTS). We do not need to keep everything forever. I did read some explanations about how the lines are counted, but it is a bit confusing. Here is my question. I know I can delete the projects that have not been analyzed in a certain period (either through the GUI or I believe via API api/projects/bulk_delete). I also believe that in the Administration/General Settings/Housekeeping settings may be used. So, thus I need advice on what is a better way (settings) or others. Also do I need to delete a project or just analysis to make sure the lines of code number go down? Any help/advice is much appreciated.


Housekeeping won’t delete projects, only stale project analyses. If you want to delete projects, you’ll need to do that yourself.

If your code is still in use (and thus still under occasional development) you probably don’t want to delete it. But if you’re dealing with a truly dead project, then you’ll want to delete the project as a whole. License LOC is based on the LOC in the largest branch or PR from each project. So as long as a dead project exists in your instance, it’s counted toward your license usage.


Thank you @ganncamp. In most cases we don’t have truly dead projects. However, I think the logic we would use is that if we did not touch it, say for 6 months, then we can get rid of it. When it is being worked on again, it will get created and analyzed. That said, and correct me if I am wrong, the only option to minimize the number of LOC, is to periodically delete projects older (not touched) than say 6 months. That can be accomplished by manual deletion in the GUI or by using api POST api/projects/bulk_delete with the analyzedBefore parameter being the date that is 6 months before. Thank you in advance !


If you do that, you’ll lose your baseline for New Code. I.e. it will make it more difficult to understand the quality of the code being changed (versus the old code in the project).

To minimize license usage you can:

  • make sure your projects are scoped properly, e.g. not including 3rd-party libraries in the analysis, large data files, generated files &etc.
  • make sure any branches that did accidentally analyze extra code get deleted
  • or yes, delete dead projects.

TBH, I would do this via the GUI so you can look over what will be deleted before you pull the trigger. But yes, you can do it with the API.

May I ask what your edition and license size are? Because license costs generally (yes, there are a few roadbumps in there) scale very reasonably.


Thanks @ganncamp !
We have developer edition and 1,000,000 LOC and we have some room yet. Right now, it only has about a year’s worth of history as we had to start from scratch about a year ago. I would have to talk to developers and their managers as to what they would consider dead projects. We can always find out what the next step in the lines of code is and the price, if they still want to keep the old code, even if the project has not been touched in a while. Let me talk to them to see what their preference is.
I just want to make sure that I keep configuration in check :slight_smile: . The one good thing that was added recently is an API to get license usage by project. It is very helpful :+1:t2:

1 Like