From 532850a387e483592e6f2f80a5e833bcf218a58f Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Wed, 5 Dec 2018 10:23:09 +0100 Subject: Fix quality flaws --- .../src/main/java/org/sonar/xoo/XooPlugin.java | 4 +- .../org/sonar/xoo/global/GlobalProjectSensor.java | 44 ++++++++++++++++++++++ .../java/org/sonar/xoo/global/GlobalSensor.java | 44 ---------------------- 3 files changed, 46 insertions(+), 46 deletions(-) create mode 100644 plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/global/GlobalProjectSensor.java delete mode 100644 plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/global/GlobalSensor.java (limited to 'plugins/sonar-xoo-plugin') 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 73efd1d2580..8817e5575ec 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,7 +32,7 @@ import org.sonar.xoo.extensions.XooIssueFilter; import org.sonar.xoo.extensions.XooPostJob; import org.sonar.xoo.extensions.XooProjectBuilder; import org.sonar.xoo.global.DeprecatedGlobalSensor; -import org.sonar.xoo.global.GlobalSensor; +import org.sonar.xoo.global.GlobalProjectSensor; import org.sonar.xoo.lang.CpdTokenizerSensor; import org.sonar.xoo.lang.LineMeasureSensor; import org.sonar.xoo.lang.MeasureSensor; @@ -174,7 +174,7 @@ public class XooPlugin implements Plugin { context.addExtension(DeprecatedGlobalSensor.class); } if (context.getSonarQubeVersion().isGreaterThanOrEqual(Version.create(7, 6))) { - context.addExtension(GlobalSensor.class); + context.addExtension(GlobalProjectSensor.class); } if (context.getSonarQubeVersion().isGreaterThanOrEqual(Version.create(7, 2))) { context.addExtensions( diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/global/GlobalProjectSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/global/GlobalProjectSensor.java new file mode 100644 index 00000000000..67d214011f5 --- /dev/null +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/global/GlobalProjectSensor.java @@ -0,0 +1,44 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program 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. + * + * This program 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.global; + +import org.sonar.api.scanner.sensor.ProjectSensor; +import org.sonar.api.batch.sensor.SensorContext; +import org.sonar.api.batch.sensor.SensorDescriptor; +import org.sonar.api.utils.log.Logger; +import org.sonar.api.utils.log.Loggers; + +public class GlobalProjectSensor implements ProjectSensor { + + private static final Logger LOG = Loggers.get(GlobalProjectSensor.class); + public static final String ENABLE_PROP = "sonar.scanner.mediumtest.globalSensor"; + + @Override + public void describe(SensorDescriptor descriptor) { + descriptor + .name("Global Sensor") + .onlyWhenConfiguration(c -> c.hasKey(ENABLE_PROP)); + } + + @Override + public void execute(SensorContext context) { + context.fileSystem().inputFiles(context.fileSystem().predicates().all()).forEach(inputFile -> LOG.info("Global Sensor: {}", inputFile.relativePath())); + } +} diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/global/GlobalSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/global/GlobalSensor.java deleted file mode 100644 index e4aef94c692..00000000000 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/global/GlobalSensor.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.global; - -import org.sonar.api.scanner.sensor.Sensor; -import org.sonar.api.batch.sensor.SensorContext; -import org.sonar.api.batch.sensor.SensorDescriptor; -import org.sonar.api.utils.log.Logger; -import org.sonar.api.utils.log.Loggers; - -public class GlobalSensor implements Sensor { - - private static final Logger LOG = Loggers.get(GlobalSensor.class); - public static final String ENABLE_PROP = "sonar.scanner.mediumtest.globalSensor"; - - @Override - public void describe(SensorDescriptor descriptor) { - descriptor - .name("Global Sensor") - .onlyWhenConfiguration(c -> c.hasKey(ENABLE_PROP)); - } - - @Override - public void execute(SensorContext context) { - context.fileSystem().inputFiles(context.fileSystem().predicates().all()).forEach(inputFile -> LOG.info("Global Sensor: {}", inputFile.relativePath())); - } -} -- cgit v1.2.3