From: Fabrice Bellingard Date: Fri, 21 Sep 2012 09:58:00 +0000 (+0200) Subject: SONAR-3591 Split the CKJM widget into two distinct widgets X-Git-Tag: 3.3~259 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=66e7e4ef879dcc7c5f606ac0d600b409c451410b;p=sonarqube.git SONAR-3591 Split the CKJM widget into two distinct widgets --- 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 a8210dbff9f..d684f7b7e59 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 @@ -718,13 +718,6 @@ widget.timeline.timeline_not_displayed=No history widget.time_machine.name=History Table widget.time_machine.description=Displays up to 10 metrics in a table, showing their value for a specified number of past snapshots. -widget.ckjm.name=Chidamber & Kemerer -widget.ckjm.description=Reports on LCOM4 and RFC average and distribution. -widget.ckjm.lcom4=LCOM4 -widget.ckjm.per_class.suffix=\ /class -widget.ckjm.files_having_lcom_greater_than_one=\ files having LCOM4>1 -widget.ckjm.rfc=Response for Class - widget.file_design.name=File design widget.file_design.description=Reports on files dependency cycles and tangle index. widget.file_design.file_tangle_index=File tangle index @@ -800,6 +793,17 @@ widget.filter.name=Filter widget.filter.description=Shows a pre-configured filter widget.filter.edit=Edit my filters +widget.lcom4.name=LCOM4 +widget.lcom4.description=Reports on LCOM4 average and distribution. +widget.lcom4.title=LCOM4 +widget.lcom4.per_class.suffix=\ /class +widget.lcom4.files_having_lcom_greater_than_one=\ files having LCOM4>1 + +widget.rfc.name=Response for class +widget.rfc.description=Reports on RFC average and distribution. +widget.rfc.title=Response for Class +widget.rfc.per_class.suffix=\ /class + widget.resource_id=project #------------------------------------------------------------------------------ diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/DesignPlugin.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/DesignPlugin.java index 50805055b42..ec4b774897c 100644 --- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/DesignPlugin.java +++ b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/DesignPlugin.java @@ -30,14 +30,16 @@ import org.sonar.plugins.design.batch.SuspectLcom4DensityDecorator; import org.sonar.plugins.design.ui.dependencies.DependenciesViewer; import org.sonar.plugins.design.ui.libraries.GwtLibrariesPage; import org.sonar.plugins.design.ui.page.GwtDesignPage; -import org.sonar.plugins.design.ui.widgets.ChidamberKemererWidget; import org.sonar.plugins.design.ui.widgets.FileDesignWidget; +import org.sonar.plugins.design.ui.widgets.LCOM4Widget; import org.sonar.plugins.design.ui.widgets.PackageDesignWidget; +import org.sonar.plugins.design.ui.widgets.ResponseForClassWidget; import java.util.List; public class DesignPlugin extends SonarPlugin { + @SuppressWarnings("unchecked") public List> getExtensions() { return ImmutableList.of( // Batch @@ -53,6 +55,7 @@ public class DesignPlugin extends SonarPlugin { DependenciesViewer.class, FileDesignWidget.class, PackageDesignWidget.class, - ChidamberKemererWidget.class); + LCOM4Widget.class, + ResponseForClassWidget.class); } } diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/widgets/ChidamberKemererWidget.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/widgets/ChidamberKemererWidget.java deleted file mode 100644 index 88db19e61d8..00000000000 --- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/widgets/ChidamberKemererWidget.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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.design.ui.widgets; - -import org.sonar.api.web.AbstractRubyTemplate; -import org.sonar.api.web.RubyRailsWidget; -import org.sonar.api.web.UserRole; -import org.sonar.api.web.WidgetCategory; - -@UserRole(UserRole.USER) -@WidgetCategory({ "Design" }) -public final class ChidamberKemererWidget extends AbstractRubyTemplate implements RubyRailsWidget { - - public String getId() { - return "ckjm"; - } - - public String getTitle() { - return "Chidamber & Kemerer"; - } - - @Override - protected String getTemplatePath() { - return "/org/sonar/plugins/design/ui/widgets/chidamber_kemerer.html.erb"; - } -} \ No newline at end of file diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/widgets/LCOM4Widget.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/widgets/LCOM4Widget.java new file mode 100644 index 00000000000..4345edf37d4 --- /dev/null +++ b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/widgets/LCOM4Widget.java @@ -0,0 +1,43 @@ +/* + * 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.design.ui.widgets; + +import org.sonar.api.web.AbstractRubyTemplate; +import org.sonar.api.web.RubyRailsWidget; +import org.sonar.api.web.UserRole; +import org.sonar.api.web.WidgetCategory; + +@UserRole(UserRole.USER) +@WidgetCategory({"Design"}) +public final class LCOM4Widget extends AbstractRubyTemplate implements RubyRailsWidget { + + public String getId() { + return "lcom4"; + } + + public String getTitle() { + return "LCOM4"; + } + + @Override + protected String getTemplatePath() { + return "/org/sonar/plugins/design/ui/widgets/lcom4.html.erb"; + } +} diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/widgets/ResponseForClassWidget.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/widgets/ResponseForClassWidget.java new file mode 100644 index 00000000000..fe2b8d7ea4e --- /dev/null +++ b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/widgets/ResponseForClassWidget.java @@ -0,0 +1,43 @@ +/* + * 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.design.ui.widgets; + +import org.sonar.api.web.AbstractRubyTemplate; +import org.sonar.api.web.RubyRailsWidget; +import org.sonar.api.web.UserRole; +import org.sonar.api.web.WidgetCategory; + +@UserRole(UserRole.USER) +@WidgetCategory({"Design"}) +public final class ResponseForClassWidget extends AbstractRubyTemplate implements RubyRailsWidget { + + public String getId() { + return "rfc"; + } + + public String getTitle() { + return "Response for class"; + } + + @Override + protected String getTemplatePath() { + return "/org/sonar/plugins/design/ui/widgets/response_for_class.html.erb"; + } +} diff --git a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/chidamber_kemerer.html.erb b/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/chidamber_kemerer.html.erb deleted file mode 100644 index 7757aa18075..00000000000 --- a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/chidamber_kemerer.html.erb +++ /dev/null @@ -1,56 +0,0 @@ -<% -lcom=measure('lcom4') -rfc=measure('rfc') -if lcom || rfc - lcom_distribution=measure('lcom4_distribution') - rfc_distribution=measure('rfc_distribution') - suspect_lcom4_density=measure('suspect_lcom4_density') - %> - - - - <% if lcom %> - - <% end %> - <% if rfc %> - - <% end %> - - - - - - -
-
-

<%= message('widget.ckjm.lcom4') -%>

-

- <%= format_measure(lcom, :suffix => '', :default => '-', :url => url_for_drilldown('lcom4')) -%><%= message('widget.ckjm.per_class.suffix') -%> <%= dashboard_configuration.selected_period? ? format_variation(lcom) : trend_icon(lcom, :big => true) -%> -

-

- <%= format_measure(suspect_lcom4_density, :suffix => message('widget.ckjm.files_having_lcom_greater_than_one'), :url => url_for_drilldown('lcom4')) %> <%= dashboard_configuration.selected_period? ? format_variation(suspect_lcom4_density) : trend_icon(suspect_lcom4_density) -%> -

-
-
-
-

<%= message('widget.ckjm.rfc') -%>

-

- <%= format_measure(rfc, :suffix => '', :default => '-', :url => url_for_drilldown('rfc')) -%><%= message('widget.ckjm.per_class.suffix') -%> <%= dashboard_configuration.selected_period? ? format_variation(rfc) : trend_icon(rfc, :big => true) -%> -

-
-
- <% - if suspect_lcom4_density && suspect_lcom4_density.value>1.0 && lcom_distribution && !lcom_distribution.data.blank? - query="ck=distbar&c=777777&w=180&h=100&fs=8&bgc=ffffff&v=" + u(lcom_distribution.data) - %> - <%= chart(query, :id => 'lcom4_distribution', :alt => '') -%> - <% end %> - - <% - if rfc_distribution && !rfc_distribution.data.blank? - query="ck=distbar&c=777777&w=180&h=100&fs=8&bgc=ffffff&v=" + u(rfc_distribution.data) - %> - <%= chart(query, :id => 'rfc_distribution', :alt => '') -%> - <% end %> -
-<% end %> diff --git a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/lcom4.html.erb b/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/lcom4.html.erb new file mode 100644 index 00000000000..171d3e6175b --- /dev/null +++ b/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/lcom4.html.erb @@ -0,0 +1,34 @@ +<% + lcom=measure('lcom4') + if lcom + lcom_distribution=measure('lcom4_distribution') + suspect_lcom4_density=measure('suspect_lcom4_density') +%> + + + + + + <% + if suspect_lcom4_density && suspect_lcom4_density.value>1.0 && lcom_distribution && !lcom_distribution.data.blank? + query="ck=distbar&c=777777&w=180&h=100&fs=8&bgc=ffffff&v=" + u(lcom_distribution.data) + %> + + <% end %> + + + +
+
+

<%= message('widget.lcom4.title') -%>

+

+ <%= format_measure(lcom, :suffix => '', :default => '-', :url => url_for_drilldown('lcom4')) -%><%= message('widget.lcom4.per_class.suffix') -%> <%= dashboard_configuration.selected_period? ? format_variation(lcom) : trend_icon(lcom, :big => true) -%> +

+

+ <%= format_measure(suspect_lcom4_density, :suffix => message('widget.lcom4.files_having_lcom_greater_than_one'), :url => url_for_drilldown('lcom4')) %> <%= dashboard_configuration.selected_period? ? format_variation(suspect_lcom4_density) : trend_icon(suspect_lcom4_density) -%> +

+
+
+ <%= chart(query, :id => 'lcom4_distribution', :alt => '') -%> +
+<% end %> diff --git a/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/response_for_class.html.erb b/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/response_for_class.html.erb new file mode 100644 index 00000000000..63a6fa6f55a --- /dev/null +++ b/plugins/sonar-design-plugin/src/main/resources/org/sonar/plugins/design/ui/widgets/response_for_class.html.erb @@ -0,0 +1,30 @@ +<% + rfc=measure('rfc') + if rfc + rfc_distribution=measure('rfc_distribution') +%> + + + + + + <% + if rfc_distribution && !rfc_distribution.data.blank? + query="ck=distbar&c=777777&w=180&h=100&fs=8&bgc=ffffff&v=" + u(rfc_distribution.data) + %> + + <% end %> + + + +
+
+

<%= message('widget.rfc.title') -%>

+

+ <%= format_measure(rfc, :suffix => '', :default => '-', :url => url_for_drilldown('rfc')) -%><%= message('widget.rfc.per_class.suffix') -%> <%= dashboard_configuration.selected_period? ? format_variation(rfc) : trend_icon(rfc, :big => true) -%> +

+
+
+ <%= chart(query, :id => 'rfc_distribution', :alt => '') -%> +
+<% end %>