From: Julien Lancelot Date: Thu, 23 May 2013 12:43:30 +0000 (+0200) Subject: SONAR-4333 Provide a new "Unresolved issue statuses" widget X-Git-Tag: 3.6~293 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=629380e090de7a57fedde2397ce08b3a1f5b3289;p=sonarqube.git SONAR-4333 Provide a new "Unresolved issue statuses" widget --- 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 cc3b9e380d2..826b3478689 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 @@ -46,9 +46,7 @@ import org.sonar.plugins.core.web.Lcom4Viewer; import org.sonar.plugins.core.web.TestsViewer; import org.sonar.plugins.core.widgets.*; import org.sonar.plugins.core.widgets.issues.ActionPlansWidget; -import org.sonar.plugins.core.widgets.issues.FalsePositiveIssuesWidget; -import org.sonar.plugins.core.widgets.issues.MyUnresolvedIssuesWidget; -import org.sonar.plugins.core.widgets.issues.UnresolvedIssuesPerAssigneeWidget; +import org.sonar.plugins.core.widgets.issues.*; import org.sonar.plugins.core.widgets.reviews.*; import java.util.List; @@ -418,6 +416,7 @@ public final class CorePlugin extends SonarPlugin { ActionPlansWidget.class, org.sonar.plugins.core.widgets.ActionPlansWidget.class, UnresolvedIssuesPerAssigneeWidget.class, + UnresolvedIssuesStatusesWidget.class, // batch ProfileSensor.class, diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/ProjectIssuesDashboard.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/ProjectIssuesDashboard.java index 17daeadeec3..0df89cb314f 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/ProjectIssuesDashboard.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/ProjectIssuesDashboard.java @@ -45,7 +45,8 @@ public final class ProjectIssuesDashboard extends DashboardTemplate { } private void addFirstColumn(Dashboard dashboard) { - dashboard.addWidget("issues_action_plans", 1); + dashboard.addWidget("unresolved_issues_statuses", 1); + dashboard.addWidget("issues_action_plans", 2); } private void addSecondColumn(Dashboard dashboard) { diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/issues/UnresolvedIssuesStatusesWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/issues/UnresolvedIssuesStatusesWidget.java new file mode 100644 index 00000000000..566c1d2827c --- /dev/null +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/issues/UnresolvedIssuesStatusesWidget.java @@ -0,0 +1,30 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2013 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.issues; + +import org.sonar.api.web.WidgetCategory; +import org.sonar.plugins.core.widgets.CoreWidget; + +@WidgetCategory({"Issues"}) +public class UnresolvedIssuesStatusesWidget extends CoreWidget { + public UnresolvedIssuesStatusesWidget() { + super("unresolved_issues_statuses", "Unresolved issue statuses", "/org/sonar/plugins/core/widgets/issues/unresolved_issues_statuses.html.erb"); + } +} diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties index 5cf4f639a85..43e989126b6 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties @@ -1073,6 +1073,11 @@ widget.unresolved_issues_per_assignee.name=Unresolved issues per assignee widget.unresolved_issues_per_assignee.description=Shows the number of unresolved issues per assignee. widget.unresolved_issues_per_assignee.not_assigned=Not assigned +widget.unresolved_issues_statuses.name=Unresolved issue statuses +widget.unresolved_issues_statuses.description=Display the number of unresolved issues according to their status : Open, Reopen and Accepted. +widget.unresolved_issues_statuses.added=Added: +widget.unresolved_issues_statuses.removed=Removed: + widget.action_plans.name=Action plans widget.action_plans.description=Shows all the open action plans of the project widget.action_plans.property.showClosedReviews.name=Show Closed Reviews diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/unresolved_issues_statuses.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/unresolved_issues_statuses.html.erb new file mode 100644 index 00000000000..255ea178eb4 --- /dev/null +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/unresolved_issues_statuses.html.erb @@ -0,0 +1,58 @@ +<% + issues = @snapshot.measure('violations') + open_issues = @snapshot.measure('open_issues') + reopened_issues = @snapshot.measure('reopened_issues') + confirmed_issues = @snapshot.measure('confirmed_issues') + + issues_search_options = {} + issues_search_options['resolved'] = 'false' + issues_search_options['componentRoots'] = @project.key +%> + + + + + + + +
+
+

<%= message('issues') -%>

+
+ + <%= format_measure(issues, :url => url_for({:controller => 'issues', :action => 'search' }.merge(issues_search_options))) -%> + + <%= dashboard_configuration.selected_period? ? format_variation(issues) : trend_icon(issues) -%> +
+
+
+
+

<%= message('issue.status.OPEN') -%>

+
+ + <%= format_measure(open_issues, :url => url_for({:controller => 'issues', :action => 'search', :statuses => 'OPEN'}.merge(issues_search_options))) -%> + + <%= dashboard_configuration.selected_period? ? format_variation(open_issues) : trend_icon(open_issues) -%> +
+
+
+
+

<%= message('issue.status.REOPENED') -%>

+
+ + <%= format_measure(reopened_issues, :url => url_for({:controller => 'issues', :action => 'search', :statuses => 'REOPENED'}.merge(issues_search_options))) -%> + + <%= dashboard_configuration.selected_period? ? format_variation(reopened_issues) : trend_icon(reopened_issues) -%> +
+
+
+
+

<%= message('issue.status.CONFIRMED') -%>

+
+ + <%= format_measure(confirmed_issues, :url => url_for({:controller => 'issues', :action => 'search', :statuses => 'CONFIRMED'}.merge(issues_search_options))) -%> + + <%= dashboard_configuration.selected_period? ? format_variation(confirmed_issues) : trend_icon(confirmed_issues) -%> +
+
+
diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/ProjectIssuesDashboardTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/ProjectIssuesDashboardTest.java new file mode 100644 index 00000000000..65e9e31d107 --- /dev/null +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/ProjectIssuesDashboardTest.java @@ -0,0 +1,52 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2013 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.dashboards; + +import org.junit.Test; +import org.sonar.api.web.Dashboard; +import org.sonar.api.web.DashboardLayout; +import org.sonar.plugins.core.CorePlugin; + +import static org.fest.assertions.Assertions.assertThat; + +public class ProjectIssuesDashboardTest { + + ProjectIssuesDashboard template = new ProjectIssuesDashboard(); + + @Test + public void should_have_a_name() { + assertThat(template.getName()).isEqualTo("Issues"); + } + + @Test + public void should_be_registered_as_an_extension() { + assertThat(new CorePlugin().getExtensions()).contains(template.getClass()); + } + + @Test + public void should_create_dashboard() { + Dashboard dashboard = template.createDashboard(); + + assertThat(dashboard.getLayout()).isEqualTo(DashboardLayout.TWO_COLUMNS); + assertThat(dashboard.getWidgets()).hasSize(5); + } + +} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java index 17fc013a30e..f72770aa2bd 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java @@ -1848,7 +1848,6 @@ public final class CoreMetrics { .setDomain(DOMAIN_ISSUES) .setBestValue(0.0) .setOptimizedBestValue(true) - .setDeleteHistoricalData(true) .create(); /** @@ -1866,7 +1865,6 @@ public final class CoreMetrics { .setDomain(DOMAIN_ISSUES) .setBestValue(0.0) .setOptimizedBestValue(true) - .setDeleteHistoricalData(true) .create();