]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4347 Move Duplications widget from Widget Lab plugin to Sonar Core
authorJulien HENRY <julien.henry@sonarsource.com>
Tue, 9 Jul 2013 12:25:21 +0000 (14:25 +0200)
committerJulien HENRY <julien.henry@sonarsource.com>
Tue, 9 Jul 2013 12:44:43 +0000 (14:44 +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/widgets/DuplicationsWidget.java [new file with mode: 0644]
plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/duplications_widget.html.erb [new file with mode: 0644]

index ce3a0fb254fa93c0ecbbc7aa6ebea8ff5ff1b9ee..542c63ed8fce14ef4a3888cd5406bb83532c166f 100644 (file)
@@ -370,6 +370,7 @@ public final class CorePlugin extends SonarPlugin {
       MeasureFilterTreemapWidget.class,
       WelcomeWidget.class,
       DocumentationCommentsWidget.class,
+      DuplicationsWidget.class,
 
       // dashboards
       ProjectDefaultDashboard.class,
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/DuplicationsWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/DuplicationsWidget.java
new file mode 100644 (file)
index 0000000..8fd939e
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * 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;
+
+/**
+ * @author Patroklos PAPAPETROU
+ */
+
+public class DuplicationsWidget extends CoreWidget {
+
+  public DuplicationsWidget() {
+    super("duplications", "Duplications", "/org/sonar/plugins/core/widgets/duplications_widget.html.erb");
+  }
+
+}
index 3c94a4082fa1a18289004c43c10eae3db1932940..96b87825a1360e1d4754789d9ea36c3b91974b62 100644 (file)
@@ -910,6 +910,14 @@ widget.documentation_comments.docu_api.suffix=\ docu. API
 widget.documentation_comments.undocu_api.suffix=\ undocu. API
 widget.documentation_comments.public_api.suffix=\ Public API
 
+widget.duplications.name=Duplications
+widget.duplications.description= Reports on copy/paste and code duplications
+widget.duplications.duplications=Duplications
+widget.duplications.useless-duplications-title=Duplicated lines that can be reduced
+widget.duplications.lines.suffix=\ lines
+widget.duplications.blocks.suffix=\ blocks
+widget.duplications.files.suffix=\ files
+
 widget.complexity.name=Complexity
 widget.complexity.description=Reports on complexity, average complexity and complexity distribution.
 widget.complexity.per_method.suffix=\ /method
diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/duplications_widget.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/duplications_widget.html.erb
new file mode 100644 (file)
index 0000000..df4065d
--- /dev/null
@@ -0,0 +1,55 @@
+<%
+  duplications=measure('duplicated_lines_density')
+  if duplications
+%>
+<table width="100%">
+  <tbody>
+    <tr>
+      <td valign="top" width="50%">
+        <div class="dashbox">
+          <p class="title"><%= message('widget.duplications.duplications') -%></p>
+          <p>
+            <span class="big">
+              <%= format_measure('duplicated_lines_density',:url => url_for_drilldown('duplicated_lines_density'))%></span>
+              <%= dashboard_configuration.selected_period? ? format_variation('duplicated_lines_density') : trend_icon('duplicated_lines_density') -%>
+            </span>
+          </p>
+          <p>
+            <%= format_measure(measure('duplicated_lines'),:url => url_for_drilldown('duplicated_lines'), :suffix =>  ' ' + message('widget.duplications.lines.suffix'))%>
+              <%= dashboard_configuration.selected_period? ? format_variation('duplicated_lines') : trend_icon('duplicated_lines') -%>
+          </p>
+          <p>
+            <%= format_measure(measure('duplicated_blocks'),:url => url_for_drilldown('duplicated_blocks'), :suffix =>  ' ' + message('widget.duplications.blocks.suffix'))%>
+              <%= dashboard_configuration.selected_period? ? format_variation('duplicated_blocks') : trend_icon('duplicated_blocks') -%>
+          </p>
+          <p>
+            <%= format_measure(measure('duplicated_files'),:url => url_for_drilldown('duplicated_files'), :suffix =>  ' ' + message('widget.duplications.files.suffix'))%>
+              <%= dashboard_configuration.selected_period? ? format_variation('duplicated_files') : trend_icon('duplicated_files') -%>
+          </p>
+       </div>
+      </td>
+<%
+  useless_code=measure('total-useless-lines')
+  if useless_code
+%>
+
+      <td valign="top" width="50%">
+        <div class="dashbox">
+          <p class="title"><%= message('widget.duplications.useless-duplications-title') -%></p>
+          <p>
+            <span class="big">
+              <%= format_measure(measure('useless-duplicated-lines'),:url => url_for_drilldown('useless-duplicated-lines'), :suffix =>  ' ' + message('widget.duplications.lines.suffix'))%>
+            </span>
+            <%= dashboard_configuration.selected_period? ? format_variation('useless-duplicated-lines') : trend_icon('useless-duplicated-lines') -%>
+          </p>
+        </div>
+      </td>
+<%
+  end
+%>
+    </tr>
+  </tbody>
+</table>
+<%
+  end
+%>