コード例 #1
0
        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();
            }
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        private void ProcessMetric(SonarMeasuresJson sonarMeasuresJson)
        {
            if (processedMetric)
            {
                return;
            }

            sonarMeasuresJson.Metrics.Add(metric);

            processedMetric = true;
        }
コード例 #4
0
        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);
            }
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }