Exemplo n.º 1
0
        public ComponentShowResponse Show(SonarComponentShowArgs SonarComponentShowArgs, NameValueCollection configuration)
        {
            string url = string.Format("{0}api/components/show{1}", SonarApiClient.BaseAddress, (SonarComponentShowArgs == null) ? String.Empty : SonarComponentShowArgs.ToString());

            return(SonarApiClient.QueryObject <ComponentShowResponse>(url, configuration));
        }
Exemplo n.º 2
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;
                }
            }
        }