public void ProcessFileMeasure(DailyCodeChurn dailyCodeChurn, SonarMeasuresJson sonarMeasuresJson)
        {
            if (!ValidDailyCodeChurn(dailyCodeChurn))
            {
                return;
            }

            ProcessMetric(sonarMeasuresJson);

            var fileName = ProcessFileName(dailyCodeChurn.FileName, filePrefixToRemove);

            var existingMeasureRaw = sonarMeasuresJson.FindRawMeasure(metric.MetricKey, fileName) as Measure <T>;

            if (existingMeasureRaw == null)
            {
                sonarMeasuresJson.AddRawMeasure(new Measure <T>()
                {
                    MetricKey = this.metric.MetricKey,
                    Value     = measureAggregator.GetValueForNewMeasure(dailyCodeChurn),
                    File      = fileName
                });
            }
            else
            {
                existingMeasureRaw.Value = measureAggregator.GetValueForExistingMeasure(dailyCodeChurn, existingMeasureRaw);
            }
        }
        private bool ValidDailyCodeChurn(DailyCodeChurn dailyCodeChurn)
        {
            if (!measureAggregator.HasValue(dailyCodeChurn))
            {
                return(false);
            }

            return(true);
        }
Example #3
0
        private bool ValidDailyCodeChurn(DailyCodeChurn dailyCodeChurn)
        {
            if (dailyCodeChurn.GetDateTimeAsDateTime() < startDate || dailyCodeChurn.GetDateTimeAsDateTime() > endDate)
            {
                return(false);
            }

            if (!measureAggregator.HasValue(dailyCodeChurn))
            {
                return(false);
            }

            return(true);
        }
Example #4
0
        public int CompareTo(object obj)
        {
            DailyCodeChurn dest = (DailyCodeChurn)obj;

            var dates = this.Timestamp.CompareTo(dest.Timestamp);

            if (dates != 0)
            {
                return(dates);
            }
            else
            {
                return(this.FileName.CompareTo(dest.FileName));
            }
        }
Example #5
0
        private void AggregateLine(AggregatedDailyCodeChurn aggregatedDailyCodeChurn, DailyCodeChurn line)
        {
            aggregatedDailyCodeChurn.Added                       += line.Added;
            aggregatedDailyCodeChurn.AddedInFixesVCS             += line.AddedWithFixes;
            aggregatedDailyCodeChurn.ChangesAfter                += line.ChangesAfter;
            aggregatedDailyCodeChurn.ChangesAfterInFixesVCS      += line.ChangesAfterWithFixes;
            aggregatedDailyCodeChurn.ChangesBefore               += line.ChangesBefore;
            aggregatedDailyCodeChurn.ChangesBeforeInFixesVCS     += line.ChangesBeforeWithFixes;
            aggregatedDailyCodeChurn.Deleted                     += line.Deleted;
            aggregatedDailyCodeChurn.DeletedInFixesVCS           += line.DeletedWithFixes;
            aggregatedDailyCodeChurn.NumberOfChanges             += line.NumberOfChanges;
            aggregatedDailyCodeChurn.NumberOfChangesWithFixesVCS += line.NumberOfChangesWithFixes;

            AggregateAuthors(aggregatedDailyCodeChurn, line);
            AggregateBugDatabase(aggregatedDailyCodeChurn, line);
            aggregatedDailyCodeChurn.DailyCodeChurnPerFile.Add(line);
        }
Example #6
0
        private void ProcessLine(SortedDictionary <DateTime, AggregatedDailyCodeChurn> dict, DailyCodeChurn line, string fileWithoutPrefix)
        {
            if (!this.inclusionsProcessor.IsIncluded(fileWithoutPrefix))
            {
                return;
            }

            if (this.exclusionsProcessor.IsExcluded(fileWithoutPrefix))
            {
                return;
            }

            DateTime key = line.GetDateTimeAsDateTime().Date;

            if (!dict.ContainsKey(key))
            {
                dict.Add(key, new AggregatedDailyCodeChurn()
                {
                    Timestamp = key.ToString(AggregatedDailyCodeChurn.DATE_FORMAT, CultureInfo.InvariantCulture)
                });
            }

            AggregateLine(dict[key], line);
        }
Example #7
0
        private static void AggregateAuthors(AggregatedDailyCodeChurn aggregatedDailyCodeChurn, DailyCodeChurn line)
        {
            if (line.Authors == null)
            {
                return;
            }

            foreach (var a in line.Authors)
            {
                if (!aggregatedDailyCodeChurn.Authors.Exists(aut => aut.Author == a.Author))
                {
                    aggregatedDailyCodeChurn.Authors.Add(new DailyCodeChurnAuthor()
                    {
                        Author = a.Author
                    });
                }
                aggregatedDailyCodeChurn.Authors.Where(aut => aut.Author == a.Author).First().NumberOfChanges += a.NumberOfChanges;
            }
        }
Example #8
0
        private static void AggregateBugDatabase(AggregatedDailyCodeChurn aggregatedDailyCodeChurn, DailyCodeChurn line)
        {
            if (line.BugDatabase == null)
            {
                return;
            }

            aggregatedDailyCodeChurn.AddedInFixesBugDB             += line.BugDatabase.AddedInFixes;
            aggregatedDailyCodeChurn.ChangesAfterInFixesBugDB      += line.BugDatabase.ChangesAfterInFixes;
            aggregatedDailyCodeChurn.ChangesBeforeInFixesBugDB     += line.BugDatabase.ChangesBeforeInFixes;
            aggregatedDailyCodeChurn.DeletedInFixesBugDB           += line.BugDatabase.DeletedInFixes;
            aggregatedDailyCodeChurn.NumberOfChangesWithFixesBugDB += line.BugDatabase.NumberOfChangesInFixes;
        }