public void ProcessProjectMeasure(SonarMeasuresJson sonarMeasuresJson)
        {
            if (!projectMeasure)
            {
                return;
            }

            ProcessMetric(sonarMeasuresJson);

            var existingMeasureProject   = sonarMeasuresJson.FindProjectMeasure(metric.MetricKey) as Measure <T>;
            var projectMeasureAggregator = measureAggregator as IMeasureAggregatorProject <T>;

            if (existingMeasureProject == null)
            {
                sonarMeasuresJson.AddProjectMeasure(new Measure <T>()
                {
                    MetricKey = this.metric.MetricKey,
                    Value     = projectMeasureAggregator.GetValueForProjectMeasure()
                });
            }
            else
            {
                existingMeasureProject.Value = projectMeasureAggregator.GetValueForProjectMeasure();
            }
        }
        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 void ProcessMetric(SonarMeasuresJson sonarMeasuresJson)
        {
            if (processedMetric)
            {
                return;
            }

            sonarMeasuresJson.Metrics.Add(metric);

            processedMetric = true;
        }
        private void ProcessDailyCodeChurnList(IList <DailyCodeChurn> codeChurnList, SonarMeasuresJson outputJson)
        {
            foreach (var converter in measureConverters)
            {
                foreach (var codeChurn in codeChurnList)
                {
                    converter.ProcessFileMeasure(codeChurn, outputJson);
                }

                converter.ProcessProjectMeasure(outputJson);
            }
        }
        public void Process(SonarGenericMetricsCosmosDbCommandLineArgs a, Dictionary <DateTime, Dictionary <string, DailyCodeChurn> > data)
        {
            var documentsPerDay = dataConverter.ConvertDictToOrderedListPerDay(data);
            var outputJson      = new SonarMeasuresJson();

            foreach (var document in documentsPerDay)
            {
                this.logger.LogToConsole($"Processing document with date: {document.Key}");
                var codeChurnList = document.Value.Values;
                ProcessDailyCodeChurnList(codeChurnList, outputJson);
            }

            this.jsonExporter.Export(outputJson, a.OutputFile);
        }
        public void Process(SonarGenericMetricsCommandLineArgs a)
        {
            var files      = fileSystem.GetFiles(a.InputDir, "*.json");
            var outputJson = new SonarMeasuresJson();

            foreach (var file in files)
            {
                this.logger.LogToConsole($"Processing {file.FileName}");
                var codeChurnList = this.dailyCodeChurnParser.ParseFile(file.FileName);
                ProcessDailyCodeChurnList(codeChurnList, outputJson);
            }

            this.jsonExporter.Export(outputJson, a.OutputFile);
        }