private void saveMeasure(SensorContext context, InputComponent component, String metricKey, String value) { org.sonar.api.batch.measure.Metric<Serializable> metric = metricFinder.findByKey(metricKey); if (metric == null) { throw new IllegalStateException("Unknow metric with key: " + metricKey); } NewMeasure<Serializable> newMeasure = context.newMeasure() .forMetric(metric) .on(component); if (Boolean.class.equals(metric.valueType())) { newMeasure.withValue(Boolean.parseBoolean(value)); } else if (Integer.class.equals(metric.valueType())) { newMeasure.withValue(Integer.valueOf(value)); } else if (Double.class.equals(metric.valueType())) { newMeasure.withValue(Double.valueOf(value)); } else if (String.class.equals(metric.valueType())) { newMeasure.withValue(value); } else if (Long.class.equals(metric.valueType())) { newMeasure.withValue(Long.valueOf(value)); } else { throw new UnsupportedOperationException("Unsupported type :" + metric.valueType()); } newMeasure.save(); }
private void saveMetricOnFile(SensorContext context, @Nullable InputFile inputFile, Metric<Integer> metric, int value) { if (inputFile != null) { context.<Integer>newMeasure().on(inputFile).forMetric(metric).withValue(value); } }
public void saveAnalysisErrors() { if (!isSonarLintContext() && !analysisErrors.isEmpty() && shouldCollectAnalysisErrors()) { Gson gson = new Gson(); String metricValue = gson.toJson(analysisErrors); context.<String>newMeasure().forMetric(FEEDBACK_METRIC).on(context.module()).withValue(metricValue).save(); } }
public void saveAnalysisErrors() { if (!isSonarLintContext() && !analysisErrors.isEmpty() && shouldCollectAnalysisErrors()) { Gson gson = new Gson(); String metricValue = gson.toJson(analysisErrors); context.<String>newMeasure().forMetric(FEEDBACK_METRIC).on(context.module()).withValue(metricValue).save(); } }
public static void saveMeasure(SensorContext context, InputComponent component, Metric<Long> metric, long value) { context.<Long>newMeasure() .on(component) .forMetric(metric) .withValue(value) .save(); }
public static void saveMeasure(SensorContext context, InputComponent component, Metric<Double> metric, double value) { context.<Double>newMeasure() .on(component) .forMetric(metric) .withValue(value) .save(); } }
public static void saveMeasure(SensorContext context, InputComponent component, Metric<Integer> metric, int value) { context.<Integer>newMeasure() .on(component) .forMetric(metric) .withValue(value) .save(); }
private static <T extends Serializable> void saveMeasure(SensorContext context, InputFile inputFile, Metric<T> metric, T value) { context.<T>newMeasure() .withValue(value) .forMetric(metric) .on(inputFile) .save(); }
private static void saveMeasure(SensorContext context, InputComponent component, Metric<Long> metric, long value) { context.<Long>newMeasure() .on(component) .forMetric(metric) .withValue(value) .save(); }
protected <T extends Serializable> void saveMetricOnFile(Metric metric, T value) { sensorContext.<T>newMeasure() .withValue(value) .forMetric(metric) .on(inputFile) .save(); }
private static void saveMeasure(SensorContext context, InputFile inputFile, Metric<Integer> metric, int value) { context.<Integer>newMeasure() .on(inputFile) .forMetric(metric) .withValue(value) .save(); }
private static <T extends Serializable> void saveMetric(SensorContext context, InputFile inputFile, Metric<T> metric, T value) { context.<T>newMeasure() .on(inputFile) .forMetric(metric) .withValue(value) .save(); }
private void saveMetricOnFile(InputFile inputFile, Metric<Integer> metric, Integer value) { context.<Integer>newMeasure() .withValue(value) .forMetric(metric) .on(inputFile) .save(); }
private static void saveMeasure(SensorContext context, InputComponent component, Metric<Integer> metric, int value) { context.<Integer>newMeasure() .on(component) .forMetric(metric) .withValue(value) .save(); }
/** * Reports a measure on specified file */ @SuppressWarnings({"rawtypes", "unchecked"}) public void reportMeasure(InputFile file, Metric metric, Serializable value) { context.newMeasure().forMetric(metric).on(file).withValue(value).save(); }
/** * Reports a measure on specified file */ @SuppressWarnings({"rawtypes", "unchecked"}) public void reportMeasure(InputFile file, Metric metric, Serializable value) { context.newMeasure().forMetric(metric).on(file).withValue(value).save(); }
private static void saveMeasure(SensorContext context, InputComponent component, Metric<Integer> metric, int value) { context.<Integer>newMeasure() .on(component) .forMetric(metric) .withValue(value) .save(); }
private static void saveFilesComplexityDistribution(SensorContext context, InputFile inputFile, int fileComplexity) { String distribution = new RangeDistributionBuilder(FILES_DISTRIB_BOTTOM_LIMITS) .add(fileComplexity) .build(); context.<String>newMeasure() .on(inputFile) .forMetric(CoreMetrics.FILE_COMPLEXITY_DISTRIBUTION) .withValue(distribution) .save(); }
private static <T extends Serializable> void saveMeasure(SensorContext context, InputFile inputFile, Metric<T> metric, T value) { LOGGER.warn(inputFile.absolutePath()); LOGGER.warn(metric.toString()); context.<T>newMeasure().forMetric(metric).on(inputFile).withValue(value).save(); } }
private static void saveFunctionsComplexityDistribution(SensorContext context, InputFile inputFile, AstNode rootNode) { RangeDistributionBuilder complexityDistribution = new RangeDistributionBuilder(FUNCTIONS_DISTRIB_BOTTOM_LIMITS); for (AstNode functionDef : rootNode.getDescendants(FlexGrammar.FUNCTION_DEF, FlexGrammar.FUNCTION_EXPR)) { complexityDistribution.add(ComplexityVisitor.complexity(functionDef)); } context.<String>newMeasure() .on(inputFile) .forMetric(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION) .withValue(complexityDistribution.build()) .save(); }