private static IEnumerable <DateModel> GetModels(FileMetricOverTime fileMetricOverTime) { return(fileMetricOverTime .FileMetricForCommits .OrderBy(x => x.Time) .Select(x => new DateModel(x.Time, x.CyclomaticComplexity))); }
public List <FileMetricOverTime> GetFileMetricOverTime(IEnumerable <GitCommit> gitCommits, IEnumerable <string> filePaths) { List <FileMetricOverTime> fileMetricsOverTime = new List <FileMetricOverTime>(); foreach (string filePath in filePaths) { FileMetricOverTime fileMetricOverTime = new FileMetricOverTime(filePath); foreach (GitCommit gitCommit in gitCommits) { if (gitCommit.ContainsFileNames(new List <string>() { filePath })) { SyntaxTree syntaxTree = GetSyntaxTree(GetFileContentForFilePath(filePath, gitCommit)); if (syntaxTree.Length == 0) { continue; } IEnumerable <INamespaceMetric> metrics = GetFileMetric(syntaxTree); if (metrics.Count() != 1) { continue; } INamespaceMetric metric = metrics.SingleOrDefault(); fileMetricOverTime.FileMetricForCommits.Add( new FileMetricForCommit(gitCommit.SHA, gitCommit.Time, metric.MaintainabilityIndex, metric.CyclomaticComplexity, metric.LinesOfCode)); } } fileMetricsOverTime.Add(fileMetricOverTime); } return(fileMetricsOverTime); }