Пример #1
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()
                       ));
        }
Пример #2
0
        /// <summary>
        /// Calculates alternative defect density for specified code.
        /// Total code size is added LOC at the moment.
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public static double CalculateDefectDensity(this CodeBlockSelectionExpression code)
        {
            code = code.Added().Fixed();

            return(CalculateDefectDensity(
                       code.CalculateLOC(),
                       code.CalculateNumberOfDefects()
                       ));
        }
Пример #3
0
        public static double CalculateDefectCodeSizePerDefect(this CodeBlockSelectionExpression code, string revision)
        {
            code = code.Fixed();

            int numberOfDefects = code.CalculateNumberOfDefects(revision);

            return(numberOfDefects > 0 ?
                   code.CalculateDefectCodeSize(revision) / numberOfDefects
                                :
                   0);
        }
Пример #4
0
        public static double CalculateDefectDensity(this CodeBlockSelectionExpression code, string revision)
        {
            code = code
                   .Commits().TillRevision(revision)
                   .CodeBlocks().Again().AddedInitiallyInCommits().Fixed();

            return(CalculateDefectDensity(
                       code.CalculateLOC(),
                       code.CalculateNumberOfDefects(revision)
                       ));
        }
Пример #5
0
        /// <summary>
        /// Calculate traditional defect density for specified code
        /// were added in revision or before it.
        /// </summary>
        public static double CalculateTraditionalDefectDensity(this CodeBlockSelectionExpression code, string revision)
        {
            code = code
                   .Commits().TillRevision(revision)
                   .CodeBlocks().Again().AddedInitiallyInCommits().Fixed();

            return(CalculateDefectDensity(
                       code.CalculateNumberOfDefects(revision),
                       code.CalculateLOC()
                       +
                       code
                       .Modifications().InCommits()
                       .CodeBlocks().Again().ModifiedBy().Removed().InModifications().CalculateLOC()
                       ));
        }