001 /*
002 * Sonar, open source software quality management tool.
003 * Copyright (C) 2008-2012 SonarSource
004 * mailto:contact AT sonarsource DOT com
005 *
006 * Sonar is free software; you can redistribute it and/or
007 * modify it under the terms of the GNU Lesser General Public
008 * License as published by the Free Software Foundation; either
009 * version 3 of the License, or (at your option) any later version.
010 *
011 * Sonar is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014 * Lesser General Public License for more details.
015 *
016 * You should have received a copy of the GNU Lesser General Public
017 * License along with Sonar; if not, write to the Free Software
018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
019 */
020 package org.sonar.plugins.core.dashboards;
021
022 import org.sonar.api.web.Dashboard;
023 import org.sonar.api.web.DashboardLayout;
024 import org.sonar.api.web.DashboardTemplate;
025
026 /**
027 * Hotspot dashboard for Sonar
028 *
029 * @since 2.13
030 */
031 public final class HotspotsDashboard extends DashboardTemplate {
032
033 private static final String HOTSPOT_METRIC = "hotspot_metric";
034 private static final String TITLE_PROPERTY = "title";
035 private static final String METRIC_PROPERTY = "metric";
036
037 @Override
038 public String getName() {
039 return "Hotspots";
040 }
041
042 @Override
043 public Dashboard createDashboard() {
044 Dashboard dashboard = Dashboard.create();
045 dashboard.setLayout(DashboardLayout.TWO_COLUMNS);
046
047 addFirstColumn(dashboard);
048 addSecondColumn(dashboard);
049
050 return dashboard;
051 }
052
053 private void addFirstColumn(Dashboard dashboard) {
054 dashboard.addWidget("hotspot_most_violated_rules", 1);
055
056 Dashboard.Widget widget = dashboard.addWidget(HOTSPOT_METRIC, 1);
057 widget.setProperty(METRIC_PROPERTY, "test_execution_time");
058 widget.setProperty(TITLE_PROPERTY, "Longest unit tests");
059
060 widget = dashboard.addWidget(HOTSPOT_METRIC, 1);
061 widget.setProperty(METRIC_PROPERTY, "complexity");
062 widget.setProperty(TITLE_PROPERTY, "Highest complexity");
063
064 widget = dashboard.addWidget(HOTSPOT_METRIC, 1);
065 widget.setProperty(METRIC_PROPERTY, "duplicated_lines");
066 widget.setProperty(TITLE_PROPERTY, "Highest duplications");
067 }
068
069 private void addSecondColumn(Dashboard dashboard) {
070 dashboard.addWidget("hotspot_most_violated_resources", 2);
071
072 Dashboard.Widget widget = dashboard.addWidget(HOTSPOT_METRIC, 2);
073 widget.setProperty(METRIC_PROPERTY, "uncovered_lines");
074 widget.setProperty(TITLE_PROPERTY, "Highest untested lines");
075
076 widget = dashboard.addWidget(HOTSPOT_METRIC, 2);
077 widget.setProperty(METRIC_PROPERTY, "function_complexity");
078 widget.setProperty(TITLE_PROPERTY, "Highest average method complexity");
079
080 widget = dashboard.addWidget(HOTSPOT_METRIC, 2);
081 widget.setProperty(METRIC_PROPERTY, "public_undocumented_api");
082 widget.setProperty(TITLE_PROPERTY, "Most undocumented APIs");
083 }
084
085 }