diff options
5 files changed, 108 insertions, 29 deletions
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 49b7f8b8ac1..03a1f3f7804 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 @@ -48,9 +48,6 @@ import org.sonar.plugins.core.filters.ProjectFilter; import org.sonar.plugins.core.filters.TreeMapFilter; import org.sonar.plugins.core.security.ApplyProjectRolesDecorator; import org.sonar.plugins.core.security.DefaultResourcePermissions; -import org.sonar.plugins.core.sensors.OverallBranchCoverageDecorator; -import org.sonar.plugins.core.sensors.OverallCoverageDecorator; -import org.sonar.plugins.core.sensors.OverallLineCoverageDecorator; import org.sonar.plugins.core.sensors.BranchCoverageDecorator; import org.sonar.plugins.core.sensors.CheckAlertThresholds; import org.sonar.plugins.core.sensors.CommentDensityDecorator; @@ -64,6 +61,9 @@ import org.sonar.plugins.core.sensors.ItLineCoverageDecorator; import org.sonar.plugins.core.sensors.LineCoverageDecorator; import org.sonar.plugins.core.sensors.ManualMeasureDecorator; import org.sonar.plugins.core.sensors.ManualViolationInjector; +import org.sonar.plugins.core.sensors.OverallBranchCoverageDecorator; +import org.sonar.plugins.core.sensors.OverallCoverageDecorator; +import org.sonar.plugins.core.sensors.OverallLineCoverageDecorator; import org.sonar.plugins.core.sensors.ProfileEventsSensor; import org.sonar.plugins.core.sensors.ProfileSensor; import org.sonar.plugins.core.sensors.ProjectLinksSensor; @@ -80,6 +80,7 @@ import org.sonar.plugins.core.testdetailsviewer.TestsViewerDefinition; import org.sonar.plugins.core.timemachine.NewCoverageAggregator; import org.sonar.plugins.core.timemachine.NewCoverageFileAnalyzer; import org.sonar.plugins.core.timemachine.NewItCoverageFileAnalyzer; +import org.sonar.plugins.core.timemachine.NewOverallCoverageFileAnalyzer; import org.sonar.plugins.core.timemachine.NewViolationsDecorator; import org.sonar.plugins.core.timemachine.ReferenceAnalysis; import org.sonar.plugins.core.timemachine.TendencyDecorator; @@ -429,6 +430,7 @@ public final class CorePlugin extends SonarPlugin { TimeMachineConfigurationPersister.class, NewCoverageFileAnalyzer.class, NewItCoverageFileAnalyzer.class, + NewOverallCoverageFileAnalyzer.class, NewCoverageAggregator.class); } } diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewCoverageAggregator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewCoverageAggregator.java index a0aec7935ad..beb4d016087 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewCoverageAggregator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewCoverageAggregator.java @@ -46,7 +46,8 @@ public final class NewCoverageAggregator implements Decorator { public List<Metric> generatesNewCoverageMetrics() { return Arrays.asList( CoreMetrics.NEW_LINES_TO_COVER, CoreMetrics.NEW_UNCOVERED_LINES, CoreMetrics.NEW_CONDITIONS_TO_COVER, CoreMetrics.NEW_UNCOVERED_CONDITIONS, - CoreMetrics.NEW_IT_LINES_TO_COVER, CoreMetrics.NEW_IT_UNCOVERED_LINES, CoreMetrics.NEW_IT_CONDITIONS_TO_COVER, CoreMetrics.NEW_IT_UNCOVERED_CONDITIONS); + CoreMetrics.NEW_IT_LINES_TO_COVER, CoreMetrics.NEW_IT_UNCOVERED_LINES, CoreMetrics.NEW_IT_CONDITIONS_TO_COVER, CoreMetrics.NEW_IT_UNCOVERED_CONDITIONS, + CoreMetrics.NEW_OVERALL_LINES_TO_COVER, CoreMetrics.NEW_OVERALL_UNCOVERED_LINES, CoreMetrics.NEW_OVERALL_CONDITIONS_TO_COVER, CoreMetrics.NEW_OVERALL_UNCOVERED_CONDITIONS); } public void decorate(Resource resource, DecoratorContext context) { @@ -60,6 +61,10 @@ public final class NewCoverageAggregator implements Decorator { aggregate(context, CoreMetrics.NEW_IT_UNCOVERED_LINES, maxPeriods); aggregate(context, CoreMetrics.NEW_IT_CONDITIONS_TO_COVER, maxPeriods); aggregate(context, CoreMetrics.NEW_IT_UNCOVERED_CONDITIONS, maxPeriods); + aggregate(context, CoreMetrics.NEW_OVERALL_LINES_TO_COVER, maxPeriods); + aggregate(context, CoreMetrics.NEW_OVERALL_UNCOVERED_LINES, maxPeriods); + aggregate(context, CoreMetrics.NEW_OVERALL_CONDITIONS_TO_COVER, maxPeriods); + aggregate(context, CoreMetrics.NEW_OVERALL_UNCOVERED_CONDITIONS, maxPeriods); } } diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewOverallCoverageFileAnalyzer.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewOverallCoverageFileAnalyzer.java new file mode 100644 index 00000000000..3808a56f1d9 --- /dev/null +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewOverallCoverageFileAnalyzer.java @@ -0,0 +1,66 @@ +/* + * 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.core.timemachine; + +import org.sonar.api.measures.CoreMetrics; +import org.sonar.api.measures.Metric; +import org.sonar.batch.components.TimeMachineConfiguration; + +public class NewOverallCoverageFileAnalyzer extends AbstractNewCoverageFileAnalyzer { + + public NewOverallCoverageFileAnalyzer(TimeMachineConfiguration timeMachineConfiguration) { + super(timeMachineConfiguration); + } + + @Override + public Metric getCoverageLineHitsDataMetric() { + return CoreMetrics.OVERALL_COVERAGE_LINE_HITS_DATA; + } + + @Override + public Metric getConditionsByLineMetric() { + return CoreMetrics.OVERALL_CONDITIONS_BY_LINE; + } + + @Override + public Metric getCoveredConditionsByLineMetric() { + return CoreMetrics.OVERALL_COVERED_CONDITIONS_BY_LINE; + } + + @Override + public Metric getNewLinesToCoverMetric() { + return CoreMetrics.NEW_OVERALL_LINES_TO_COVER; + } + + @Override + public Metric getNewUncoveredLinesMetric() { + return CoreMetrics.NEW_OVERALL_UNCOVERED_LINES; + } + + @Override + public Metric getNewConditionsToCoverMetric() { + return CoreMetrics.NEW_OVERALL_CONDITIONS_TO_COVER; + } + + @Override + public Metric getNewUncoveredConditionsMetric() { + return CoreMetrics.NEW_OVERALL_UNCOVERED_CONDITIONS; + } +} diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/it_coverage.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/it_coverage.html.erb index e21eb58dbe0..86add802fd0 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/it_coverage.html.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/it_coverage.html.erb @@ -31,6 +31,36 @@ <% end %> </div> </td> + <% end -%> + <% if overall_coverage -%> + <td nowrap valign="top"> + <div class="dashbox"> + <p class="title"><%= message('widget.overall-coverage.name') -%></p> + + <p> + <span class="big"><%= format_measure(overall_coverage, :suffix => '', :url => url_for_drilldown('overall_coverage'), :default => '-') %></span> + <%= dashboard_configuration.selected_period? ? format_variation(overall_coverage) : trend_icon(overall_coverage) -%> + </p> + <% it_line_coverage=measure('overall_line_coverage') + if it_line_coverage %> + <p> + <%= format_measure(it_line_coverage, :suffix => message('widget.overall-coverage.line_coverage.suffix'), :url => url_for_drilldown('overall_uncovered_lines', :highlight => 'overall_line_coverage')) %> + <%= dashboard_configuration.selected_period? ? format_variation(it_line_coverage) : trend_icon(it_line_coverage) -%> + </p> + <% end %> + <% it_branch_coverage=measure('overall_branch_coverage') + if it_branch_coverage %> + <p> + <%= format_measure(it_branch_coverage, :suffix => message('widget.overall-coverage.branch_coverage.suffix'), :url => url_for_drilldown('overall_uncovered_conditions', :highlight => 'overall_branch_coverage')) %> + <%= dashboard_configuration.selected_period? ? format_variation(it_branch_coverage) : trend_icon(it_branch_coverage) -%> + </p> + <% end %> + </div> + </td> + <% end -%> + </tr> + <tr> + <% if it_coverage -%> <td nowrap valign="top"> <div class="dashbox"> <% @@ -77,30 +107,6 @@ <% if overall_coverage -%> <td nowrap valign="top"> <div class="dashbox"> - <p class="title"><%= message('widget.overall-coverage.name') -%></p> - - <p> - <span class="big"><%= format_measure(overall_coverage, :suffix => '', :url => url_for_drilldown('overall_coverage'), :default => '-') %></span> - <%= dashboard_configuration.selected_period? ? format_variation(overall_coverage) : trend_icon(overall_coverage) -%> - </p> - <% it_line_coverage=measure('overall_line_coverage') - if it_line_coverage %> - <p> - <%= format_measure(it_line_coverage, :suffix => message('widget.overall-coverage.line_coverage.suffix'), :url => url_for_drilldown('overall_uncovered_lines', :highlight => 'overall_line_coverage')) %> - <%= dashboard_configuration.selected_period? ? format_variation(it_line_coverage) : trend_icon(it_line_coverage) -%> - </p> - <% end %> - <% it_branch_coverage=measure('overall_branch_coverage') - if it_branch_coverage %> - <p> - <%= format_measure(it_branch_coverage, :suffix => message('widget.overall-coverage.branch_coverage.suffix'), :url => url_for_drilldown('overall_uncovered_conditions', :highlight => 'overall_branch_coverage')) %> - <%= dashboard_configuration.selected_period? ? format_variation(it_branch_coverage) : trend_icon(it_branch_coverage) -%> - </p> - <% end %> - </div> - </td> - <td nowrap valign="top"> - <div class="dashbox"> <% if dashboard_configuration.selected_period? new_lines_to_cover_measure=measure('new_overall_lines_to_cover') diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_coverage.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_coverage.html.erb index f4614113556..594a9002a88 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_coverage.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_header_coverage.html.erb @@ -1,5 +1,5 @@ <div id="coverage_header" class="tab_header"> - <% if @period && (measure('new_coverage') || measure('new_it_coverage')|| measure('new_overall_coverage')) %> + <% if @period && (measure('new_coverage') || measure('new_it_coverage') || measure('new_overall_coverage')) %> <p><%= message('coverage_viewer.on_new_code') -%> :</p> <table> <tr> |