From 8cd5036d05ee239a7419c2bd41084e66e00911d8 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Fri, 11 Jul 2014 10:47:29 +0200 Subject: SONAR-5450 Add a Technical debt synopsis widget --- .../java/org/sonar/plugins/core/CorePlugin.java | 1 + .../core/dashboards/ProjectDefaultDashboard.java | 2 +- .../plugins/core/widgets/DebtOverviewWidget.java | 33 +++++++++++ .../sonar/plugins/core/widgets/debt_overview.erb | 64 ++++++++++++++++++++++ 4 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/DebtOverviewWidget.java create mode 100644 plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/debt_overview.erb (limited to 'plugins') diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java index 484ff746d68..1c9bdcf3045 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java @@ -226,6 +226,7 @@ public final class CorePlugin extends SonarPlugin { MeasureFilterAsHistogramWidget.class, MeasureFilterAsBubbleChartWidget.class, ProjectFileCloudWidget.class, + DebtOverviewWidget.class, // dashboards ProjectDefaultDashboard.class, diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/ProjectDefaultDashboard.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/ProjectDefaultDashboard.java index 7412127acf8..96799dfec2c 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/ProjectDefaultDashboard.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/ProjectDefaultDashboard.java @@ -53,7 +53,7 @@ public final class ProjectDefaultDashboard extends DashboardTemplate { } private void addSecondColumn(Dashboard dashboard) { - dashboard.addWidget("technical_debt", 2); + dashboard.addWidget("debt_overview", 2); dashboard.addWidget("rules", 2); dashboard.addWidget("alerts", 2); dashboard.addWidget("file_design", 2); diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/DebtOverviewWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/DebtOverviewWidget.java new file mode 100644 index 00000000000..9af75bbbdd3 --- /dev/null +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/DebtOverviewWidget.java @@ -0,0 +1,33 @@ +/* + * 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.plugins.core.widgets; + +import org.sonar.api.web.UserRole; +import org.sonar.api.web.WidgetCategory; + +@UserRole(UserRole.USER) +@WidgetCategory("Technical Debt") +public final class DebtOverviewWidget extends CoreWidget { + + public DebtOverviewWidget() { + super("debt_overview", "Technical Debt Overview", "/org/sonar/plugins/core/widgets/debt_overview.erb"); + } +} diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/debt_overview.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/debt_overview.erb new file mode 100644 index 00000000000..77db77beb22 --- /dev/null +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/debt_overview.erb @@ -0,0 +1,64 @@ +<% + sqale_rating = @snapshot.measure('sqale_rating') + sqale_debt_ratio = @snapshot.measure('sqale_debt_ratio') + if sqale_rating && sqale_rating.text_value && sqale_debt_ratio +%> + + <% if sqale_rating && sqale_rating.text_value %> +
+
+
+
+ <%= message('metric.sqale_rating.name') -%> + + + <%= sqale_rating.text_value -%> + + <% unless dashboard_configuration.selected_period? %> + <%= trend_icon(sqale_rating) -%> + <% end %> + +
+
+
+ <% end %> + <% if sqale_debt_ratio %> +
+
+
+ <%= message('metric.sqale_debt_ratio.name') -%> + + <%= format_measure(sqale_debt_ratio, :url => url_for_drilldown(sqale_debt_ratio)) %> + <%= dashboard_configuration.selected_period? ? format_variation(sqale_debt_ratio) : trend_icon(sqale_debt_ratio) -%> + +
+
+
+
+ <% end %> +<% end %> -- cgit v1.2.3