From: Fabrice Bellingard Date: Mon, 8 Oct 2012 09:46:18 +0000 (+0200) Subject: Refactor code X-Git-Tag: 3.3~85 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3cee12889f13ab2784cf2db9138a7a417e8e4097;p=sonarqube.git Refactor code --- diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/TimeMachineWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/TimeMachineWidget.java index 564ffed857f..362a1437b83 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/TimeMachineWidget.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/TimeMachineWidget.java @@ -31,16 +31,16 @@ import org.sonar.api.web.WidgetPropertyType; @WidgetProperty(key = "title", type = WidgetPropertyType.STRING), @WidgetProperty(key = "numberOfColumns", type = WidgetPropertyType.INTEGER, defaultValue = "3"), @WidgetProperty(key = "displaySparkLine", type = WidgetPropertyType.BOOLEAN), - @WidgetProperty(key = "metric1", type = WidgetPropertyType.METRIC, defaultValue = "ncloc", options = {"key:^(?!new_).*"}), - @WidgetProperty(key = "metric2", type = WidgetPropertyType.METRIC, options = {"key:^(?!new_).*"}), - @WidgetProperty(key = "metric3", type = WidgetPropertyType.METRIC, options = {"key:^(?!new_).*"}), - @WidgetProperty(key = "metric4", type = WidgetPropertyType.METRIC, options = {"key:^(?!new_).*"}), - @WidgetProperty(key = "metric5", type = WidgetPropertyType.METRIC, options = {"key:^(?!new_).*"}), - @WidgetProperty(key = "metric6", type = WidgetPropertyType.METRIC, options = {"key:^(?!new_).*"}), - @WidgetProperty(key = "metric7", type = WidgetPropertyType.METRIC, options = {"key:^(?!new_).*"}), - @WidgetProperty(key = "metric8", type = WidgetPropertyType.METRIC, options = {"key:^(?!new_).*"}), - @WidgetProperty(key = "metric9", type = WidgetPropertyType.METRIC, options = {"key:^(?!new_).*"}), - @WidgetProperty(key = "metric10", type = WidgetPropertyType.METRIC, options = {"key:^(?!new_).*"}) + @WidgetProperty(key = "metric1", type = WidgetPropertyType.METRIC, defaultValue = "ncloc", options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "metric2", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "metric3", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "metric4", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "metric5", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "metric6", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "metric7", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "metric8", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "metric9", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "metric10", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}) }) public class TimeMachineWidget extends AbstractRubyTemplate implements RubyRailsWidget { public String getId() { diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/TimelineWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/TimelineWidget.java index 5d8c0e303be..aa540fb8859 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/TimelineWidget.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/TimelineWidget.java @@ -29,9 +29,9 @@ import org.sonar.api.web.WidgetPropertyType; @WidgetCategory("History") @WidgetProperties({ @WidgetProperty(key = "chartTitle", type = WidgetPropertyType.STRING), - @WidgetProperty(key = "metric1", type = WidgetPropertyType.METRIC, defaultValue = "ncloc", options = {"key:^(?!new_).*"}), - @WidgetProperty(key = "metric2", type = WidgetPropertyType.METRIC, options = {"key:^(?!new_).*"}), - @WidgetProperty(key = "metric3", type = WidgetPropertyType.METRIC, options = {"key:^(?!new_).*"}), + @WidgetProperty(key = "metric1", type = WidgetPropertyType.METRIC, defaultValue = "ncloc", options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "metric2", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}), + @WidgetProperty(key = "metric3", type = WidgetPropertyType.METRIC, options = {WidgetsConstants.FILTER_OUT_NEW_METRICS}), @WidgetProperty(key = "hideEvents", type = WidgetPropertyType.BOOLEAN), @WidgetProperty(key = "chartHeight", type = WidgetPropertyType.INTEGER, defaultValue = "80") }) diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/WidgetsConstants.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/WidgetsConstants.java new file mode 100644 index 00000000000..7fab6f3c020 --- /dev/null +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/WidgetsConstants.java @@ -0,0 +1,34 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2012 SonarSource + * mailto:contact AT sonarsource DOT com + * + * Sonar 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. + * + * Sonar 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 Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.plugins.core.widgets; + +import org.sonar.api.web.WidgetProperty; + +/** + * Constants shared accross multiple widgets + */ +interface WidgetsConstants { + + /** + * Widget property option used to filter out all the metrics which keys start with "new_". + * @see WidgetProperty#options() + */ + String FILTER_OUT_NEW_METRICS = "key:^(?!new_).*"; +}