I'm trying to figure out a way to analyze code longevity in open source projects: that is, how long a specific line of code is active and in use.My current thinking is that a line of code's lifespan begins when it is first committed, and ends when one of the following occurs:It's edited or deleted, Excluded from builds,No code within its build is maintained for some period of time (say, a year).NOTE: As clarification on why an edit is being counted as death, edited lines would be counted as a new generation, or line of code. Also, unless there's an easy way to do this, there would be no accounting for the longevity of a lineage, or descent from an ancestor.What else would determine a line of code's lifespan?
How can I estimate the lifespan of a line of code?
version control;efficiency
Andy Ozment looked at OpenBSD in 2006 with the same sort of question: Milk or Wine: Does Software Security Improve with Age?You may be able to learn from his definition.  It's also a very interesting paper, with an interesting conclusion as well, one that hasn't been incorporated into software management lore:Over a period of 7.5 years and fifteen releases, 62% of the 140 vulnerabilities reported in OpenBSD were foundational: present in the code at the beginning of the study.It took more than two and a half years for the first half of these foundational vulnerabilities to be reported. We found that 61% of the source code in the final version studied is foundational: it remains unaltered from the initial version released 7.5 years earlier. The rate of reporting of foundational vulnerabilities in OpenBSD is thus likely to continue to greatly influence the overall rate of vulnerability reporting.We also found statistically significant evidence that the rate of foundational vulnerability reports decreased during the study period. We utilized a reliability growth model to estimate that 67.6% of the vulnerabilities in the foundation version had been found. The models estimate of the expected number of foundational vulnerabilities reported per day decreased from 0.051 at the start of the study to 0.024.