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 */
020package org.sonar.plugins.core.dashboards;
021
022import org.sonar.api.web.Dashboard;
023import org.sonar.api.web.DashboardLayout;
024import org.sonar.api.web.DashboardTemplate;
025
026/**
027 * Default "Hotspots" dashboard
028 *
029 * @since 2.13
030 */
031public final class HotspotsDashboard extends DashboardTemplate {
032
033  private static final String HOTSPOT_METRIC = "hotspot_metric";
034  private static final String METRIC_PROPERTY = "metric";
035
036  @Override
037  public String getName() {
038    return "Hotspots";
039  }
040
041  @Override
042  public Dashboard createDashboard() {
043    Dashboard dashboard = Dashboard.create();
044    dashboard.setLayout(DashboardLayout.TWO_COLUMNS);
045
046    addFirstColumn(dashboard);
047    addSecondColumn(dashboard);
048
049    return dashboard;
050  }
051
052  private void addFirstColumn(Dashboard dashboard) {
053    dashboard.addWidget("hotspot_most_violated_rules", 1);
054
055    Dashboard.Widget widget = dashboard.addWidget(HOTSPOT_METRIC, 1);
056    widget.setProperty(METRIC_PROPERTY, "test_execution_time");
057
058    widget = dashboard.addWidget(HOTSPOT_METRIC, 1);
059    widget.setProperty(METRIC_PROPERTY, "complexity");
060
061    widget = dashboard.addWidget(HOTSPOT_METRIC, 1);
062    widget.setProperty(METRIC_PROPERTY, "duplicated_lines");
063  }
064
065  private void addSecondColumn(Dashboard dashboard) {
066    dashboard.addWidget("hotspot_most_violated_resources", 2);
067
068    Dashboard.Widget widget = dashboard.addWidget(HOTSPOT_METRIC, 2);
069    widget.setProperty(METRIC_PROPERTY, "uncovered_lines");
070
071    widget = dashboard.addWidget(HOTSPOT_METRIC, 2);
072    widget.setProperty(METRIC_PROPERTY, "function_complexity");
073
074    widget = dashboard.addWidget(HOTSPOT_METRIC, 2);
075    widget.setProperty(METRIC_PROPERTY, "public_undocumented_api");
076  }
077
078}