*/
package org.sonar.xoo;
-import org.sonar.xoo.rule.OneBlockerIssuePerFileSensor;
-
-import org.sonar.xoo.rule.HasTagSensor;
-import org.sonar.xoo.rule.OneIssuePerModuleSensor;
-import org.sonar.xoo.rule.OneIssuePerFileSensor;
-import org.sonar.xoo.rule.Xoo2BasicProfile;
+import java.util.Arrays;
+import java.util.List;
import org.sonar.api.SonarPlugin;
import org.sonar.xoo.coverage.ItCoverageSensor;
import org.sonar.xoo.coverage.OverallCoverageSensor;
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;
+import org.sonar.xoo.rule.HasTagSensor;
import org.sonar.xoo.rule.MultilineIssuesSensor;
+import org.sonar.xoo.rule.OneBlockerIssuePerFileSensor;
import org.sonar.xoo.rule.OneIssueOnDirPerFileSensor;
+import org.sonar.xoo.rule.OneIssuePerFileSensor;
import org.sonar.xoo.rule.OneIssuePerLineSensor;
+import org.sonar.xoo.rule.OneIssuePerModuleSensor;
import org.sonar.xoo.rule.RandomAccessSensor;
+import org.sonar.xoo.rule.Xoo2BasicProfile;
+import org.sonar.xoo.rule.XooBasicProfile;
import org.sonar.xoo.rule.XooEmptyProfile;
import org.sonar.xoo.rule.XooFakeExporter;
import org.sonar.xoo.rule.XooFakeImporter;
import org.sonar.xoo.rule.XooFakeImporterWithMessages;
-import org.sonar.xoo.rule.XooBasicProfile;
import org.sonar.xoo.rule.XooRulesDefinition;
import org.sonar.xoo.scm.XooBlameCommand;
import org.sonar.xoo.scm.XooScmProvider;
import org.sonar.xoo.test.CoveragePerTestSensor;
import org.sonar.xoo.test.TestExecutionSensor;
-import java.util.Arrays;
-import java.util.List;
-
/**
* Plugin entry-point, as declared in pom.xml.
*/
TestExecutionSensor.class,
CoveragePerTestSensor.class,
+ // Measures
+ XooMetrics.class,
+ ConstantFloatMeasureSensor.class,
+
// Other
XooProjectBuilder.class,
XooPostJob.class);
--- /dev/null
+/*
+ * 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.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 {
+
+ private static final double CONSTANT_VALUE = 1.2345678910111213d;
+
+ private final FileSystem fs;
+
+ public ConstantFloatMeasureSensor(FileSystem fs) {
+ this.fs = fs;
+ }
+
+ @Override
+ public boolean shouldExecuteOnProject(Project project) {
+ return fs.hasFiles(fs.predicates().hasLanguage(Xoo.KEY));
+ }
+
+ @Override
+ public void analyse(Project project, SensorContext context) {
+ Measure<?> floatMeasure = 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();
+ }
+}
--- /dev/null
+/*
+ * 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);
+ }
+}
--- /dev/null
+/*
+ * 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;
+