Example #1
0
 /// <summary>
 /// Constructor for the SonarBrowser Orchestrator.
 /// </summary>
 /// <param name="sonarConnector">Connector for SonarQube related searches.</param>
 /// <param name="mapper">AutoMapper interface.</param>
 /// <param name="activeDirectoryService">Service for ActiveDirectory related searches.</param>
 /// <param name="tfsConnector">Service for Tfs related searches.</param>
 /// <param name="loggingService">The error logging services.</param>
 public SonarBrowserOrchestrator(ISonarConnector sonarConnector, IMapper mapper, IActiveDirectoryService activeDirectoryService, ITfsConnector tfsConnector, ILoggingService loggingService)
 {
     _sonarConnector         = sonarConnector;
     _mapper                 = mapper;
     _activeDirectoryService = activeDirectoryService;
     _tfsConnector           = tfsConnector;
     _loggingService         = loggingService;
 }
Example #2
0
        /// <summary>
        /// Add the ChangeSet informations to an existing Sonar Issue.
        /// </summary>
        /// <param name="issue">The current Issue.</param>
        /// <param name="sonarConnector">The access to the Sonar Services.</param>
        /// <returns>The enriched Sonar Issue.</returns>
        private static Issue AddChangeSet(this Issue issue, ISonarConnector sonarConnector)
        {
            Issue returnIssue = issue;

            Source ChangeSetSource = issue.GetChangeSetAsync(sonarConnector);

            returnIssue.ChangetSet    = ChangeSetSource?.ChangeSet ?? default(int);
            returnIssue.ChangeSetDate = ChangeSetSource?.CreationDate ?? null;

            return(returnIssue);
        }
Example #3
0
        /// <summary>
        /// Call the SonarConnector and get the <see cref="Source"/> corresponding to the actual issue informations.
        /// </summary>
        /// <param name="sonarRequestGetChangeSet">The Issue informations used to detect the ChangeSet.</param>
        /// <param name="sonarConnector"></param>
        /// <returns>The <see cref="Source"/> containing the ChangeSet id, it's Date, ...</returns>
        private static Source GetChangeSetAsync(this Issue issue, ISonarConnector sonarConnector)
        {
            if (issue == null)
            {
                return(null);
            }

            SonarRequestGetChangeSet sonarRequestGetChangeSet = new SonarRequestGetChangeSet()
            {
                AuthorEmail = issue.IssueDetail.author,
                IssueDate   = issue.IssueDetail.creationDate,
                Component   = issue.IssueDetail.component,
                Line        = issue.IssueDetail.line
            };

            return(sonarConnector.GetChangeSet(sonarRequestGetChangeSet));
        }
Example #4
0
        /// <summary>
        /// The internal Assembler converting the <see cref="SearchIssuesResponse"/> to an enriched list of Sonar Issues.
        /// </summary>
        /// <param name="searchIssuesResponse">The list of Issues from the Sonar API.</param>
        /// <param name="groupADSet">The active directory information needed to get some informations.</param>
        /// <param name="mapper">The AutoMapper interface to create the Issues Detail <see cref="IssueDetail"/>.</param>
        /// <param name="sonarConnector">The link to the Sonar Services.</param>
        /// <returns>An enriched and filtered list of Sonar Issues.</returns>
        internal static List <Issue> CreateIssueSet(this SearchIssuesResponse searchIssuesResponse, GroupADSet groupADSet, IMapper mapper, ISonarConnector sonarConnector, ITfsConnector tfsConnector)
        {
            List <Issue> issueSet = new List <Issue>();

            if (searchIssuesResponse?.issues == null)
            {
                return(issueSet);
            }

            issueSet.Capacity = searchIssuesResponse.issues.Count;
            foreach (var responseIssue in searchIssuesResponse.issues)
            {
                if (responseIssue != null)
                {
                    Issue issue = new Issue()
                    {
                        IssueDetail = mapper.Map <IssueDetail>(responseIssue)
                    };

                    issue = issue.AddChangeSet(sonarConnector);
                    if (issue.ChangeSetDate != null && issue.ChangeSetDate?.AddDays(5) > issue.IssueDetail.creationDate)
                    {
                        issue = issue.AddCodeProject(tfsConnector);
                        issue = issue.AddActiveDirectoryGroup(groupADSet);
                        issue = issue.AddCodeLineCount(tfsConnector);

                        issueSet.Add(issue);
                    }
                }
            }

            issueSet.TrimExcess();
            return(issueSet);
        }