private async Task SendErrorsAndThresholdThroughMail(InspectionsComparator comparer)
        {
            if (!_mailNotifier.IsSetUp)
            {
                Console.WriteLine("The Software Quality mail notifier is not set up");
                return;
            }

            var(newIssues, _, _) = comparer.GetComparison();
            var newErrors = newIssues.Where(i => i.Severity == Severity.ERROR).ToArray();

            var blamer = new GitBlamer(_gitPath);

            var(_, headCommit) = await _teamcityService.ComputeCommitRange(_buildId);

            var contributors = await blamer.GetNewContributors(headCommit, newErrors, newErrors.Length, ComputePathToRepo);

            foreach (var contributor in contributors)
            {
                try
                {
                    Console.WriteLine($"Sending mail to {contributor.Name} for errors in inspection");
                    var body = await GetBody(contributor.Contributions, contributor.Name);

                    await _mailNotifier.SendMail("Errors in daily inspection", contributor.Mail, contributor.Name, body);
                }
                catch (Exception e)
                {
                    Console.WriteLine($"Failed to send mail to {contributor.Name}: {e.Message}");
                }
            }
        }
Exemple #2
0
        private async Task <HangoutCard> GetLeaderBoardCard(DuplicateComparator comparator)
        {
            try
            {
                var(_, removedDuplicates, _) = comparator.GetComparison();

                var blamer = new GitBlamer(_gitPath);

                var(baseCommit, headCommit) = await _teamcityService.ComputeCommitRange(_buildId);

                var contributors = await blamer.GetRemovalContributors(baseCommit, headCommit, removedDuplicates, 3, file => file);

                var sections = new List <HangoutCardSection>();
                var rank     = 1;
                foreach (var contributor in contributors)
                {
                    sections.Add(CardBuilderHelper.GetKeyValueSection("Duplication has been removed by", contributor.Name, $"for a cost of {contributor.Contributions.Sum(f => f.Score)}", _ranks[rank]));
                    rank++;
                }

                return(new HangoutCard
                {
                    Header = CardBuilderHelper.GetCardHeader("Podium", "Who removed duplication", "https://icon-icons.com/icons2/9/PNG/128/podium_1511.png"),
                    Sections = sections.ToArray()
                });
            }
            catch (Exception)
            {
                Console.WriteLine("Failed to retrieve best contributors");
            }
            return(null);
        }
Exemple #3
0
        public async Task RunAsync()
        {
            var comparer = new InspectionsComparator(_old, _new, null);

            var(newIssues, removedIssues, _) = comparer.GetComparison();

            var blamer = new GitBlamer(_gitPath);

            var contributorsForNewViolations = await blamer.GetNewContributors(_headCommit, newIssues, 10, ComputePathToRepo);

            var contributorsForRemovalViolations = await blamer.GetRemovalContributors(_baseCommit, _headCommit, removedIssues, 10, ComputePathToRepo);

            Console.WriteLine("The top ten collaborators who added violations are:");
            var rank = 1;

            foreach (var collaborator in contributorsForNewViolations)
            {
                Console.WriteLine($"{rank}# {collaborator.Name} with {collaborator.Contributions.Count} fragments");
                rank++;
            }
            Console.WriteLine("");
            Console.WriteLine("The top ten collaborators who removed violations are:");
            var goodRank = 1;

            foreach (var collaborator in contributorsForRemovalViolations)
            {
                Console.WriteLine($"{goodRank}# {collaborator.Name} with {collaborator.Contributions.Count} fragments");
                goodRank++;
            }
        }