]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5450 Add a Technical debt synopsis widget
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Fri, 11 Jul 2014 08:47:29 +0000 (10:47 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Fri, 11 Jul 2014 08:47:41 +0000 (10:47 +0200)
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/ProjectDefaultDashboard.java
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/DebtOverviewWidget.java [new file with mode: 0644]
plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/debt_overview.erb [new file with mode: 0644]
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index 484ff746d683be9cd7b14483147760af1aa7ce53..1c9bdcf30459c46788c6bafb0f091cfaf76bd05f 100644 (file)
@@ -226,6 +226,7 @@ public final class CorePlugin extends SonarPlugin {
       MeasureFilterAsHistogramWidget.class,
       MeasureFilterAsBubbleChartWidget.class,
       ProjectFileCloudWidget.class,
+      DebtOverviewWidget.class,
 
       // dashboards
       ProjectDefaultDashboard.class,
index 7412127acf8c8fa8175cc915119a1f61415ab3cf..96799dfec2cdd83e8547b4fa4f341256b0774015 100644 (file)
@@ -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 (file)
index 0000000..9af75bb
--- /dev/null
@@ -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 (file)
index 0000000..77db77b
--- /dev/null
@@ -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
+%>
+  <style>
+    .debt_overview .rating {
+      padding: 2px 5px;
+      color: #fff;
+    }
+
+    .debt_overview .A {
+      background-color: #00AA00;
+    }
+
+    .debt_overview .B {
+      background-color: #80CC00;
+    }
+
+    .debt_overview .C {
+      background-color: #FFEE00;
+    }
+
+    .debt_overview .D {
+      background-color: #F77700;
+    }
+
+    .debt_overview .E {
+      background-color: #EE0000;
+    }
+  </style>
+  <% if sqale_rating && sqale_rating.text_value %>
+    <div class="widget-row">
+      <div class="widget-span widget-span-6">
+        <div class="widget-measure-container">
+          <div class="widget-measure widget-measure-main">
+            <span class="widget-label"><%= message('metric.sqale_rating.name') -%></span>
+            <span class="nowrap">
+              <a href="<%= url_for_drilldown('sqale_rating') -%>" class="widget-link">
+                <span class="rating <%= sqale_rating.text_value -%>"><%= sqale_rating.text_value -%></span>
+              </a>
+              <% unless dashboard_configuration.selected_period? %>
+                <%= trend_icon(sqale_rating) -%>
+              <% end %>
+            </span>
+          </div>
+        </div>
+      </div>
+  <% end %>
+  <% if sqale_debt_ratio %>
+    <div class="widget-span widget-span-6">
+      <div class="widget-measure-container">
+        <div class="widget-measure widget-measure-main">
+          <span class="widget-label"><%= message('metric.sqale_debt_ratio.name') -%></span>
+          <span class="nowrap">
+            <%= 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) -%>
+          </span>
+        </div>
+      </div>
+    </div>
+    </div>
+  <% end %>
+<% end %>
index c4d35c11947bc23ae9e6b9a7148c302283212628..3a43b6dc3937554b07e55376d58d743dc7d24110 100644 (file)
@@ -1284,6 +1284,9 @@ widget.technical_debt_pyramid.technical_debt=Technical Debt
 widget.technical_debt_pyramid.total=Total
 widget.technical_debt_pyramid.no_info_available=No information available.
 
+widget.debt_overview.name=Technical Debt Synopsis
+widget.debt_overview.description=Display the SQALE rating and the technical debt ratio.
+
 # Below are labels used in widget edition pages
 widget.image.name=Image
 widget.image.description=Shows an image with a link
@@ -2516,7 +2519,7 @@ metric.new_technical_debt.description=Technical Debt on new code
 metric.sqale_rating.name=SQALE Rating
 metric.sqale_rating.description=Density of technical debt computed by dividing the technical debt by the estimated effort to develop from scratch an application.
 
-metric.sqale_debt_ratio.name=SQALE Technical Debt Ratio
+metric.sqale_debt_ratio.name=Technical Debt Ratio
 metric.sqale_debt_ratio.description=Ratio of the technical debt compared to what it would cost to develop the whole source code from scratch.