From: Julien Lancelot Date: Thu, 23 May 2013 15:25:56 +0000 (+0200) Subject: SONAR-4341 Provide an "Issues by Severity" widget which will replace the "Rules Compl... X-Git-Tag: 3.6~290 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a2a272bb4535dc36ee353c05452cc64249ca91f9;p=sonarqube.git SONAR-4341 Provide an "Issues by Severity" widget which will replace the "Rules Compliance" 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 826b3478689..5849d7c5f06 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 @@ -365,7 +365,7 @@ public final class CorePlugin extends SonarPlugin { DescriptionWidget.class, ComplexityWidget.class, RulesWidget.class, - RulesWidget2.class, + IssuesBySeverity.class, SizeWidget.class, EventsWidget.class, CustomMeasuresWidget.class, diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/RulesWidget2.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/RulesWidget2.java deleted file mode 100644 index 559204c1efe..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/RulesWidget2.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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; - -import org.sonar.api.web.WidgetCategory; - -@WidgetCategory({"Rules"}) -public class RulesWidget2 extends CoreWidget { - - public RulesWidget2() { - super("rules2", "Rules Compliance 2", "/org/sonar/plugins/core/widgets/rules2.html.erb"); - } -} \ No newline at end of file diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/issues/IssuesBySeverity.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/issues/IssuesBySeverity.java new file mode 100644 index 00000000000..9c532d175f0 --- /dev/null +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/issues/IssuesBySeverity.java @@ -0,0 +1,33 @@ +/* + * 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 IssuesBySeverity extends CoreWidget { + + public IssuesBySeverity() { +// super("issues_by_severity", "Issues by Severity", "/org/sonar/plugins/core/widgets/issues/issues_by_severity.html.erb"); + super("issues_by_severity", "Issues by Severity", + "/Users/julienlancelot/Dev/Sources/sonar/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/issues_by_severity.html.erb"); + } +} \ No newline at end of file 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 24bf89edfc5..70b66438fea 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 @@ -1078,8 +1078,13 @@ 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.issues_by_severity.name=Issues by Severity +widget.issues_by_severity.description=Reports issues by severity. +widget.issues_by_severity.issues=Issues +widget.issues_by_severity.false_positives=False positives +widget.issues_by_severity.added=Added: +widget.issues_by_severity.removed=Removed: widget.action_plans.name=Action plans widget.action_plans.description=Shows all the open action plans of the project diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/issues_by_severity.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/issues_by_severity.html.erb new file mode 100644 index 00000000000..9f70cd09f12 --- /dev/null +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/issues_by_severity.html.erb @@ -0,0 +1,168 @@ +<% + issues = @snapshot.measure('issues') # TODO replace by violations + false_positive_issues = @snapshot.measure('false_positive_issues') # TODO replace by false_positive_reviews + blocker_issues = @snapshot.measure('blocker_issues') # TODO replace by violations... + critical_issues = @snapshot.measure('critical_issues') + major_issues = @snapshot.measure('major_issues') + minor_issues = @snapshot.measure('minor_issues') + info_issues = @snapshot.measure('info_issues') + new_issues = @snapshot.measure('new_issues') +%> + + + + + + +
+
+

<%= message('widget.issues_by_severity.issues') -%>

+
+ + <%= format_measure(issues, :url => url_for(:controller => 'drilldown', :action => 'issues', :id => @project.key)) -%> + + <%= dashboard_configuration.selected_period? ? format_variation(issues) : trend_icon(issues) -%> + <% + if @dashboard_configuration.selected_period? + issues_variation = variation_value(issues) + new_issues_variation = variation_value(new_issues) + estimated_cleared_issues = (new_issues_variation - issues_variation).to_i if issues_variation && new_issues_variation + %> + <% if new_issues_variation && new_issues_variation > 0 %> +
+ + <%= message('widget.issues_by_severity.added') -%>  + + <%= format_variation(new_issues, :style => 'none', :default => '-') -%> + + <% end %> + <% if estimated_cleared_issues && estimated_cleared_issues > 0 %> +
+ + <%= message('widget.issues_by_severity.removed') -%>  + <%= estimated_cleared_issues -%> + + <% end %> + <% end %> +
+

<%= message('widget.issues_by_severity.false_positives') -%>

+
+ + <%= format_measure(false_positive_issues, :url => url_for(:controller => 'drilldown', :action => 'issues', :id => @project.key)) -%> + + <%= dashboard_configuration.selected_period? ? format_variation(false_positive_issues) : trend_icon(false_positive_issues) -%> +
+
+
+ <% + values = [blocker_issues, critical_issues, major_issues, minor_issues, info_issues] + if dashboard_configuration.selected_period? + values = values.map{|m| m ? (m.variation(dashboard_configuration.period_index)||0) : 0} + else + values = values.map{|m| m ? (m.value||0) : 0} + end + max = values.map{|val| val.abs}.max + %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
<%= image_tag 'priority/BLOCKER.png'%>  <%= link_to message('blocker'), {:controller => 'drilldown', :action => 'issues', :id => @project.key, :severity => 'BLOCKER'} %> + <%= format_measure(blocker_issues) -%> + + <%= dashboard_configuration.selected_period? ? format_variation(blocker_issues) : trend_icon(blocker_issues, :empty => true) -%> + + <% if max > 0 %> + <% if dashboard_configuration.selected_period? %> + <%= barchart(:width => 35, :percent => (values[0]<0 ? (100 * values[0] / max).to_i : 0), :color => '#078C00') %> + <%= barchart(:width => 35, :percent => (values[0]>0 ? (100 * values[0] / max).to_i : 0), :color => '#cc0000') %> + <% else %> + <%= barchart(:width => 70, :percent => (100 * values[0] / max).to_i) %> + <% end %> + <% end %> +
<%= image_tag 'priority/CRITICAL.png' %>  <%= link_to message('critical'), {:controller => 'drilldown', :action => 'issues', :id => @project.key, :severity => 'CRITICAL'} %> + <%= format_measure(critical_issues) -%> + + <%= dashboard_configuration.selected_period? ? format_variation(critical_issues) : trend_icon(critical_issues, :empty => true) -%> + + <% if max > 0 %> + <% if dashboard_configuration.selected_period? %> + <%= barchart(:width => 35, :percent => (values[1]<0 ? (100 * values[1] / max).to_i : 0), :color => '#078C00') %> + <%= barchart(:width => 35, :percent => (values[1]>0 ? (100 * values[1] / max).to_i : 0), :color => '#cc0000') %> + <% else %> + <%= barchart(:width => 70, :percent => (100 * values[1] / max).to_i) %> + <% end %> + <% end %> +
<%= image_tag 'priority/MAJOR.png' %>  <%= link_to message('major'), {:controller => 'drilldown', :action => 'issues', :id => @project.key, :severity => 'MAJOR'} %> + <%= format_measure(major_issues) -%> + + <%= dashboard_configuration.selected_period? ? format_variation(major_issues) : trend_icon(major_issues, :empty => true) -%> + + <% if max > 0 %> + <% if dashboard_configuration.selected_period? %> + <%= barchart(:width => 35, :percent => (values[2]<0 ? (100 * values[2] / max).to_i : 0), :color => '#078C00') %> + <%= barchart(:width => 35, :percent => (values[2]>0 ? (100 * values[2] / max).to_i : 0), :color => '#cc0000') %> + <% else %> + <%= barchart(:width => 70, :percent => (100 * values[2] / max).to_i) %> + <% end %> + <% end %> +
<%= image_tag 'priority/MINOR.png' %>  <%= link_to message('minor'), {:controller => 'drilldown', :action => 'issues', :id => @project.key, :severity => 'MINOR'} %> + <%= format_measure(minor_issues) -%> + + <%= dashboard_configuration.selected_period? ? format_variation(minor_issues) : trend_icon(minor_issues, :empty => true) -%> + + <% if max > 0 %> + <% if dashboard_configuration.selected_period? %> + <%= barchart(:width => 35, :percent => (values[3]<0 ? (100 * values[3] / max).to_i : 0), :color => '#078C00') %> + <%= barchart(:width => 35, :percent => (values[3]>0 ? (100 * values[3] / max).to_i : 0), :color => '#cc0000') %> + <% else %> + <%= barchart(:width => 70, :percent => (100 * values[3] / max).to_i) %> + <% end %> + <% end %> +
<%= image_tag 'priority/INFO.png' %>  <%= link_to message('info'), {:controller => 'drilldown', :action => 'issues', :id => @project.key, :severity => 'INFO'} %> + <%= format_measure(info_issues) -%> + + <%= dashboard_configuration.selected_period? ? format_variation(info_issues) : trend_icon(info_issues, :empty => true) -%> + + <% if max > 0 %> + <% if dashboard_configuration.selected_period? %> + <%= barchart(:width => 35, :percent => (values[4]<0 ? (100 * values[4] / max).to_i : 0), :color => '#078C00') %> + <%= barchart(:width => 35, :percent => (values[4]>0 ? (100 * values[4] / max).to_i : 0), :color => '#cc0000') %> + <% else %> + <%= barchart(:width => 70, :percent => (100 * values[4] / max).to_i) %> + <% end %> + <% end %> +
+
diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/rules2.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/rules2.html.erb deleted file mode 100644 index c0e24340584..00000000000 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/rules2.html.erb +++ /dev/null @@ -1,169 +0,0 @@ -<% - issues = @snapshot.measure('issues') - density = @snapshot.measure('issues_density') - blocker_issues = @snapshot.measure('blocker_issues') - critical_issues = @snapshot.measure('critical_issues') - major_issues = @snapshot.measure('major_issues') - minor_issues = @snapshot.measure('minor_issues') - info_issues = @snapshot.measure('info_issues') - new_issues = @snapshot.measure('new_issues') -%> - - - - - - -
-
-

<%= message('widget.rules.issues') -%>

-
- - <%= format_measure(issues, :url => url_for(:controller => 'drilldown', :action => 'issues', :id => @project.key)) -%> - - <%= dashboard_configuration.selected_period? ? format_variation(issues) : trend_icon(issues) -%> - <% - if @dashboard_configuration.selected_period? - issues_variation = variation_value(issues) - new_issues_variation = variation_value(new_issues) - estimated_cleared_issues = (new_issues_variation - issues_variation).to_i if issues_variation && new_issues_variation - %> - <% if new_issues_variation && new_issues_variation > 0 %> -
- - <%= message('widget.rules.added') -%>  - <%= format_variation(new_issues, :style => 'none', :default => '-') -%> - - <% end %> - <% if estimated_cleared_issues && estimated_cleared_issues > 0 %> -
- - <%= message('widget.rules.removed') -%>  - <%= estimated_cleared_issues -%> - - <% end %> - <% end %> -
- <% if density %> -

<%= message('widget.rules.rules_compliance') -%>

-
- - <%= format_measure(density, :url => url_for_drilldown('weighted_issues', {:highlight => 'weighted_issues'})) -%> - - <%= dashboard_configuration.selected_period? ? format_variation(density) : trend_icon(density) -%> -
- <% end %> -
-
- <% - values = [blocker_issues, critical_issues, major_issues, minor_issues, info_issues] - if dashboard_configuration.selected_period? - values = values.map{|m| m ? (m.variation(dashboard_configuration.period_index)||0) : 0} - else - values = values.map{|m| m ? (m.value||0) : 0} - end - max = values.map{|val| val.abs}.max - %> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<%= image_tag 'priority/BLOCKER.png'%>  <%= link_to message('blocker'), {:controller => 'drilldown', :action => 'issues', :id => @project.key, :severity => 'BLOCKER'} %> - <%= format_measure(blocker_issues) -%> - - <%= dashboard_configuration.selected_period? ? format_variation(blocker_issues) : trend_icon(blocker_issues, :empty => true) -%> - - <% if max > 0 %> - <% if dashboard_configuration.selected_period? %> - <%= barchart(:width => 35, :percent => (values[0]<0 ? (100 * values[0] / max).to_i : 0), :color => '#078C00') %> - <%= barchart(:width => 35, :percent => (values[0]>0 ? (100 * values[0] / max).to_i : 0), :color => '#cc0000') %> - <% else %> - <%= barchart(:width => 70, :percent => (100 * values[0] / max).to_i) %> - <% end %> - <% end %> -
<%= image_tag 'priority/CRITICAL.png' %>  <%= link_to message('critical'), {:controller => 'drilldown', :action => 'issues', :id => @project.key, :severity => 'CRITICAL'} %> - <%= format_measure(critical_issues) -%> - - <%= dashboard_configuration.selected_period? ? format_variation(critical_issues) : trend_icon(critical_issues, :empty => true) -%> - - <% if max > 0 %> - <% if dashboard_configuration.selected_period? %> - <%= barchart(:width => 35, :percent => (values[1]<0 ? (100 * values[1] / max).to_i : 0), :color => '#078C00') %> - <%= barchart(:width => 35, :percent => (values[1]>0 ? (100 * values[1] / max).to_i : 0), :color => '#cc0000') %> - <% else %> - <%= barchart(:width => 70, :percent => (100 * values[1] / max).to_i) %> - <% end %> - <% end %> -
<%= image_tag 'priority/MAJOR.png' %>  <%= link_to message('major'), {:controller => 'drilldown', :action => 'issues', :id => @project.key, :severity => 'MAJOR'} %> - <%= format_measure(major_issues) -%> - - <%= dashboard_configuration.selected_period? ? format_variation(major_issues) : trend_icon(major_issues, :empty => true) -%> - - <% if max > 0 %> - <% if dashboard_configuration.selected_period? %> - <%= barchart(:width => 35, :percent => (values[2]<0 ? (100 * values[2] / max).to_i : 0), :color => '#078C00') %> - <%= barchart(:width => 35, :percent => (values[2]>0 ? (100 * values[2] / max).to_i : 0), :color => '#cc0000') %> - <% else %> - <%= barchart(:width => 70, :percent => (100 * values[2] / max).to_i) %> - <% end %> - <% end %> -
<%= image_tag 'priority/MINOR.png' %>  <%= link_to message('minor'), {:controller => 'drilldown', :action => 'issues', :id => @project.key, :severity => 'MINOR'} %> - <%= format_measure(minor_issues) -%> - - <%= dashboard_configuration.selected_period? ? format_variation(minor_issues) : trend_icon(minor_issues, :empty => true) -%> - - <% if max > 0 %> - <% if dashboard_configuration.selected_period? %> - <%= barchart(:width => 35, :percent => (values[3]<0 ? (100 * values[3] / max).to_i : 0), :color => '#078C00') %> - <%= barchart(:width => 35, :percent => (values[3]>0 ? (100 * values[3] / max).to_i : 0), :color => '#cc0000') %> - <% else %> - <%= barchart(:width => 70, :percent => (100 * values[3] / max).to_i) %> - <% end %> - <% end %> -
<%= image_tag 'priority/INFO.png' %>  <%= link_to message('info'), {:controller => 'drilldown', :action => 'issues', :id => @project.key, :severity => 'INFO'} %> - <%= format_measure(info_issues) -%> - - <%= dashboard_configuration.selected_period? ? format_variation(info_issues) : trend_icon(info_issues, :empty => true) -%> - - <% if max > 0 %> - <% if dashboard_configuration.selected_period? %> - <%= barchart(:width => 35, :percent => (values[4]<0 ? (100 * values[4] / max).to_i : 0), :color => '#078C00') %> - <%= barchart(:width => 35, :percent => (values[4]>0 ? (100 * values[4] / max).to_i : 0), :color => '#cc0000') %> - <% else %> - <%= barchart(:width => 70, :percent => (100 * values[4] / max).to_i) %> - <% end %> - <% end %> -
-