コード例 #1
0
ファイル: Issues.cs プロジェクト: Cyrinehl/Portail
        public SonarIssuesSearch Search(SonarIssuesSearchArgs sonarIssuesSearchArg, NameValueCollection configuration)
        {
            string url = string.Format("{0}api/issues/search{1}", SonarApiClient.BaseAddress, (sonarIssuesSearchArg == null) ? String.Empty : sonarIssuesSearchArg.ToString());

            return(SonarApiClient.QueryObject <SonarIssuesSearch>(url, configuration));
        }
コード例 #2
0
ファイル: Issues.cs プロジェクト: Cyrinehl/Portail
        public async Task <SonarIssuesSearch> SearchAsync(SonarIssuesSearchArgs sonarIssuesSearchArg, NameValueCollection configuration)
        {
            string url = string.Format("{0}api/issues/search{1}", SonarApiClient.BaseAddress, (sonarIssuesSearchArg == null) ? String.Empty : sonarIssuesSearchArg.ToString());

            return(await SonarApiClient.QueryObjectAsync <SonarIssuesSearch>(url, configuration).ConfigureAwait(false));
        }
コード例 #3
0
        public static void ExtractIssues(IConfigurationRoot configuration)
        {
            List <Profile> list = new List <Profile>();

            list = TreatExport.ExtractProfiles(configuration); //services for the wanted profiles


            SonarApiClient SonarClient = new SonarApiClient(configuration);

            SonarIssuesSearchArgs SonarIssuesSearch = new SonarIssuesSearchArgs();

            SonarIssuesSearch.Rules = RulesKey; //issues for the wanted rules

            foreach (Profile profile in list)
            {
                List <Build> tmpList      = profile.profileBuilds;
                int          countTmpList = tmpList.Count;


                for (int i = 0; i < countTmpList; i++)
                {// issues for each service
                    SonarIssuesSearch SonarIssues = new SonarIssuesSearch();
                    SonarIssuesSearch.ProjectKeys.Add(tmpList[i].buildKey);

                    SonarIssues = SonarClient.Issues.Search(SonarIssuesSearch, configuration);

                    // fill list a issue for each service
                    while (SonarIssues.Issues.Count < SonarIssues.Paging.Total)
                    {
                        SonarIssuesSearch.SonarPagingQuery.PageIndex++;
                        SonarIssuesSearch tmp = SonarClient.Issues.Search(SonarIssuesSearch, configuration);
                        foreach (SonarIssue issue in tmp.Issues)
                        {
                            SonarIssues.Issues.Add(issue);
                        }
                    }

                    // fill issues list (the private static variable)
                    foreach (SonarIssue issue in SonarIssues.Issues)
                    {
                        Issue b = new Issue();

                        b.ProfileName = tmpList[i].ProfileName;
                        b.projectName = tmpList[i].buildName;
                        b.RuleKey     = issue.RuleKey;
                        b.Severity    = issue.Severity;
                        b.Type        = issue.Type;
                        b.Assignee    = issue.Assignee;
                        b.Line        = issue.Line;
                        b.ModuleKey   = issue.SubProject;
                        b.fileKey     = issue.Component;
                        issues.Add(b);
                    }

                    SonarIssuesSearch.ProjectKeys.Clear();
                }
            }

            foreach (Issue issue in issues)
            {
                SonarComponentShowArgs SonarComponentShowArgsModule = new SonarComponentShowArgs();
                SonarComponentShowArgs SonarComponentShowArgsFile   = new SonarComponentShowArgs();

                if ((String.IsNullOrEmpty(issue.ModuleKey)))
                {
                }
                else
                {
                    SonarComponentShowArgsModule.ComponentKey = issue.ModuleKey;
                    ComponentShowResponse ComponentShowResponseModule = SonarClient.Components.Show(SonarComponentShowArgsModule, configuration);
                    issue.Module = ComponentShowResponseModule.Component.ComponentName;
                }


                if ((String.IsNullOrEmpty(issue.fileKey)))
                {
                }
                else
                {
                    SonarComponentShowArgsFile.ComponentKey = issue.fileKey;
                    ComponentShowResponse ComponentShowResponseFile = SonarClient.Components.Show(SonarComponentShowArgsFile, configuration);
                    issue.file = ComponentShowResponseFile.Component.ComponentName;
                }
            }
        }