예제 #1
0
        private void BuildFirstCommitStats(Commit commit, LinesOfChange result)
        {
            var stats = _repository.Diff.Compare <PatchStats>(null, commit.Tree);

            result.Added   += stats.TotalLinesAdded;
            result.Removed += stats.TotalLinesDeleted;
        }
예제 #2
0
        private LinesOfChange Change_Stats(Author developer)
        {
            var result = new LinesOfChange();

            var developerCommits = GetCommits()
                                   .Where(x => developer.Emails.Contains(x.Author.Email))
                                   .OrderBy(x => x.Author.When.Date);

            foreach (var commit in developerCommits)
            {
                if (FirstCommit(commit))
                {
                    BuildFirstCommitStats(commit, result);
                    continue;
                }

                BuildCommitStats(commit, result);
            }

            var productionLinesPerHour = Calculate_Lines_Per_Hour(developer, result.Added - result.Removed);

            result.ChangePerHour = Calculate_Lines_Per_Hour(developer, result.TotalLines);
            result.Rtt100        = Math.Round(100.0 / result.ChangePerHour, 2);
            result.Ptt100        = Math.Abs(Math.Round(100.0 / productionLinesPerHour, 2));

            return(result);
        }
예제 #3
0
        public void TotalLines_ShouldSumOfAddedAndRemoved()
        {
            // arrange
            var sut = new LinesOfChange {
                Removed = 5, Added = 10
            };
            // act
            var actual = sut.TotalLines;

            // assert
            actual.Should().Be(15);
        }
예제 #4
0
        public void Churn_WhenRemovedAndAddedNonZero_ShouldReturnRemovedDividedByAddedToTwoDecimals()
        {
            // arrange
            var sut = new LinesOfChange {
                Removed = 1, Added = 3
            };
            // act
            var actual = sut.Churn;

            // assert
            actual.Should().Be(0.33);
        }
예제 #5
0
        public void Churn_WhenRemovedZeroAddedNonZero_ShouldReturnZero()
        {
            // arrange
            var sut = new LinesOfChange {
                Removed = 0, Added = 10
            };
            // act
            var actual = sut.Churn;

            // assert
            actual.Should().Be(0.0);
        }
예제 #6
0
        private void BuildCommitStats(Commit commit, LinesOfChange result)
        {
            foreach (var parent in commit.Parents)
            {
                var fileChanges = _repository.Diff.Compare <Patch>(parent.Tree, commit.Tree);
                var totalCommentedOutlinesToRemove = TotalCommentedOutLinesToDeduct(fileChanges);

                foreach (var file in fileChanges)
                {
                    if (FileShouldBeIgnored(file))
                    {
                        continue;
                    }

                    result.Added   += file.LinesAdded - totalCommentedOutlinesToRemove;
                    result.Removed += file.LinesDeleted;
                }
            }
        }