示例#1
0
        public IssueTypeResult(string issueType, IDictionary <string, Term> detectedIssueTypes)
        {
            detectedIssueTypes.TryGetValue(issueType, out Term description);

            Name        = TransformationIssue.ReplaceEachUppercaseLetterWithASpaceAndTheLetter(issueType);
            Description = description;
        }
示例#2
0
        private IssueTypeResult AsIssueTypeResult(TransformationIssue transformationIssue)
        {
            var    issueType   = transformationIssue.IssueType;
            string?description = null;

            if (IssueAnalyzers.DetectedIssueTypes.TryGetValue(
                    issueType,
                    out var descriptionTerm
                    ))
            {
                description = descriptionTerm;
            }

            return(new IssueTypeResult
            {
                Name = Metadata.Terms.IssueTypes.With(
                    new
                {
                    issueType
                }
                    ),
                Description = description
            });
        }
示例#3
0
        private ReportResults CompileResults(IEnumerable <PageTemplate> pageTemplates)
        {
            var allIssues = pageTemplates
                            .SelectMany(pageTemplate => pageTemplate.WebParts)
                            .SelectMany(webPart => webPart.Properties)
                            .SelectMany(webPartProperty => webPartProperty.Transformation.Issues);

            if (!allIssues.Any())
            {
                return(new ReportResults()
                {
                    Type = ReportResultsType.String,
                    Status = ReportResultsStatus.Good,
                    Summary = Metadata.Terms.GoodSummary
                });
            }

            var oneIssueOfEachType = allIssues
                                     .GroupBy(transformationIssue => transformationIssue.IssueType)
                                     .Select(g => g.First());

            var issueTypes = oneIssueOfEachType
                             .Select(transformationIssue => new IssueTypeResult(transformationIssue.IssueType, IssueAnalyzers.DetectedIssueTypes));

            var issueTypesResult = new TableResult <IssueTypeResult>
            {
                Name = Metadata.Terms.TableTitles.IssueTypes,
                Rows = issueTypes
            };

            var usedIssueTypes = IssueAnalyzers.DetectedIssueTypes
                                 .Keys
                                 .Where(issueType => oneIssueOfEachType
                                        .Select(issue => issue.IssueType)
                                        .Contains(issueType)
                                        );

            var allTransformations = pageTemplates
                                     .SelectMany(pageTemplate => pageTemplate.WebParts)
                                     .SelectMany(webPart => webPart.Properties)
                                     .Select(webPartProperty => webPartProperty.Transformation)
                                     .GroupBy(transformation => transformation.FullName)
                                     .Select(g => g.First());

            var transformationsResultRows = allTransformations
                                            .Select(transformation => new TransformationResult(transformation, CountTransformationUses(transformation, pageTemplates), usedIssueTypes))
                                            .OrderBy(transformationResult => transformationResult.Uses);

            var transformationsResult = new TableResult <TransformationResult>
            {
                Name = Metadata.Terms.TableTitles.TransformationsWithIssues,
                Rows = transformationsResultRows
            };

            var transformationUsageResultRows = pageTemplates
                                                .SelectMany(AsTransformationUsageResults);

            var transformationUsageResult = new TableResult <TransformationUsageResult>
            {
                Name = Metadata.Terms.TableTitles.TransformationUsage,
                Rows = transformationUsageResultRows
            };

            var templateUsageResultRows = pageTemplates
                                          .SelectMany(pageTemplate => pageTemplate.Pages)
                                          .Select(page => new TemplateUsageResult(page));

            var templateUsageResult = new TableResult <TemplateUsageResult>
            {
                Name = Metadata.Terms.TableTitles.TemplateUsage,
                Rows = templateUsageResultRows
            };

            var summaryCount = allTransformations
                               .Select(transformation => transformation.Issues)
                               .Count();

            var issueTypesAsCsv = string.Join(',', usedIssueTypes
                                              .Select(issueType => TransformationIssue.ReplaceEachUppercaseLetterWithASpaceAndTheLetter(issueType)));

            return(new ReportResults()
            {
                Type = ReportResultsType.TableList,
                Status = ReportResultsStatus.Warning,
                Summary = Metadata.Terms.WarningSummary.With(new { summaryCount, issueTypesAsCsv }),
                Data = new
                {
                    issueTypesResult,
                    transformationsResult,
                    transformationUsageResult,
                    templateUsageResult
                }
            });
        }
示例#4
0
 private string IssueSnippet(TransformationIssue issue)
 {
     return($"{TransformationIssue.SnippetWrapper}{issue.CodeSnippet}{TransformationIssue.SnippetWrapper}");
 }