Пример #1
0
 /// <summary>
 /// Calculate number of fixed bugs were fixed in revision or before it.
 /// </summary>
 /// <param name="code"></param>
 /// <param name="revision"></param>
 /// <returns></returns>
 public static int CalculateNumberOfDefects(this CodeBlockSelectionExpression code, string revision)
 {
     return(code.ModifiedBy()
            .Modifications().ContainCodeBlocks()
            .Commits().TillRevision(revision).ContainModifications()
            .BugFixes().InCommits().Count());
 }
Пример #2
0
        /// <summary>
        /// Calculates traditional defect density for specified code.
        /// Total code size is LOC at the moment
        /// (added code minus removed code).
        /// </summary>
        /// <param name="code">Code set to calc metric for.</param>
        /// <returns>Defect density.</returns>
        public static double CalculateTraditionalDefectDensity(this CodeBlockSelectionExpression code)
        {
            code = code.Added().Fixed();

            return(CalculateDefectDensity(
                       code.CalculateLOC() + code.ModifiedBy().Deleted().CalculateLOC(),
                       code.CalculateNumberOfDefects()
                       ));
        }
Пример #3
0
 /// <summary>
 /// Calculate number of fixed bugs in specified code
 /// </summary>
 public static int CalculateNumberOfDefects(this CodeBlockSelectionExpression code)
 {
     return(code.ModifiedBy()
            .Modifications()
            .ContainCodeBlocks()
            .Commits()
            .ContainModifications()
            .AreBugFixes()
            .Count());
 }
Пример #4
0
 public static double CalculateDefectCodeSize(this CodeBlockSelectionExpression code)
 {
     return(-code.ModifiedBy().InBugFixes().CalculateLOC());
 }