summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2015-12-04 11:41:15 +0100
committerSimon Brandhof <simon.brandhof@sonarsource.com>2015-12-07 17:26:43 +0100
commit6cf62f0adc9677404df3ff457135591c17ad89a5 (patch)
tree08b31db10e52e92575a6343768f93e46b13266b7 /plugins
parent541c15654fc024534c45710b30b9cfc8ec551d96 (diff)
downloadsonarqube-6cf62f0adc9677404df3ff457135591c17ad89a5.tar.gz
sonarqube-6cf62f0adc9677404df3ff457135591c17ad89a5.zip
SONAR-6939 ability for plugins to override the decimal scale of float
measures
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java6
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/measures/ConstantFloatMeasureSensor.java74
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/measures/XooMetrics.java43
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/measures/package-info.java25
4 files changed, 0 insertions, 148 deletions
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java
index a2cb7066e0a..598be59d3dc 100644
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java
+++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java
@@ -32,8 +32,6 @@ import org.sonar.xoo.lang.SymbolReferencesSensor;
import org.sonar.xoo.lang.SyntaxHighlightingSensor;
import org.sonar.xoo.lang.XooCpdMapping;
import org.sonar.xoo.lang.XooTokenizer;
-import org.sonar.xoo.measures.ConstantFloatMeasureSensor;
-import org.sonar.xoo.measures.XooMetrics;
import org.sonar.xoo.rule.ChecksSensor;
import org.sonar.xoo.rule.CreateIssueByInternalKeySensor;
import org.sonar.xoo.rule.DeprecatedResourceApiSensor;
@@ -115,10 +113,6 @@ public class XooPlugin extends SonarPlugin {
TestExecutionSensor.class,
CoveragePerTestSensor.class,
- // Measures
- XooMetrics.class,
- ConstantFloatMeasureSensor.class,
-
// Other
XooProjectBuilder.class,
XooPostJob.class);
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/measures/ConstantFloatMeasureSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/measures/ConstantFloatMeasureSensor.java
deleted file mode 100644
index 416efe2bc39..00000000000
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/measures/ConstantFloatMeasureSensor.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package org.sonar.xoo.measures;
-
-import org.sonar.api.batch.Sensor;
-import org.sonar.api.batch.SensorContext;
-import org.sonar.api.batch.fs.FileSystem;
-import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.config.Settings;
-import org.sonar.api.measures.Measure;
-import org.sonar.api.resources.Project;
-import org.sonar.xoo.Xoo;
-
-/**
- * Save a constant float measure on each XOO source file
- */
-public class ConstantFloatMeasureSensor implements Sensor {
-
- public static final String SONAR_XOO_ENABLE_FLOAT_SENSOR = "sonar.xoo.enableFloatSensor";
- public static final String SONAR_XOO_FLOAT_PRECISION = "sonar.xoo.floatPrecision";
-
- public static final double CONSTANT_VALUE = 1.2345678910111213d;
-
- private final FileSystem fs;
- private final Settings settings;
-
- public ConstantFloatMeasureSensor(FileSystem fs, Settings settings) {
- this.fs = fs;
- this.settings = settings;
- }
-
- @Override
- public boolean shouldExecuteOnProject(Project project) {
- return fs.hasFiles(fs.predicates().hasLanguage(Xoo.KEY)) && settings.getBoolean(
- SONAR_XOO_ENABLE_FLOAT_SENSOR);
- }
-
- @Override
- public void analyse(Project project, SensorContext context) {
- Measure<?> floatMeasure = settings.hasKey(SONAR_XOO_FLOAT_PRECISION)
- ? new Measure<>(XooMetrics.CONSTANT_FLOAT_MEASURE, CONSTANT_VALUE, settings.getInt(SONAR_XOO_FLOAT_PRECISION))
- : new Measure<>(XooMetrics.CONSTANT_FLOAT_MEASURE, CONSTANT_VALUE);
- for (InputFile inputFile : getSourceFiles()) {
- context.saveMeasure(inputFile, floatMeasure);
- }
- }
-
- private Iterable<InputFile> getSourceFiles() {
- return fs.inputFiles(fs.predicates().and(fs.predicates().hasLanguage(Xoo.KEY), fs.predicates().hasType(InputFile.Type.MAIN)));
- }
-
- @Override
- public String toString() {
- return getClass().getSimpleName();
- }
-}
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/measures/XooMetrics.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/measures/XooMetrics.java
deleted file mode 100644
index 511baf2761c..00000000000
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/measures/XooMetrics.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-package org.sonar.xoo.measures;
-
-import com.google.common.collect.Lists;
-import java.util.List;
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.measures.Metric;
-import org.sonar.api.measures.Metrics;
-
-public final class XooMetrics implements Metrics {
-
- public static final String CONSTANT_FLOAT_MEASURE_KEY = "xoo_constant_float_measure";
-
- public static final Metric<Float> CONSTANT_FLOAT_MEASURE = new Metric.Builder(CONSTANT_FLOAT_MEASURE_KEY, "Constant float measure", Metric.ValueType.FLOAT)
- .setDescription("Return always the same float measure for every components")
- .setDirection(Metric.DIRECTION_WORST)
- .setDomain(CoreMetrics.DOMAIN_GENERAL)
- .create();
-
- @Override
- public List<Metric> getMetrics() {
- return Lists.<Metric>newArrayList(CONSTANT_FLOAT_MEASURE);
- }
-}
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/measures/package-info.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/measures/package-info.java
deleted file mode 100644
index 53dbecc35dc..00000000000
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/measures/package-info.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-@ParametersAreNonnullByDefault
-package org.sonar.xoo.measures;
-
-import javax.annotation.ParametersAreNonnullByDefault;
-