From: Simon Brandhof Date: Wed, 22 Apr 2015 22:00:36 +0000 (+0200) Subject: SONAR-6392 Drop measure trends X-Git-Tag: 5.2-RC1~2132 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fpull%2F249%2Fhead;p=sonarqube.git SONAR-6392 Drop measure trends --- 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 fb064dc3486..4afed1eb7ef 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 @@ -20,7 +20,11 @@ package org.sonar.plugins.core; import com.google.common.collect.ImmutableList; -import org.sonar.api.*; +import org.sonar.api.CoreProperties; +import org.sonar.api.Properties; +import org.sonar.api.Property; +import org.sonar.api.PropertyType; +import org.sonar.api.SonarPlugin; import org.sonar.core.timemachine.Periods; import org.sonar.plugins.core.charts.DistributionAreaChart; import org.sonar.plugins.core.charts.DistributionBarChart; @@ -34,11 +38,56 @@ import org.sonar.plugins.core.measurefilters.MyFavouritesFilter; import org.sonar.plugins.core.measurefilters.ProjectFilter; import org.sonar.plugins.core.notifications.alerts.NewAlerts; import org.sonar.plugins.core.security.ApplyProjectRolesDecorator; -import org.sonar.plugins.core.sensors.*; -import org.sonar.plugins.core.timemachine.*; -import org.sonar.plugins.core.widgets.*; -import org.sonar.plugins.core.widgets.issues.*; -import org.sonar.plugins.core.widgets.measures.*; +import org.sonar.plugins.core.sensors.BranchCoverageDecorator; +import org.sonar.plugins.core.sensors.CommentDensityDecorator; +import org.sonar.plugins.core.sensors.CoverageDecorator; +import org.sonar.plugins.core.sensors.DirectoriesDecorator; +import org.sonar.plugins.core.sensors.FilesDecorator; +import org.sonar.plugins.core.sensors.ItBranchCoverageDecorator; +import org.sonar.plugins.core.sensors.ItCoverageDecorator; +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.OverallBranchCoverageDecorator; +import org.sonar.plugins.core.sensors.OverallCoverageDecorator; +import org.sonar.plugins.core.sensors.OverallLineCoverageDecorator; +import org.sonar.plugins.core.sensors.UnitTestDecorator; +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.TimeMachineConfigurationPersister; +import org.sonar.plugins.core.timemachine.VariationDecorator; +import org.sonar.plugins.core.widgets.AlertsWidget; +import org.sonar.plugins.core.widgets.BubbleChartWidget; +import org.sonar.plugins.core.widgets.ComplexityWidget; +import org.sonar.plugins.core.widgets.CoverageWidget; +import org.sonar.plugins.core.widgets.CustomMeasuresWidget; +import org.sonar.plugins.core.widgets.DebtOverviewWidget; +import org.sonar.plugins.core.widgets.DescriptionWidget; +import org.sonar.plugins.core.widgets.DocumentationCommentsWidget; +import org.sonar.plugins.core.widgets.DuplicationsWidget; +import org.sonar.plugins.core.widgets.EventsWidget; +import org.sonar.plugins.core.widgets.HotspotMetricWidget; +import org.sonar.plugins.core.widgets.ItCoverageWidget; +import org.sonar.plugins.core.widgets.ProjectFileCloudWidget; +import org.sonar.plugins.core.widgets.SizeWidget; +import org.sonar.plugins.core.widgets.TechnicalDebtPyramidWidget; +import org.sonar.plugins.core.widgets.TimeMachineWidget; +import org.sonar.plugins.core.widgets.TimelineWidget; +import org.sonar.plugins.core.widgets.TreemapWidget; +import org.sonar.plugins.core.widgets.WelcomeWidget; +import org.sonar.plugins.core.widgets.issues.ActionPlansWidget; +import org.sonar.plugins.core.widgets.issues.IssueFilterWidget; +import org.sonar.plugins.core.widgets.issues.IssueTagCloudWidget; +import org.sonar.plugins.core.widgets.issues.IssuesWidget; +import org.sonar.plugins.core.widgets.issues.ProjectIssueFilterWidget; +import org.sonar.plugins.core.widgets.measures.MeasureFilterAsBubbleChartWidget; +import org.sonar.plugins.core.widgets.measures.MeasureFilterAsCloudWidget; +import org.sonar.plugins.core.widgets.measures.MeasureFilterAsHistogramWidget; +import org.sonar.plugins.core.widgets.measures.MeasureFilterAsPieChartWidget; +import org.sonar.plugins.core.widgets.measures.MeasureFilterAsTreemapWidget; +import org.sonar.plugins.core.widgets.measures.MeasureFilterListWidget; import java.util.List; @@ -279,7 +328,6 @@ public final class CorePlugin extends SonarPlugin { ManualMeasureDecorator.class, // time machine - TendencyDecorator.class, VariationDecorator.class, TimeMachineConfigurationPersister.class, NewCoverageFileAnalyzer.class, diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TendencyAnalyser.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TendencyAnalyser.java deleted file mode 100644 index 07fdef297f6..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TendencyAnalyser.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 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.timemachine; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -import java.util.List; - -public class TendencyAnalyser { - - public static final Integer TENDENCY_BIG_UP = 2; - public static final Integer TENDENCY_UP = 1; - public static final Integer TENDENCY_NEUTRAL = 0; - public static final Integer TENDENCY_DOWN = -1; - public static final Integer TENDENCY_BIG_DOWN = -2; - - public Integer analyseLevel(List values) { - TendencyAnalyser.SlopeData slopeData = analyse(values); - if (slopeData != null) { - return slopeData.getLevel(); - } - return null; - } - - public SlopeData analyse(List values) { - double sumY = 0.0; - double sumX = 0.0; - double sumYPower2 = 0.0; - double sumXY = 0.0; - double sumXPower2 = 0.0; - int nbrPoints = 0; - boolean nullValuesYList = true; - int i = 0; - for (Double p : values) { - if (p != null) { - nullValuesYList = false; - // SumY calculation - sumY += p; - // sumYPower2 calculation - sumYPower2 += p * p; - // sumXY calculation - sumXY += p * (i + 1); - // SumX calculation - sumX += (i + 1); - // sumXPower2 calculation - sumXPower2 += (i + 1) * (i + 1); - // Point number calculation - nbrPoints++; - } - i++; - } - // no tendency if null values or only 1 value - if (nullValuesYList || nbrPoints == 1) { - return null; - } - double n0 = (nbrPoints * sumXY) - (sumX * sumY); - double d = (nbrPoints * sumXPower2) - (sumX * sumX); - double n1 = (sumY * sumXPower2) - (sumX * sumXY); - - SlopeData result = new SlopeData(); - - // yIntercept Calculation the value when X equals zero - result.setYIntercept(n1 / d); - // Slope Calculation - if (Double.doubleToRawLongBits(n0) == 0L && Double.doubleToRawLongBits(d) == 0L) { - result.setSlope(0.0); - } else { - Double slope = n0 / d; - if (Double.isNaN(slope) || Double.isInfinite(slope)) { - result.setSlope(null); - } else { - result.setSlope(slope); - } - } - result.setSumXPower2(sumXPower2); - result.setSumXY(sumXY); - result.setSumYPower2(sumYPower2); - - if (Double.doubleToRawLongBits(sumXPower2) == 0L || Double.doubleToRawLongBits(sumYPower2) == 0L) { - result.setCorrelationRate(0.0); - } else { - result.setCorrelationRate(sumXY / Math.sqrt(sumXPower2 * sumYPower2)); - } - - return result; - } - - static class SlopeData { - private double sumXPower2; - private double sumYPower2; - private double sumXY; - // not used today - private double yIntercept; - private Double slope; - private Double correlationRate; - - public double getSumXPower2() { - return sumXPower2; - } - - public void setSumXPower2(double sumXPower2) { - this.sumXPower2 = sumXPower2; - } - - public double getSumYPower2() { - return sumYPower2; - } - - public void setSumYPower2(double sumYPower2) { - this.sumYPower2 = sumYPower2; - } - - public double getSumXY() { - return sumXY; - } - - public void setSumXY(double sumXY) { - this.sumXY = sumXY; - } - - public double getYIntercept() { - return yIntercept; - } - - public void setYIntercept(double yIntercept) { - this.yIntercept = yIntercept; - } - - @CheckForNull - public Double getSlope() { - return slope; - } - - public void setSlope(@Nullable Double slope) { - this.slope = slope; - } - - public Double getCorrelationRate() { - return correlationRate; - } - - public void setCorrelationRate(Double correlationRate) { - this.correlationRate = correlationRate; - } - - public Integer getLevel() { - double hSlope = 0.8; - double nSlope = 0.2; - - double vHighCorcoef = 1.0; - double modCorcoef = 0.69; - Double correlationCoeff = getCorrelationRate(); - boolean vHCorCoefPos = (correlationCoeff > modCorcoef) && (correlationCoeff <= vHighCorcoef); - boolean vHCorCoefNeg = (correlationCoeff < -modCorcoef) && (correlationCoeff >= -vHighCorcoef); - - if ((vHCorCoefPos || vHCorCoefNeg) && (slope >= hSlope)) { - return TENDENCY_BIG_UP; - - } else if ((vHCorCoefPos || vHCorCoefNeg) && (slope <= -hSlope)) { - return TENDENCY_BIG_DOWN; - - } else if ((vHCorCoefPos || vHCorCoefNeg) && ((slope >= nSlope) && (slope < hSlope))) { - return TENDENCY_UP; - - } else if ((vHCorCoefPos || vHCorCoefNeg) && ((slope <= -nSlope) && (slope > -hSlope))) { - return TENDENCY_DOWN; - - } else if ((vHCorCoefPos || vHCorCoefNeg) && ((slope < nSlope) || (slope > -nSlope))) { - return TENDENCY_NEUTRAL; - - } else if (correlationCoeff == 0 && slope == 0 && !vHCorCoefPos && !vHCorCoefNeg) { - return TENDENCY_NEUTRAL; - } - return null; - } - } -} diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TendencyDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TendencyDecorator.java deleted file mode 100644 index aa98cf6c603..00000000000 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TendencyDecorator.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 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.timemachine; - -import org.sonar.batch.deprecated.components.PeriodsDefinition; - -import org.sonar.api.batch.RequiresDB; -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.ListMultimap; -import com.google.common.collect.Lists; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.time.DateUtils; -import org.sonar.api.batch.Decorator; -import org.sonar.api.batch.DecoratorBarriers; -import org.sonar.api.batch.DecoratorContext; -import org.sonar.api.batch.DependedUpon; -import org.sonar.api.batch.DependsUpon; -import org.sonar.api.batch.TimeMachine; -import org.sonar.api.batch.TimeMachineQuery; -import org.sonar.api.measures.Measure; -import org.sonar.api.measures.Metric; -import org.sonar.api.measures.MetricFinder; -import org.sonar.api.resources.Project; -import org.sonar.api.resources.Resource; -import org.sonar.api.resources.Scopes; - -import java.util.List; - -@RequiresDB -@DependedUpon(DecoratorBarriers.END_OF_TIME_MACHINE) -public class TendencyDecorator implements Decorator { - - public static final String PROP_DAYS_DESCRIPTION = "Number of days the tendency should be calculated on."; - - private TimeMachine timeMachine; - private TimeMachineQuery query; - private TendencyAnalyser analyser; - private List metrics; - - public TendencyDecorator(TimeMachine timeMachine, MetricFinder metricFinder) { - this.timeMachine = timeMachine; - this.analyser = new TendencyAnalyser(); - this.metrics = Lists.newLinkedList(); - for (Metric metric : metricFinder.findAll()) { - if (metric.isNumericType()) { - metrics.add(metric); - } - } - } - - TendencyDecorator(TimeMachine timeMachine, TimeMachineQuery query, TendencyAnalyser analyser) { - this.timeMachine = timeMachine; - this.query = query; - this.analyser = analyser; - } - - @DependsUpon - public List dependsUponMetrics() { - return metrics; - } - - protected TimeMachineQuery initQuery(Project project) { - int days = PeriodsDefinition.CORE_TENDENCY_DEPTH_DEFAULT_VALUE; - - // resource is set after - query = new TimeMachineQuery(null) - .setFrom(DateUtils.addDays(project.getAnalysisDate(), -days)) - .setToCurrentAnalysis(true) - .setMetrics(metrics); - return query; - } - - protected TimeMachineQuery resetQuery(Project project, Resource resource) { - if (query == null) { - initQuery(project); - } - query.setResource(resource); - return query; - } - - @Override - public boolean shouldExecuteOnProject(Project project) { - return true; - } - - @Override - public void decorate(Resource resource, DecoratorContext context) { - if (shouldDecorateResource(resource)) { - resetQuery(context.getProject(), resource); - List fields = timeMachine.getMeasuresFields(query); - ListMultimap valuesPerMetric = ArrayListMultimap.create(); - for (Object[] field : fields) { - valuesPerMetric.put((Metric) field[1], (Double) field[2]); - } - - for (Metric metric : query.getMetrics()) { - Measure measure = context.getMeasure(metric); - if (measure != null) { - List values = valuesPerMetric.get(metric); - values.add(measure.getValue()); - - measure.setTendency(analyser.analyseLevel(valuesPerMetric.get(metric))); - context.saveMeasure(measure); - } - } - } - } - - private boolean shouldDecorateResource(Resource resource) { - return StringUtils.equals(Scopes.PROJECT, resource.getScope()) || StringUtils.equals(Scopes.DIRECTORY, resource.getScope()); - } -} diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/complexity.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/complexity.html.erb index 6a24a955965..62832d2335a 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/complexity.html.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/complexity.html.erb @@ -15,7 +15,7 @@ <%= message('metric.complexity.name') %> <%= format_measure(complexity, :url => url_for_drilldown(complexity)) %> - <%= dashboard_configuration.selected_period? ? format_variation(complexity) : trend_icon(complexity) -%> + <%= format_variation(complexity) if dashboard_configuration.selected_period? -%>

<% end %> @@ -24,7 +24,7 @@ <%= message('widget.complexity.per_method.suffix') %> <%= format_measure(function_complexity, :url => url_for_drilldown(function_complexity)) %> - <%= dashboard_configuration.selected_period? ? format_variation(function_complexity) : trend_icon(function_complexity) -%> + <%= format_variation(function_complexity) if dashboard_configuration.selected_period? -%>

<% end %> @@ -33,7 +33,7 @@ <%= message('widget.complexity.per_class.suffix') %> <%= format_measure(class_complexity, :url => url_for_drilldown(class_complexity)) %> - <%= dashboard_configuration.selected_period? ? format_variation(class_complexity) : trend_icon(class_complexity) -%> + <%= format_variation(class_complexity) if dashboard_configuration.selected_period? -%>

<% end %> @@ -42,7 +42,7 @@ <%= message('widget.complexity.per_file.suffix') %> <%= format_measure(file_complexity, :url => url_for_drilldown(file_complexity)) %> - <%= dashboard_configuration.selected_period? ? format_variation(file_complexity) : trend_icon(file_complexity) -%> + <%= format_variation(file_complexity) if dashboard_configuration.selected_period? -%>

<% end %> diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/coverage.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/coverage.html.erb index 29dcc3eef58..e293cfa0d56 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/coverage.html.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/coverage.html.erb @@ -13,7 +13,7 @@ <%= message('widget.code_coverage.name') -%> <%= format_measure(code_coverage_measure, :suffix => '', :url => url_for_drilldown('coverage'), :default => '-') %> - <%= dashboard_configuration.selected_period? ? format_variation(code_coverage_measure) : trend_icon(code_coverage_measure) -%> + <%= format_variation(code_coverage_measure) if dashboard_configuration.selected_period? -%> <% @@ -24,7 +24,7 @@ <%= message('widget.code_coverage.line_coverage.suffix') -%> <%= format_measure(line_coverage, :url => url_for_drilldown('uncovered_lines', :highlight => 'line_coverage')) %> - <%= dashboard_configuration.selected_period? ? format_variation(line_coverage) : trend_icon(line_coverage) -%> + <%= format_variation(line_coverage) if dashboard_configuration.selected_period? -%> <% end %> @@ -36,7 +36,7 @@ <%= message('widget.code_coverage.condition_coverage.suffix') -%> <%= format_measure(branch_coverage, :url => url_for_drilldown('uncovered_conditions', :highlight => 'branch_coverage')) %> - <%= dashboard_configuration.selected_period? ? format_variation(branch_coverage) : trend_icon(branch_coverage) -%> + <%= format_variation(branch_coverage) if dashboard_configuration.selected_period? -%> <% end %> @@ -100,7 +100,7 @@ <%= message('widget.code_coverage.test_success') -%> <%= format_measure(success_percentage, :url => url_for_drilldown(success_percentage)) %> - <%= dashboard_configuration.selected_period? ? format_variation(success_percentage) : trend_icon(success_percentage) -%> + <%= format_variation(success_percentage) if dashboard_configuration.selected_period? -%> @@ -108,7 +108,7 @@ <%= message('widget.code_coverage.failures.suffix') -%> <%= format_measure(Metric::TEST_FAILURES, :url => url_for_drilldown(Metric::TEST_FAILURES)) %> - <%= dashboard_configuration.selected_period? ? format_variation(Metric::TEST_FAILURES) : trend_icon(Metric::TEST_FAILURES) -%> + <%= format_variation(Metric::TEST_FAILURES) if dashboard_configuration.selected_period? -%> @@ -116,7 +116,7 @@ <%= message('widget.code_coverage.errors.suffix') -%> <%= format_measure(Metric::TEST_ERRORS, :url => url_for_drilldown(Metric::TEST_ERRORS)) %> - <%= dashboard_configuration.selected_period? ? format_variation(Metric::TEST_ERRORS) : trend_icon(Metric::TEST_ERRORS) -%> + <%= format_variation(Metric::TEST_ERRORS) if dashboard_configuration.selected_period? -%> @@ -124,7 +124,7 @@ <%= message('widget.code_coverage.tests.suffix') -%> <%= format_measure(tests_measure, :url => url_for_drilldown('tests')) %> - <%= dashboard_configuration.selected_period? ? format_variation(tests_measure) : trend_icon(tests_measure) -%> + <%= format_variation(tests_measure) if dashboard_configuration.selected_period? -%> @@ -135,7 +135,7 @@ <%= message('widget.code_coverage.skipped.suffix') -%> <%= format_measure(skipped_measure, :url => url_for_drilldown(Metric::SKIPPED_TESTS)) %> - <%= dashboard_configuration.selected_period? ? format_variation(skipped_measure) : trend_icon(skipped_measure) -%> + <%= format_variation(skipped_measure) if dashboard_configuration.selected_period? -%> <% end %> @@ -144,7 +144,7 @@ <%= message('widget.code_coverage.execution_time') -%> <%= format_measure(execution_time, :url => url_for_drilldown('test_execution_time')) %> - <%= dashboard_configuration.selected_period? ? format_variation(execution_time) : trend_icon(execution_time) -%> + <%= format_variation(execution_time) if dashboard_configuration.selected_period? -%> diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/custom_measures.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/custom_measures.html.erb index 3ea96e27bd8..c817403bc8c 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/custom_measures.html.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/custom_measures.html.erb @@ -22,7 +22,7 @@ <%= format_measure(measure, :url => url_for_drilldown(measure, :period => period), :period => period) -%> <% else %> <%= format_measure(measure, :url => url_for_drilldown(measure)) -%> - <%= dashboard_configuration.selected_period? ? format_variation(measure) : trend_icon(measure) -%> + <%= format_variation(measure) if dashboard_configuration.selected_period? -%> <% end -%>

diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/debt_overview.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/debt_overview.erb index a945f084724..87cceb5ff3b 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/debt_overview.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/debt_overview.erb @@ -11,9 +11,6 @@ <%= message('metric.sqale_rating.name') -%> <%= format_measure(sqale_rating, :url => url_for_drilldown(sqale_rating)) %> - <% unless dashboard_configuration.selected_period? %> - <%= trend_icon(sqale_rating) -%> - <% end %> @@ -26,7 +23,7 @@ <%= message('metric.sqale_debt_ratio.name') -%> <%= format_measure(sqale_debt_ratio, :url => url_for_drilldown(sqale_debt_ratio)) %> - <%= dashboard_configuration.selected_period? ? format_variation(sqale_debt_ratio) : trend_icon(sqale_debt_ratio) -%> + <%= format_variation(sqale_debt_ratio) if dashboard_configuration.selected_period? -%> diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/documentation_comments_widget.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/documentation_comments_widget.html.erb index e0c4ffe5e56..06423d5c029 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/documentation_comments_widget.html.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/documentation_comments_widget.html.erb @@ -17,7 +17,7 @@ <%= message('widget.documentation_comments.documentation') -%> <%= format_measure(public_documented_api_density, :url => url_for_drilldown(Metric::PUBLIC_UNDOCUMENTED_API, :highlight => Metric::PUBLIC_DOCUMENTED_API_DENSITY)) %> - <%= dashboard_configuration.selected_period? ? format_variation('public_documented_api_density') : trend_icon('public_documented_api_density') -%> + <%= format_variation('public_documented_api_density') if dashboard_configuration.selected_period? -%> <% end %> @@ -25,14 +25,14 @@ <%= message('metric.public_api.name') -%> <%= format_measure(public_api,:url => url_for_drilldown(public_api)) %> - <%= dashboard_configuration.selected_period? ? format_variation(public_api) : trend_icon(public_api) -%> + <%= format_variation(public_api) if dashboard_configuration.selected_period? -%>
<%= message('metric.public_undocumented_api.abbreviation') -%> <%= format_measure(public_undocumented_api,:url => url_for_drilldown(public_undocumented_api)) %> - <%= dashboard_configuration.selected_period? ? format_variation(public_undocumented_api) : trend_icon(public_undocumented_api) -%> + <%= format_variation(public_undocumented_api) if dashboard_configuration.selected_period? -%>
@@ -45,14 +45,14 @@ <%= message('widget.documentation_comments.comments') -%> <%= format_measure(comment_lines_density,:url => url_for_drilldown(comment_lines_density))%> - <%= dashboard_configuration.selected_period? ? format_variation(comment_lines_density) : trend_icon(comment_lines_density) -%> + <%= format_variation(comment_lines_density) if dashboard_configuration.selected_period? -%>
<%= message('metric.comment_lines.name') -%> <%= format_measure(comment_lines,:url => url_for_drilldown(comment_lines)) %> - <%= dashboard_configuration.selected_period? ? format_variation(comment_lines) : trend_icon(comment_lines) -%> + <%= format_variation(comment_lines) if dashboard_configuration.selected_period? -%>
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 index 3eaaf6d4a55..99b487a57a7 100644 --- 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 @@ -8,7 +8,7 @@ <%= message('widget.duplications.duplications') -%> <%= format_measure(duplicated_lines_density, :url => url_for_drilldown('duplicated_lines', :highlight => 'duplicated_lines_density')) %> - <%= dashboard_configuration.selected_period? ? format_variation('duplicated_lines_density') : trend_icon('duplicated_lines_density') -%> + <%= format_variation('duplicated_lines_density') if dashboard_configuration.selected_period? -%> @@ -16,7 +16,7 @@ <%= message('widget.duplications.lines.suffix') -%> <%= format_measure(measure('duplicated_lines'), :url => url_for_drilldown('duplicated_lines'))%> - <%= dashboard_configuration.selected_period? ? format_variation('duplicated_lines') : trend_icon('duplicated_lines') -%> + <%= format_variation('duplicated_lines') if dashboard_configuration.selected_period? -%> @@ -24,7 +24,7 @@ <%= message('widget.duplications.blocks.suffix') -%> <%= format_measure(measure('duplicated_blocks'), :url => url_for_drilldown('duplicated_blocks'))%> - <%= dashboard_configuration.selected_period? ? format_variation('duplicated_blocks') : trend_icon('duplicated_blocks') -%> + <%= format_variation('duplicated_blocks') if dashboard_configuration.selected_period? -%> @@ -32,7 +32,7 @@ <%= message('widget.duplications.files.suffix') -%> <%= format_measure(measure('duplicated_files'), :url => url_for_drilldown('duplicated_files'))%> - <%= dashboard_configuration.selected_period? ? format_variation('duplicated_files') : trend_icon('duplicated_files') -%> + <%= format_variation('duplicated_files') if dashboard_configuration.selected_period? -%> diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/issues.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/issues.html.erb index 0e645dfa2bd..d27c35ca448 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/issues.html.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/issues.html.erb @@ -34,7 +34,7 @@ title="<%= tooltip -%>" data-toggle="tooltip" data-placement="bottom"> <%= format_measure(technical_debt) -%> - <%= dashboard_configuration.selected_period? ? format_variation(technical_debt) : trend_icon(technical_debt) -%> + <%= format_variation(technical_debt) if dashboard_configuration.selected_period? -%>
<% @@ -74,7 +74,7 @@ <%= format_measure(issues) -%> - <%= dashboard_configuration.selected_period? ? format_variation(issues) : trend_icon(issues) -%> + <%= format_variation(issues) if dashboard_configuration.selected_period? -%>
@@ -121,8 +121,6 @@ +<%= format_variation(new_blocker_issues, :style => 'none', :default => '-') -%> - <% else %> - <%= trend_icon(blocker_issues, :empty => true) -%> <% end %> @@ -142,8 +140,6 @@ +<%= format_variation(new_critical_issues, :style => 'none', :default => '-') -%> - <% else %> - <%= trend_icon(critical_issues, :empty => true) -%> <% end %> @@ -163,8 +159,6 @@ +<%= format_variation(new_major_issues, :style => 'none', :default => '-') -%> - <% else %> - <%= trend_icon(major_issues, :empty => true) -%> <% end %> @@ -184,8 +178,6 @@ +<%= format_variation(new_minor_issues, :style => 'none', :default => '-') -%> - <% else %> - <%= trend_icon(minor_issues, :empty => true) -%> <% end %> @@ -205,8 +197,6 @@ +<%= format_variation(new_info_issues, :style => 'none', :default => '-') -%> - <% else %> - <%= trend_icon(info_issues, :empty => true) -%> <% end %> 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 0f0daaafdd2..52c01fe6728 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 @@ -14,7 +14,7 @@ <%= message('widget.it-coverage.name') -%> <%= format_measure(it_coverage, :url => url_for_drilldown('it_coverage'), :default => '-') %> - <%= dashboard_configuration.selected_period? ? format_variation(it_coverage) : trend_icon(it_coverage) -%> + <%= format_variation(it_coverage) if dashboard_configuration.selected_period? -%>
@@ -26,7 +26,7 @@ <%= message('widget.it-coverage.line_coverage.suffix') -%> <%= format_measure(it_line_coverage, :url => url_for_drilldown('it_uncovered_lines', :highlight => 'it_line_coverage')) %> - <%= dashboard_configuration.selected_period? ? format_variation(it_line_coverage) : trend_icon(it_line_coverage) -%> + <%= format_variation(it_line_coverage) if dashboard_configuration.selected_period? -%> <% end %> @@ -39,7 +39,7 @@ <%= message('widget.it-coverage.condition_coverage.suffix') -%> <%= format_measure(it_branch_coverage, :url => url_for_drilldown('it_uncovered_conditions', :highlight => 'it_branch_coverage')) %> - <%= dashboard_configuration.selected_period? ? format_variation(it_branch_coverage) : trend_icon(it_branch_coverage) -%> + <%= format_variation(it_branch_coverage) if dashboard_configuration.selected_period? -%> <% end %> @@ -114,7 +114,7 @@ <%= message('widget.overall-coverage.name') -%> <%= format_measure(overall_coverage, :url => url_for_drilldown('overall_coverage'), :default => '-') %> - <%= dashboard_configuration.selected_period? ? format_variation(overall_coverage) : trend_icon(overall_coverage) -%> + <%= format_variation(overall_coverage) if dashboard_configuration.selected_period? -%> @@ -126,7 +126,7 @@ <%= message('widget.overall-coverage.line_coverage.suffix') -%> <%= format_measure(overall_line_coverage, :url => url_for_drilldown('overall_uncovered_lines', :highlight => 'overall_line_coverage')) %> - <%= dashboard_configuration.selected_period? ? format_variation(overall_line_coverage) : trend_icon(overall_line_coverage) -%> + <%= format_variation(overall_line_coverage) if dashboard_configuration.selected_period? -%> <% end %> @@ -139,7 +139,7 @@ <%= message('widget.overall-coverage.condition_coverage.suffix') -%> <%= format_measure(overall_branch_coverage, :url => url_for_drilldown('overall_uncovered_conditions', :highlight => 'overall_branch_coverage')) %> - <%= dashboard_configuration.selected_period? ? format_variation(overall_branch_coverage) : trend_icon(overall_branch_coverage) -%> + <%= format_variation(overall_branch_coverage) if dashboard_configuration.selected_period? -%> <% end %> @@ -170,7 +170,7 @@ :period => dashboard_configuration.period_index, :url => url_for_drilldown(new_coverage, :period => dashboard_configuration.period_index), :default => '-') %> - <%= dashboard_configuration.selected_period? ? format_variation(new_coverage) : trend_icon(new_coverage) -%> + <%= format_variation(new_coverage) if dashboard_configuration.selected_period? -%> <% end %> @@ -182,7 +182,7 @@ <%= format_measure(new_line_coverage, :period => dashboard_configuration.period_index, :url => url_for_drilldown(new_line_coverage, :period => dashboard_configuration.period_index)) %> - <%= dashboard_configuration.selected_period? ? format_variation(new_line_coverage) : trend_icon(new_line_coverage) -%> + <%= format_variation(new_line_coverage) if dashboard_configuration.selected_period? -%> <% end %> @@ -194,7 +194,7 @@ <%= format_measure(new_branch_coverage, :period => dashboard_configuration.period_index, :url => url_for_drilldown(new_branch_coverage, :period => dashboard_configuration.period_index)) %> - <%= dashboard_configuration.selected_period? ? format_variation(new_branch_coverage) : trend_icon(new_branch_coverage) -%> + <%= format_variation(new_branch_coverage) if dashboard_configuration.selected_period? -%> <% end %> diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/size.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/size.html.erb index 7811e848f0d..1a4387b1ecc 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/size.html.erb +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/size.html.erb @@ -26,13 +26,13 @@ <%= message('metric.ncloc.name') -%> <%= format_measure(ncloc, :url => url_for_drilldown(ncloc)) %> - <%= dashboard_configuration.selected_period? ? format_variation(ncloc) : trend_icon(ncloc) -%> + <%= format_variation(ncloc) if dashboard_configuration.selected_period? -%>

<% if generated_ncloc && generated_ncloc.value>0 %>

<%= message('including_abbreviated') -%> - <%= format_measure(generated_ncloc, :url => url_for_drilldown(generated_ncloc)) -%> <%= dashboard_configuration.selected_period? ? format_variation(generated_ncloc) : trend_icon(generated_ncloc) -%> + <%= format_measure(generated_ncloc, :url => url_for_drilldown(generated_ncloc)) -%> <%= format_variation(generated_ncloc) if dashboard_configuration.selected_period? -%> <%= message('metric.generated_ncloc.name.suffix') -%>

<% end %> @@ -92,7 +92,7 @@ <%= message('metric.lines.name') -%> <%= format_measure(lines, :url => url_for_drilldown(ncloc)) %> - <%= dashboard_configuration.selected_period? ? format_variation(lines) : trend_icon(lines) -%> + <%= format_variation(lines) if dashboard_configuration.selected_period? -%>

<% end %> @@ -105,7 +105,7 @@ <%= message('metric.files.name') -%> <%= format_measure(files, :url => url_for_drilldown(files)) %> - <%= dashboard_configuration.selected_period? ? format_variation(files) : trend_icon(files) -%> + <%= format_variation(files) if dashboard_configuration.selected_period? -%>

@@ -114,7 +114,7 @@ <%= message('metric.directories.name') -%> <%= format_measure(directories, :url => url_for_drilldown(directories)) %> - <%= dashboard_configuration.selected_period? ? format_variation(directories) : trend_icon(directories) -%> + <%= format_variation(directories) if dashboard_configuration.selected_period? -%>

<% end %> @@ -123,14 +123,14 @@ <%= message('metric.lines.name') -%> <%= format_measure(lines, :url => url_for_drilldown(lines)) %> - <%= dashboard_configuration.selected_period? ? format_variation(lines) : trend_icon(lines) -%> + <%= format_variation(lines) if dashboard_configuration.selected_period? -%>

<% if generated_lines && generated_lines.value>0 %>

<%= message('including_abbreviated') -%> - <%= format_measure(generated_lines, :url => url_for_drilldown(generated_lines)) -%> <%= dashboard_configuration.selected_period? ? format_variation(generated_lines) : trend_icon(generated_lines) -%> + <%= format_measure(generated_lines, :url => url_for_drilldown(generated_lines)) -%> <%= format_variation(generated_lines) if dashboard_configuration.selected_period? -%> <%= message('metric.generated_lines.name.suffix') -%>

<% end %> @@ -140,7 +140,7 @@ <%= message('projects') -%> <%= format_measure(projects) %> - <%= dashboard_configuration.selected_period? ? format_variation(projects) : trend_icon(projects) -%> + <%= format_variation(projects) if dashboard_configuration.selected_period? -%>

<% end %> @@ -154,7 +154,7 @@ <%= message('metric.functions.name') -%> <%= format_measure(functions, :url => url_for_drilldown(functions)) %> - <%= dashboard_configuration.selected_period? ? format_variation(functions) : trend_icon(functions) -%> + <%= format_variation(functions) if dashboard_configuration.selected_period? -%>

<% end %> @@ -164,7 +164,7 @@ <%= message('metric.classes.name') -%> <%= format_measure(classes, :url => url_for_drilldown(classes)) %> - <%= dashboard_configuration.selected_period? ? format_variation(classes) : trend_icon(classes) -%> + <%= format_variation(classes) if dashboard_configuration.selected_period? -%>

<% end %> @@ -174,7 +174,7 @@ <%= message('metric.statements.name') -%> <%= format_measure(statements, :url => url_for_drilldown(statements)) %> - <%= dashboard_configuration.selected_period? ? format_variation(statements) : trend_icon(statements) -%> + <%= format_variation(statements) if dashboard_configuration.selected_period? -%>

<% end %> @@ -184,7 +184,7 @@ <%= message('metric.accessors.name') -%> <%= format_measure(accessors, :url => url_for_drilldown(accessors)) %> - <%= dashboard_configuration.selected_period? ? format_variation(accessors) : trend_icon(accessors) -%> + <%= format_variation(accessors) if dashboard_configuration.selected_period? -%>

<% end %> diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TendencyAnalyserTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TendencyAnalyserTest.java deleted file mode 100644 index ae1e8630786..00000000000 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TendencyAnalyserTest.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 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.timemachine; - -import org.junit.Test; - -import java.util.Arrays; - -import static org.assertj.core.api.Assertions.assertThat; - -public class TendencyAnalyserTest { - static TendencyAnalyser.SlopeData analyse(Double... values) { - return new TendencyAnalyser().analyse(Arrays.asList(values)); - } - - static Integer analyseLevel(Double... values) { - return new TendencyAnalyser().analyseLevel(Arrays.asList(values)); - } - - @Test - public void testNoData() { - TendencyAnalyser.SlopeData slopeData = analyse(); - - assertThat(slopeData).isNull(); - } - - @Test - public void testNotEnoughData() { - assertThat(analyseLevel(10.0)).isNull(); - } - - @Test - public void testTendencyOnThreeDays() { - TendencyAnalyser.SlopeData slopeData = analyse(10.0, null, 9.9); - - assertThat(slopeData.getSlope()).isGreaterThan(-0.5).isLessThan(0.5); - assertThat(slopeData.getLevel()).isEqualTo(TendencyAnalyser.TENDENCY_NEUTRAL); - } - - @Test - public void testTendencyOnTwoZeroDays() { - TendencyAnalyser.SlopeData slopeData = analyse(0.0, 0.0); - - assertThat(slopeData.getSlope()).isZero(); - assertThat(slopeData.getLevel()).isEqualTo(TendencyAnalyser.TENDENCY_NEUTRAL); - } - - @Test - public void testTendencyOnThreeZeroDays() { - TendencyAnalyser.SlopeData slopeData = analyse(0.0, 0.0, 0.0); - - assertThat(slopeData.getSlope()).isZero(); - assertThat(slopeData.getLevel()).isEqualTo(TendencyAnalyser.TENDENCY_NEUTRAL); - } - - @Test - public void testBigDownOnThreeDays() { - TendencyAnalyser.SlopeData slopeData = analyse(90.0, 91.0, 50.0); - - assertThat(slopeData.getSlope()).isLessThan(-2.0); - assertThat(slopeData.getLevel()).isEqualTo(TendencyAnalyser.TENDENCY_BIG_DOWN); - } - - @Test - public void testFlatTendency() { - TendencyAnalyser.SlopeData slopeData = analyse(10.0, 10.2, 9.9); - - assertThat(slopeData.getSlope()).isGreaterThan(-0.5).isLessThan(0.5); - assertThat(slopeData.getLevel()).isEqualTo(TendencyAnalyser.TENDENCY_NEUTRAL); - } - - @Test - public void testFlatTendencyWithPeak() { - TendencyAnalyser.SlopeData slopeData = analyse(10.0, 15.0, 10.0); - - assertThat(slopeData.getSlope()).isGreaterThan(-0.5).isLessThan(0.5); - assertThat(slopeData.getLevel()).isEqualTo(TendencyAnalyser.TENDENCY_NEUTRAL); - } - - @Test - public void testBigUpTendencyOnThreeValues() { - TendencyAnalyser.SlopeData slopeData = analyse(10.0, 12.0, 15.5); - - assertThat(slopeData.getSlope()).isGreaterThan(2.5).isLessThan(3.0); - assertThat(slopeData.getLevel()).isEqualTo(TendencyAnalyser.TENDENCY_BIG_UP); - } - - @Test - public void testBigUpTendencyOnTenValues() { - TendencyAnalyser.SlopeData slopeData = analyse(45.0, 60.0, 57.0, 65.0, 58.0, 68.0, 59.0, 66.0, 76.0, 80.0); - - assertThat(slopeData.getSlope()).isGreaterThan(2.5).isLessThan(3.0); - assertThat(slopeData.getLevel()).isEqualTo(TendencyAnalyser.TENDENCY_BIG_UP); - } - - @Test - public void testMediumUpTendency() { - TendencyAnalyser.SlopeData slopeData = analyse(5.0, 4.5, 5.1, 5.5, 5.3, 6.4, 6.3, 6.6, 6.8, 6.5); - - assertThat(slopeData.getSlope()).isGreaterThan(0.0).isLessThan(1.0); - assertThat(slopeData.getLevel()).isEqualTo(TendencyAnalyser.TENDENCY_UP); - } - - @Test - public void testAsymetricAlgorithm() { - TendencyAnalyser.SlopeData slopeData1 = analyse(45.0, 47.0, 95.0); - TendencyAnalyser.SlopeData slopeData2 = analyse(95.0, 45.0, 47.0); - - assertThat(slopeData1.getSlope()).isNotEqualTo(slopeData2.getSlope()); - } -} diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TendencyDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TendencyDecoratorTest.java deleted file mode 100644 index 839e6f51862..00000000000 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TendencyDecoratorTest.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 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.timemachine; - -import org.junit.Test; -import org.junit.matchers.JUnitMatchers; -import org.sonar.api.batch.DecoratorContext; -import org.sonar.api.batch.TimeMachine; -import org.sonar.api.batch.TimeMachineQuery; -import org.sonar.api.measures.CoreMetrics; -import org.sonar.api.measures.Measure; -import org.sonar.api.measures.Metric; -import org.sonar.api.measures.MetricFinder; -import org.sonar.api.resources.Directory; -import org.sonar.api.resources.Project; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Arrays; -import java.util.Date; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.mockito.Matchers.anyList; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -public class TendencyDecoratorTest { - - @Test - public void initQuery() throws ParseException { - Project project = mock(Project.class); - when(project.getAnalysisDate()).thenReturn(date("2009-12-25")); - - MetricFinder metricFinder = mock(MetricFinder.class); - when(metricFinder.findAll()).thenReturn(Arrays.asList(CoreMetrics.LINES, CoreMetrics.COVERAGE, CoreMetrics.COVERAGE_LINE_HITS_DATA)); - - TendencyDecorator decorator = new TendencyDecorator(null, metricFinder); - - TimeMachineQuery query = decorator.initQuery(project); - assertThat(query.getMetrics().size(), is(2)); - assertThat(query.getMetrics(), JUnitMatchers.hasItems(CoreMetrics.LINES, CoreMetrics.COVERAGE)); - assertThat(query.getFrom(), is(date("2009-11-25"))); - assertThat(query.isToCurrentAnalysis(), is(true)); - } - - @Test - public void includeCurrentMeasures() throws ParseException { - TendencyAnalyser analyser = mock(TendencyAnalyser.class); - TimeMachineQuery query = new TimeMachineQuery(null).setMetrics(CoreMetrics.LINES, CoreMetrics.COVERAGE); - TimeMachine timeMachine = mock(TimeMachine.class); - - when(timeMachine.getMeasuresFields(query)).thenReturn(Arrays.asList( - new Object[] {date("2009-12-01"), CoreMetrics.LINES, 1200.0}, - new Object[] {date("2009-12-01"), CoreMetrics.COVERAGE, 80.5}, - new Object[] {date("2009-12-02"), CoreMetrics.LINES, 1300.0}, - new Object[] {date("2009-12-02"), CoreMetrics.COVERAGE, 79.6}, - new Object[] {date("2009-12-15"), CoreMetrics.LINES, 1150.0} - )); - - DecoratorContext context = mock(DecoratorContext.class); - when(context.getMeasure(CoreMetrics.LINES)).thenReturn(new Measure(CoreMetrics.LINES, 1400.0)); - when(context.getMeasure(CoreMetrics.COVERAGE)).thenReturn(new Measure(CoreMetrics.LINES, 90.0)); - - TendencyDecorator decorator = new TendencyDecorator(timeMachine, query, analyser); - decorator.decorate(Directory.create("org/foo"), context); - - verify(analyser).analyseLevel(Arrays.asList(1200.0, 1300.0, 1150.0, 1400.0)); - verify(analyser).analyseLevel(Arrays.asList(80.5, 79.6, 90.0)); - } - - @Test - public void noTendencyIfNoCurrentMeasures() throws ParseException { - TendencyAnalyser analyser = mock(TendencyAnalyser.class); - TimeMachineQuery query = new TimeMachineQuery(null).setMetrics(CoreMetrics.LINES, CoreMetrics.COVERAGE); - TimeMachine timeMachine = mock(TimeMachine.class); - - when(timeMachine.getMeasuresFields(query)).thenReturn(Arrays.asList( - new Object[] {date("2009-12-01"), CoreMetrics.LINES, 1200.0}, - new Object[] {date("2009-12-02"), CoreMetrics.LINES, 1300.0} - )); - - DecoratorContext context = mock(DecoratorContext.class); - TendencyDecorator decorator = new TendencyDecorator(timeMachine, query, analyser); - decorator.decorate(Directory.create("org/foo"), context); - - verify(analyser, never()).analyseLevel(anyList()); - } - - private Date date(String date) throws ParseException { - return new SimpleDateFormat("yyyy-MM-dd").parse(date); - } -} diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/ws/ResourcesWs.java b/server/sonar-server/src/main/java/org/sonar/server/component/ws/ResourcesWs.java index d69bb9344ec..7c6eaee9b76 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/component/ws/ResourcesWs.java +++ b/server/sonar-server/src/main/java/org/sonar/server/component/ws/ResourcesWs.java @@ -97,8 +97,7 @@ public class ResourcesWs implements WebService { .setExampleValue("10"); action.createParam("includetrends") - .setDescription("Include trends and period variations in response: add <trend> (1 if better, else worse), <var> (1 if measure value increases) " + - "and nodes <p*> for period variations") + .setDescription("Include period variations in response: add nodes <p*> for period variations") .setDefaultValue("false") .setPossibleValues("true", "false"); diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistMeasuresStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistMeasuresStep.java index dfcc18cf518..b020867387b 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistMeasuresStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistMeasuresStep.java @@ -104,7 +104,6 @@ public class PersistMeasuresStep implements ComputationStep { } MeasureDto out = new MeasureDto(); - out.setTendency(in.hasTendency() ? in.getTendency() : null); out.setVariation(1, in.hasVariationValue1() ? in.getVariationValue1() : null); out.setVariation(2, in.hasVariationValue2() ? in.getVariationValue2() : null); out.setVariation(3, in.hasVariationValue3() ? in.getVariationValue3() : null); diff --git a/server/sonar-server/src/main/resources/org/sonar/server/design/file_design.html.erb b/server/sonar-server/src/main/resources/org/sonar/server/design/file_design.html.erb index 63e9020b77b..d49caa22ded 100644 --- a/server/sonar-server/src/main/resources/org/sonar/server/design/file_design.html.erb +++ b/server/sonar-server/src/main/resources/org/sonar/server/design/file_design.html.erb @@ -13,7 +13,7 @@ <%= message('widget.file_design.file_tangle_index') -%> <%= format_measure(file_tangle_index, :suffix => '', :default => '-', :url => dsm_url) -%> - <%= dashboard_configuration.selected_period? ? format_variation(file_tangle_index) : trend_icon(file_tangle_index, :big => true) -%> + <%= format_variation(file_tangle_index) if dashboard_configuration.selected_period? -%> @@ -23,7 +23,7 @@ > <%= format_measure(file_cycles, :default => '-', :url => dsm_url) %> - <%= dashboard_configuration.selected_period? ? format_variation(file_cycles) : trend_icon(file_cycles) -%> + <%= format_variation(file_cycles) if dashboard_configuration.selected_period? -%> <% end %> @@ -37,7 +37,7 @@ <%= message('widget.file_design.suspect_file_dependencies') -%> <%= format_measure(file_feedback_edges, :url => dsm_url) -%> - <%= dashboard_configuration.selected_period? ? format_variation(file_feedback_edges) : trend_icon(file_feedback_edges, :big => true) -%> + <%= format_variation(file_feedback_edges) if dashboard_configuration.selected_period? -%> @@ -59,7 +59,7 @@ <%= message('widget.package_design.package_tangle_index') -%> <%= format_measure(package_tangle_index, :suffix => '', :default => '-', :url => dsm_url) %> - <%= dashboard_configuration.selected_period? ? format_variation(package_tangle_index) : trend_icon(package_tangle_index) -%> + <%= format_variation(package_tangle_index) if dashboard_configuration.selected_period? -%> @@ -69,7 +69,7 @@ > <%= format_measure(package_cycles, :default => '-', :url => dsm_url) %> - <%= dashboard_configuration.selected_period? ? format_variation(package_cycles) : trend_icon(package_cycles) -%> + <%= format_variation(package_cycles) if dashboard_configuration.selected_period? -%> <% end %> @@ -87,7 +87,7 @@ <%= message('widget.package_design.between_packages.suffix') -%> <%= format_measure(package_feedback_edges, :default => '-', :url => dsm_url) %> - <%= dashboard_configuration.selected_period? ? format_variation(package_feedback_edges) : trend_icon(package_feedback_edges) -%> + <%= format_variation(package_feedback_edges) if dashboard_configuration.selected_period? -%> <% end %> @@ -97,7 +97,7 @@ <%= message('widget.package_design.between_files.suffix') -%> <%= format_measure(package_tangles, :default => '-', :url => dsm_url) %> - <%= dashboard_configuration.selected_period? ? format_variation(package_tangles) : trend_icon(package_tangles) -%> + <%= format_variation(package_tangles) if dashboard_configuration.selected_period? -%> <% end %> diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistMeasuresStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistMeasuresStepTest.java index bca0758af1f..d51b38deb45 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistMeasuresStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistMeasuresStepTest.java @@ -106,7 +106,6 @@ public class PersistMeasuresStepTest extends BaseStepTest { BatchReport.Measure.newBuilder() .setValueType(Constants.MeasureValueType.STRING) .setStringValue("measure-data") - .setTendency(2) .setVariationValue1(1.1d) .setVariationValue2(2.2d) .setVariationValue3(3.3d) @@ -125,7 +124,6 @@ public class PersistMeasuresStepTest extends BaseStepTest { BatchReport.Measure.newBuilder() .setValueType(Constants.MeasureValueType.DOUBLE) .setDoubleValue(123.123d) - .setTendency(2) .setVariationValue1(1.1d) .setVariationValue2(2.2d) .setVariationValue3(3.3d) @@ -162,7 +160,6 @@ public class PersistMeasuresStepTest extends BaseStepTest { BatchReport.Measure batchMeasure = BatchReport.Measure.newBuilder() .setValueType(Constants.MeasureValueType.DOUBLE) .setDoubleValue(123.123d) - .setTendency(2) .setVariationValue1(1.1d) .setVariationValue2(2.2d) .setVariationValue3(3.3d) @@ -331,7 +328,6 @@ public class PersistMeasuresStepTest extends BaseStepTest { .setCharacteristicId(123456) .setPersonId(5432) .setValue(123.123d) - .setTendency(2) .setVariation(1, 1.1d) .setVariation(2, 2.2d) .setVariation(3, 3.3d) diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/persistence/MeasureDaoTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/persistence/MeasureDaoTest.java index c83c7c258bd..497fbd3aeef 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/measure/persistence/MeasureDaoTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/measure/persistence/MeasureDaoTest.java @@ -147,7 +147,6 @@ public class MeasureDaoTest { .setComponentId(6L) .setValue(2.0d) .setData("measure-value") - .setTendency(42) .setSeverity(Severity.INFO) .setVariation(1, 1.0d) .setVariation(2, 2.0d) diff --git a/server/sonar-server/src/test/resources/org/sonar/server/measure/persistence/MeasureDaoTest/insert-result.xml b/server/sonar-server/src/test/resources/org/sonar/server/measure/persistence/MeasureDaoTest/insert-result.xml index 62b7c66cac3..f8929782f32 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/measure/persistence/MeasureDaoTest/insert-result.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/measure/persistence/MeasureDaoTest/insert-result.xml @@ -9,7 +9,7 @@ person_id="23" value="2.0" text_value="measure-value" - tendency="42" + tendency="[null]" rule_priority="0" measure_date="[null]" measure_data="[null]" diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb index 263be493f14..928fbb5dcef 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb @@ -289,7 +289,7 @@ class Api::ResourcesController < Api::ApiController def select_columns_for_measures select_columns='project_measures.id,project_measures.value,project_measures.metric_id,project_measures.snapshot_id,project_measures.rule_id,project_measures.rule_priority,project_measures.text_value,project_measures.characteristic_id,project_measures.measure_data' if params[:includetrends]=='true' - select_columns+=',project_measures.tendency,project_measures.variation_value_1,project_measures.variation_value_2,project_measures.variation_value_3,project_measures.variation_value_4,project_measures.variation_value_5' + select_columns+=',project_measures.variation_value_1,project_measures.variation_value_2,project_measures.variation_value_3,project_measures.variation_value_4,project_measures.variation_value_5' end if params[:includealerts]=='true' select_columns+=',project_measures.alert_status,project_measures.alert_text' @@ -438,10 +438,6 @@ class Api::ResourcesController < Api::ApiController json_measure[:alert_text]=measure.alert_text end if include_trends - if measure.tendency - json_measure[:trend]=measure.tendency_qualitative - json_measure[:var]=measure.tendency - end json_measure[:var1]=measure.variation_value_1.to_f if measure.variation_value_1 json_measure[:fvar1]=measure.format_numeric_value(measure.variation_value_1.to_f) if measure.variation_value_1 json_measure[:var2]=measure.variation_value_2.to_f if measure.variation_value_2 @@ -529,10 +525,6 @@ class Api::ResourcesController < Api::ApiController xml.alert_text(measure.alert_text) if measure.alert_text end if include_trends - if measure.tendency - xml.trend(measure.tendency_qualitative) - xml.var(measure.tendency) - end xml.var1(measure.variation_value_1.to_f) if measure.variation_value_1 xml.fvar1(measure.format_numeric_value(measure.variation_value_1.to_f)) if measure.variation_value_1 xml.var2(measure.variation_value_2.to_f) if measure.variation_value_2 diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/measures_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/measures_controller.rb index b7c210d08d1..c5f3c4bdc66 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/measures_controller.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/measures_controller.rb @@ -280,7 +280,6 @@ class MeasuresController < ApplicationController component_hash[:measures][measure.metric.key][:val] = measure.value if measure.value component_hash[:measures][measure.metric.key][:fval] = measure.formatted_value if measure.value component_hash[:measures][measure.metric.key][:text] = measure.data if measure.data - component_hash[:measures][measure.metric.key][:trend] = measure.tendency if fields.include?('measureTrend') && measure.tendency component_hash[:measures][measure.metric.key][:status] = measure.alert_status if fields.include?('measureStatus') && measure.alert_status component_hash[:measures][measure.metric.key][:p1] = measure.variation_value_1 if display_variation && measure.variation_value_1 component_hash[:measures][measure.metric.key][:p2] = measure.variation_value_2 if display_variation && measure.variation_value_2 diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/application_helper.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/application_helper.rb index c1eb79b9028..ff006badfd0 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/application_helper.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/application_helper.rb @@ -129,7 +129,7 @@ module ApplicationHelper # deprecated since 2.5. Use trend_icon() instead def tendency_icon(metric_or_measure, small=true, no_tendency_img=true) - trend_icon(metric_or_measure, {:big => !small, :empty => !no_tendency_img}) + trend_icon(nil, {:empty => !no_tendency_img}) end def boolean_icon(boolean_value, options={}) @@ -446,44 +446,10 @@ module ApplicationHelper end # - # - # Display the trend icon : - # - # === Optional parameters - # :empty: true|false. Show an empty transparent image when no trend or no measure. Default is false. - # :big : true|false (default is false). Default is 10x10px. Big is 16x16px. - # - # === Examples - # trend_icon('ncloc') - # trend_icon(measure('ncloc')) - # trend_icon('ncloc', :empty => true) + # Unsupported since version 5.2 # def trend_icon(metric_or_measure, options={}) - m=nil - if metric_or_measure.is_a? ProjectMeasure - m = metric_or_measure - elsif @snapshot - m = @snapshot.measure(metric_or_measure) - end - - if m.nil? || m.tendency.nil? || m.tendency==0 - return options[:empty] ? "" : nil - end - className = m.tendency.to_s - - if options[:big] - className += ' icon-trend-big' - end - - case m.tendency_qualitative - when 0 - className += ' icon-black' - when -1 - className += ' icon-red' - when 1 - className += ' icon-green' - end - "" + return options[:empty] ? "" : nil end # diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/components_helper.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/components_helper.rb index ec76730db50..83b50b73d7f 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/components_helper.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/components_helper.rb @@ -51,7 +51,7 @@ module ComponentsHelper elsif column.metric_column? measure = item_by_metric_id(measures_by_snapshot[snapshot], column.id ) measure_param = measure.value if measure - content = format_measure(measure) + trend_icon(measure, :empty => true) + content = format_measure(measure) end "<#{html_node} #{"nowrap='nowrap'" if nowrap} #{"x='#{measure_param}'" if measure_param} class='right'>" + content + "" diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/measures_helper.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/measures_helper.rb index 294eda12107..ac2d7e536de 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/measures_helper.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/measures_helper.rb @@ -43,8 +43,6 @@ module MeasuresHelper else format_variation(measure, :index => column.period, :style => 'light') end - elsif column.metric.numeric? - format_measure(measure) + ' ' + trend_icon(measure, :empty => true) else format_measure(measure) + ' ' end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/project_measure.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/project_measure.rb index ca542e4b687..c85fcbb789a 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/project_measure.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/project_measure.rb @@ -260,13 +260,8 @@ class ProjectMeasure < ActiveRecord::Base end def tendency_qualitative - if !metric.qualitative? || tendency.nil? || tendency==0 || metric.direction==0 - 0 - elsif tendency>0 - metric.direction>0 ? 1 : -1 - else - metric.direction<0 ? 1 : -1 - end + # unsupported since version 5.2 + 0 end def <=>(other) diff --git a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Measure.java b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Measure.java index 3d40a55e9a5..434e5676cbb 100644 --- a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Measure.java +++ b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Measure.java @@ -36,9 +36,6 @@ public class Measure extends Model { private String characteristicKey; private String characteristicName; - private Integer trend; - private Integer var; - private String ruleKey; private String ruleName; private String ruleSeverity; @@ -164,26 +161,6 @@ public class Measure extends Model { return this; } - @CheckForNull - public Integer getTrend() { - return trend; - } - - public Measure setTrend(@Nullable Integer trend) { - this.trend = trend; - return this; - } - - @CheckForNull - public Integer getVar() { - return var; - } - - public Measure setVar(@Nullable Integer var) { - this.var = var; - return this; - } - @CheckForNull public String getRuleKey() { return ruleKey; @@ -371,7 +348,6 @@ public class Measure extends Model { .append(", data='").append(data).append('\'') .append(", characteristicKey='").append(characteristicKey).append('\'') .append(", characteristicName='").append(characteristicName).append('\'') - .append(", trend=").append(trend).append(", var=").append(var) .append(", ruleKey='").append(ruleKey).append('\'') .append(", ruleName='").append(ruleName).append('\'') .append(", ruleCategory='").append(ruleCategory).append('\'') diff --git a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ResourceUnmarshaller.java b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ResourceUnmarshaller.java index e216ced6137..c4cbdb64d29 100644 --- a/server/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ResourceUnmarshaller.java +++ b/server/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ResourceUnmarshaller.java @@ -100,8 +100,6 @@ public class ResourceUnmarshaller extends AbstractUnmarshaller { .setFormattedValue(utils.getString(json, "frmt_val")) .setAlertStatus(utils.getString(json, "alert")) .setAlertText(utils.getString(json, "alert_text")) - .setTrend(utils.getInteger(json, "trend")) - .setVar(utils.getInteger(json, "var")) .setData(utils.getString(json, "data")) .setRuleKey(utils.getString(json, "rule_key")) .setRuleName(utils.getString(json, "rule_name")) diff --git a/server/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ResourceUnmarshallerTest.java b/server/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ResourceUnmarshallerTest.java index cc2f1f64faf..271ad82ec96 100644 --- a/server/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ResourceUnmarshallerTest.java +++ b/server/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ResourceUnmarshallerTest.java @@ -52,20 +52,6 @@ public class ResourceUnmarshallerTest extends UnmarshallerTestCase { assertThat(resource.getMeasureIntValue("unknown"), nullValue()); } - @Test - public void singleResourceWithTrends() { - Resource resource = new ResourceUnmarshaller().toModel(loadFile("/resources/single-resource-with-trends.json")); - assertSonar(resource); - - assertThat(resource.getMeasures().size(), is(2)); - assertThat(resource.getMeasureIntValue("lines"), is(47798)); - assertThat(resource.getMeasureIntValue("ncloc"), is(27066)); - assertThat(resource.getMeasure("lines").getTrend(), is(0)); - assertThat(resource.getMeasure("lines").getVar(), is(2)); - assertThat(resource.getMeasure("ncloc").getTrend(), is(1)); - assertThat(resource.getMeasure("ncloc").getVar(), is(1)); - } - @Test public void manyResources() { List resources = new ResourceUnmarshaller().toModels(loadFile("/resources/many-resources.json")); diff --git a/server/sonar-ws-client/src/test/resources/resources/single-resource-with-trends.json b/server/sonar-ws-client/src/test/resources/resources/single-resource-with-trends.json deleted file mode 100644 index a29048a2fd5..00000000000 --- a/server/sonar-ws-client/src/test/resources/resources/single-resource-with-trends.json +++ /dev/null @@ -1,30 +0,0 @@ -[ - { - "id":48569, - "key":"org.codehaus.sonar:sonar", - "name":"Sonar", - "scope":"PRJ", - "qualifier":"TRK", - "date":"2010-01-01T22:27:25+0000", - "creationDate":"2009-01-01T22:27:25+0000", - "lang":"java", - "version":"1.13-SNAPSHOT", - "description":"Embrace Quality", - "msr":[ - { - "key":"lines", - "val":47798.0, - "frmt_val":"47,798", - "trend":0, - "var":2 - }, - { - "key":"ncloc", - "val":27066.0, - "frmt_val":"27,066", - "trend":1, - "var":1 - } - ] - } -] \ No newline at end of file diff --git a/sonar-batch-protocol/src/main/gen-java/org/sonar/batch/protocol/output/BatchReport.java b/sonar-batch-protocol/src/main/gen-java/org/sonar/batch/protocol/output/BatchReport.java index 14a4027df77..0bdc5dc7df3 100644 --- a/sonar-batch-protocol/src/main/gen-java/org/sonar/batch/protocol/output/BatchReport.java +++ b/sonar-batch-protocol/src/main/gen-java/org/sonar/batch/protocol/output/BatchReport.java @@ -5501,15 +5501,6 @@ public final class BatchReport { */ double getVariationValue5(); - /** - * optional int32 tendency = 19; - */ - boolean hasTendency(); - /** - * optional int32 tendency = 19; - */ - int getTendency(); - /** * optional int32 characteric_id = 20; */ @@ -5683,18 +5674,13 @@ public final class BatchReport { variationValue5_ = input.readDouble(); break; } - case 152: { - bitField0_ |= 0x00020000; - tendency_ = input.readInt32(); - break; - } case 160: { - bitField0_ |= 0x00040000; + bitField0_ |= 0x00020000; charactericId_ = input.readInt32(); break; } case 168: { - bitField0_ |= 0x00080000; + bitField0_ |= 0x00040000; personId_ = input.readInt32(); break; } @@ -6175,28 +6161,13 @@ public final class BatchReport { return variationValue5_; } - public static final int TENDENCY_FIELD_NUMBER = 19; - private int tendency_; - /** - * optional int32 tendency = 19; - */ - public boolean hasTendency() { - return ((bitField0_ & 0x00020000) == 0x00020000); - } - /** - * optional int32 tendency = 19; - */ - public int getTendency() { - return tendency_; - } - public static final int CHARACTERIC_ID_FIELD_NUMBER = 20; private int charactericId_; /** * optional int32 characteric_id = 20; */ public boolean hasCharactericId() { - return ((bitField0_ & 0x00040000) == 0x00040000); + return ((bitField0_ & 0x00020000) == 0x00020000); } /** * optional int32 characteric_id = 20; @@ -6211,7 +6182,7 @@ public final class BatchReport { * optional int32 person_id = 21; */ public boolean hasPersonId() { - return ((bitField0_ & 0x00080000) == 0x00080000); + return ((bitField0_ & 0x00040000) == 0x00040000); } /** * optional int32 person_id = 21; @@ -6238,7 +6209,6 @@ public final class BatchReport { variationValue3_ = 0D; variationValue4_ = 0D; variationValue5_ = 0D; - tendency_ = 0; charactericId_ = 0; personId_ = 0; } @@ -6307,12 +6277,9 @@ public final class BatchReport { output.writeDouble(18, variationValue5_); } if (((bitField0_ & 0x00020000) == 0x00020000)) { - output.writeInt32(19, tendency_); - } - if (((bitField0_ & 0x00040000) == 0x00040000)) { output.writeInt32(20, charactericId_); } - if (((bitField0_ & 0x00080000) == 0x00080000)) { + if (((bitField0_ & 0x00040000) == 0x00040000)) { output.writeInt32(21, personId_); } getUnknownFields().writeTo(output); @@ -6393,14 +6360,10 @@ public final class BatchReport { .computeDoubleSize(18, variationValue5_); } if (((bitField0_ & 0x00020000) == 0x00020000)) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(19, tendency_); - } - if (((bitField0_ & 0x00040000) == 0x00040000)) { size += com.google.protobuf.CodedOutputStream .computeInt32Size(20, charactericId_); } - if (((bitField0_ & 0x00080000) == 0x00080000)) { + if (((bitField0_ & 0x00040000) == 0x00040000)) { size += com.google.protobuf.CodedOutputStream .computeInt32Size(21, personId_); } @@ -6555,12 +6518,10 @@ public final class BatchReport { bitField0_ = (bitField0_ & ~0x00008000); variationValue5_ = 0D; bitField0_ = (bitField0_ & ~0x00010000); - tendency_ = 0; - bitField0_ = (bitField0_ & ~0x00020000); charactericId_ = 0; - bitField0_ = (bitField0_ & ~0x00040000); + bitField0_ = (bitField0_ & ~0x00020000); personId_ = 0; - bitField0_ = (bitField0_ & ~0x00080000); + bitField0_ = (bitField0_ & ~0x00040000); return this; } @@ -6660,14 +6621,10 @@ public final class BatchReport { if (((from_bitField0_ & 0x00020000) == 0x00020000)) { to_bitField0_ |= 0x00020000; } - result.tendency_ = tendency_; + result.charactericId_ = charactericId_; if (((from_bitField0_ & 0x00040000) == 0x00040000)) { to_bitField0_ |= 0x00040000; } - result.charactericId_ = charactericId_; - if (((from_bitField0_ & 0x00080000) == 0x00080000)) { - to_bitField0_ |= 0x00080000; - } result.personId_ = personId_; result.bitField0_ = to_bitField0_; onBuilt(); @@ -6748,9 +6705,6 @@ public final class BatchReport { if (other.hasVariationValue5()) { setVariationValue5(other.getVariationValue5()); } - if (other.hasTendency()) { - setTendency(other.getTendency()); - } if (other.hasCharactericId()) { setCharactericId(other.getCharactericId()); } @@ -7638,44 +7592,12 @@ public final class BatchReport { return this; } - private int tendency_ ; - /** - * optional int32 tendency = 19; - */ - public boolean hasTendency() { - return ((bitField0_ & 0x00020000) == 0x00020000); - } - /** - * optional int32 tendency = 19; - */ - public int getTendency() { - return tendency_; - } - /** - * optional int32 tendency = 19; - */ - public Builder setTendency(int value) { - bitField0_ |= 0x00020000; - tendency_ = value; - onChanged(); - return this; - } - /** - * optional int32 tendency = 19; - */ - public Builder clearTendency() { - bitField0_ = (bitField0_ & ~0x00020000); - tendency_ = 0; - onChanged(); - return this; - } - private int charactericId_ ; /** * optional int32 characteric_id = 20; */ public boolean hasCharactericId() { - return ((bitField0_ & 0x00040000) == 0x00040000); + return ((bitField0_ & 0x00020000) == 0x00020000); } /** * optional int32 characteric_id = 20; @@ -7687,7 +7609,7 @@ public final class BatchReport { * optional int32 characteric_id = 20; */ public Builder setCharactericId(int value) { - bitField0_ |= 0x00040000; + bitField0_ |= 0x00020000; charactericId_ = value; onChanged(); return this; @@ -7696,7 +7618,7 @@ public final class BatchReport { * optional int32 characteric_id = 20; */ public Builder clearCharactericId() { - bitField0_ = (bitField0_ & ~0x00040000); + bitField0_ = (bitField0_ & ~0x00020000); charactericId_ = 0; onChanged(); return this; @@ -7707,7 +7629,7 @@ public final class BatchReport { * optional int32 person_id = 21; */ public boolean hasPersonId() { - return ((bitField0_ & 0x00080000) == 0x00080000); + return ((bitField0_ & 0x00040000) == 0x00040000); } /** * optional int32 person_id = 21; @@ -7719,7 +7641,7 @@ public final class BatchReport { * optional int32 person_id = 21; */ public Builder setPersonId(int value) { - bitField0_ |= 0x00080000; + bitField0_ |= 0x00040000; personId_ = value; onChanged(); return this; @@ -7728,7 +7650,7 @@ public final class BatchReport { * optional int32 person_id = 21; */ public Builder clearPersonId() { - bitField0_ = (bitField0_ & ~0x00080000); + bitField0_ = (bitField0_ & ~0x00040000); personId_ = 0; onChanged(); return this; @@ -25967,7 +25889,7 @@ public final class BatchReport { "\020\001\022\034\n\004link\030\n \003(\0132\016.ComponentLink\022\017\n\007vers" + "ion\030\014 \001(\t\022\013\n\003key\030\016 \001(\t\022\r\n\005lines\030\017 \001(\005\022\n\n" + "\002id\030\r \001(\003\022\023\n\013snapshot_id\030\010 \001(\003\022\014\n\004uuid\030\t" + - " \001(\t\022\025\n\005event\030\013 \003(\0132\006.Event\"\340\003\n\007Measure\022" + + " \001(\t\022\025\n\005event\030\013 \003(\0132\006.Event\"\316\003\n\007Measure\022" + "%\n\nvalue_type\030\001 \001(\0162\021.MeasureValueType\022\025" + "\n\rboolean_value\030\002 \001(\010\022\021\n\tint_value\030\003 \001(\005" + "\022\022\n\nlong_value\030\004 \001(\003\022\024\n\014double_value\030\005 \001", @@ -25978,62 +25900,61 @@ public final class BatchReport { "riation_value_1\030\016 \001(\001\022\031\n\021variation_value" + "_2\030\017 \001(\001\022\031\n\021variation_value_3\030\020 \001(\001\022\031\n\021v" + "ariation_value_4\030\021 \001(\001\022\031\n\021variation_valu" + - "e_5\030\022 \001(\001\022\020\n\010tendency\030\023 \001(\005\022\026\n\016character" + - "ic_id\030\024 \001(\005\022\021\n\tperson_id\030\025 \001(\005\"<\n\010Measur" + - "es\022\025\n\rcomponent_ref\030\001 \001(\005\022\031\n\007measure\030\002 \003", - "(\0132\010.Measure\"\231\004\n\005Issue\022\027\n\017rule_repositor" + - "y\030\001 \001(\t\022\020\n\010rule_key\030\002 \001(\t\022\014\n\004line\030\003 \001(\005\022" + - "\013\n\003msg\030\004 \001(\t\022\033\n\010severity\030\005 \001(\0162\t.Severit" + - "y\022\013\n\003tag\030\006 \003(\t\022\025\n\reffort_to_fix\030\007 \001(\001\022\016\n" + - "\006is_new\030\010 \001(\010\022\014\n\004uuid\030\t \001(\t\022\027\n\017debt_in_m" + - "inutes\030\n \001(\003\022\022\n\nresolution\030\013 \001(\t\022\016\n\006stat" + - "us\030\014 \001(\t\022\020\n\010checksum\030\r \001(\t\022\027\n\017manual_sev" + - "erity\030\016 \001(\010\022\020\n\010reporter\030\017 \001(\t\022\020\n\010assigne" + - "e\030\020 \001(\t\022\027\n\017action_plan_key\030\021 \001(\t\022\022\n\nattr" + - "ibutes\030\022 \001(\t\022\024\n\014author_login\030\023 \001(\t\022\025\n\rcr", - "eation_date\030\024 \001(\003\022\022\n\nclose_date\030\025 \001(\003\022\023\n" + - "\013update_date\030\026 \001(\003\022\023\n\013selected_at\030\027 \001(\003\022" + - "\023\n\013diff_fields\030\030 \001(\t\022\022\n\nis_changed\030\031 \001(\010" + - "\022\036\n\026must_send_notification\030\032 \001(\010\"N\n\006Issu" + - "es\022\025\n\rcomponent_ref\030\001 \001(\005\022\025\n\005issue\030\002 \003(\013" + - "2\006.Issue\022\026\n\016component_uuid\030\003 \001(\t\"\254\001\n\nCha" + - "ngesets\022\025\n\rcomponent_ref\030\001 \001(\005\022(\n\tchange" + - "set\030\002 \003(\0132\025.Changesets.Changeset\022 \n\024chan" + - "gesetIndexByLine\030\003 \003(\005B\002\020\001\032;\n\tChangeset\022" + - "\020\n\010revision\030\001 \001(\t\022\016\n\006author\030\002 \001(\t\022\014\n\004dat", - "e\030\003 \001(\003\"R\n\tDuplicate\022\026\n\016other_file_ref\030\001" + - " \001(\005\022\025\n\005range\030\002 \001(\0132\006.Range\022\026\n\016other_fil" + - "e_key\030\003 \001(\t\"M\n\013Duplication\022\037\n\017origin_pos" + - "ition\030\001 \001(\0132\006.Range\022\035\n\tduplicate\030\002 \003(\0132\n" + - ".Duplicate\"H\n\014Duplications\022\025\n\rcomponent_" + - "ref\030\001 \001(\005\022!\n\013duplication\030\002 \003(\0132\014.Duplica" + - "tion\"W\n\005Range\022\022\n\nstart_line\030\001 \001(\005\022\020\n\010end" + - "_line\030\002 \001(\005\022\024\n\014start_offset\030\003 \001(\005\022\022\n\nend" + - "_offset\030\004 \001(\005\"~\n\007Symbols\022\020\n\010file_ref\030\001 \001" + - "(\005\022\037\n\006symbol\030\002 \003(\0132\017.Symbols.Symbol\032@\n\006S", - "ymbol\022\033\n\013declaration\030\001 \001(\0132\006.Range\022\031\n\tre" + - "ference\030\002 \003(\0132\006.Range\"\260\001\n\010Coverage\022\014\n\004li" + - "ne\030\001 \001(\005\022\022\n\nconditions\030\002 \001(\005\022\017\n\007ut_hits\030" + - "\003 \001(\010\022\017\n\007it_hits\030\004 \001(\010\022\035\n\025ut_covered_con" + - "ditions\030\005 \001(\005\022\035\n\025it_covered_conditions\030\006" + - " \001(\005\022\"\n\032overall_covered_conditions\030\007 \001(\005" + - "\"L\n\022SyntaxHighlighting\022\025\n\005range\030\001 \001(\0132\006." + - "Range\022\037\n\004type\030\002 \001(\0162\021.HighlightingType\"\203" + - "\001\n\004Test\022\014\n\004name\030\001 \001(\t\022\027\n\004type\030\002 \001(\0162\t.Te" + - "stType\022\033\n\006status\030\003 \001(\0162\013.TestStatus\022\026\n\016d", - "uration_in_ms\030\004 \001(\003\022\022\n\nstacktrace\030\005 \001(\t\022" + - "\013\n\003msg\030\006 \001(\t\"\221\001\n\016CoverageDetail\022\021\n\ttest_" + - "name\030\001 \001(\t\0221\n\014covered_file\030\002 \003(\0132\033.Cover" + - "ageDetail.CoveredFile\0329\n\013CoveredFile\022\020\n\010" + - "file_ref\030\001 \001(\005\022\030\n\014covered_line\030\002 \003(\005B\002\020\001" + - "\"5\n\016FileDependency\022\023\n\013to_file_ref\030\001 \001(\005\022" + - "\016\n\006weight\030\002 \001(\005\"\275\001\n\022ModuleDependencies\0221" + - "\n\003dep\030\001 \003(\0132$.ModuleDependencies.ModuleD" + - "ependency\032t\n\020ModuleDependency\022\013\n\003key\030\001 \001" + - "(\t\022\017\n\007version\030\002 \001(\t\022\r\n\005scope\030\003 \001(\t\0223\n\005ch", - "ild\030\004 \003(\0132$.ModuleDependencies.ModuleDep" + - "endencyB#\n\037org.sonar.batch.protocol.outp" + - "utH\001" + "e_5\030\022 \001(\001\022\026\n\016characteric_id\030\024 \001(\005\022\021\n\tper" + + "son_id\030\025 \001(\005\"<\n\010Measures\022\025\n\rcomponent_re" + + "f\030\001 \001(\005\022\031\n\007measure\030\002 \003(\0132\010.Measure\"\231\004\n\005I", + "ssue\022\027\n\017rule_repository\030\001 \001(\t\022\020\n\010rule_ke" + + "y\030\002 \001(\t\022\014\n\004line\030\003 \001(\005\022\013\n\003msg\030\004 \001(\t\022\033\n\010se" + + "verity\030\005 \001(\0162\t.Severity\022\013\n\003tag\030\006 \003(\t\022\025\n\r" + + "effort_to_fix\030\007 \001(\001\022\016\n\006is_new\030\010 \001(\010\022\014\n\004u" + + "uid\030\t \001(\t\022\027\n\017debt_in_minutes\030\n \001(\003\022\022\n\nre" + + "solution\030\013 \001(\t\022\016\n\006status\030\014 \001(\t\022\020\n\010checks" + + "um\030\r \001(\t\022\027\n\017manual_severity\030\016 \001(\010\022\020\n\010rep" + + "orter\030\017 \001(\t\022\020\n\010assignee\030\020 \001(\t\022\027\n\017action_" + + "plan_key\030\021 \001(\t\022\022\n\nattributes\030\022 \001(\t\022\024\n\014au" + + "thor_login\030\023 \001(\t\022\025\n\rcreation_date\030\024 \001(\003\022", + "\022\n\nclose_date\030\025 \001(\003\022\023\n\013update_date\030\026 \001(\003" + + "\022\023\n\013selected_at\030\027 \001(\003\022\023\n\013diff_fields\030\030 \001" + + "(\t\022\022\n\nis_changed\030\031 \001(\010\022\036\n\026must_send_noti" + + "fication\030\032 \001(\010\"N\n\006Issues\022\025\n\rcomponent_re" + + "f\030\001 \001(\005\022\025\n\005issue\030\002 \003(\0132\006.Issue\022\026\n\016compon" + + "ent_uuid\030\003 \001(\t\"\254\001\n\nChangesets\022\025\n\rcompone" + + "nt_ref\030\001 \001(\005\022(\n\tchangeset\030\002 \003(\0132\025.Change" + + "sets.Changeset\022 \n\024changesetIndexByLine\030\003" + + " \003(\005B\002\020\001\032;\n\tChangeset\022\020\n\010revision\030\001 \001(\t\022" + + "\016\n\006author\030\002 \001(\t\022\014\n\004date\030\003 \001(\003\"R\n\tDuplica", + "te\022\026\n\016other_file_ref\030\001 \001(\005\022\025\n\005range\030\002 \001(" + + "\0132\006.Range\022\026\n\016other_file_key\030\003 \001(\t\"M\n\013Dup" + + "lication\022\037\n\017origin_position\030\001 \001(\0132\006.Rang" + + "e\022\035\n\tduplicate\030\002 \003(\0132\n.Duplicate\"H\n\014Dupl" + + "ications\022\025\n\rcomponent_ref\030\001 \001(\005\022!\n\013dupli" + + "cation\030\002 \003(\0132\014.Duplication\"W\n\005Range\022\022\n\ns" + + "tart_line\030\001 \001(\005\022\020\n\010end_line\030\002 \001(\005\022\024\n\014sta" + + "rt_offset\030\003 \001(\005\022\022\n\nend_offset\030\004 \001(\005\"~\n\007S" + + "ymbols\022\020\n\010file_ref\030\001 \001(\005\022\037\n\006symbol\030\002 \003(\013" + + "2\017.Symbols.Symbol\032@\n\006Symbol\022\033\n\013declarati", + "on\030\001 \001(\0132\006.Range\022\031\n\treference\030\002 \003(\0132\006.Ra" + + "nge\"\260\001\n\010Coverage\022\014\n\004line\030\001 \001(\005\022\022\n\ncondit" + + "ions\030\002 \001(\005\022\017\n\007ut_hits\030\003 \001(\010\022\017\n\007it_hits\030\004" + + " \001(\010\022\035\n\025ut_covered_conditions\030\005 \001(\005\022\035\n\025i" + + "t_covered_conditions\030\006 \001(\005\022\"\n\032overall_co" + + "vered_conditions\030\007 \001(\005\"L\n\022SyntaxHighligh" + + "ting\022\025\n\005range\030\001 \001(\0132\006.Range\022\037\n\004type\030\002 \001(" + + "\0162\021.HighlightingType\"\203\001\n\004Test\022\014\n\004name\030\001 " + + "\001(\t\022\027\n\004type\030\002 \001(\0162\t.TestType\022\033\n\006status\030\003" + + " \001(\0162\013.TestStatus\022\026\n\016duration_in_ms\030\004 \001(", + "\003\022\022\n\nstacktrace\030\005 \001(\t\022\013\n\003msg\030\006 \001(\t\"\221\001\n\016C" + + "overageDetail\022\021\n\ttest_name\030\001 \001(\t\0221\n\014cove" + + "red_file\030\002 \003(\0132\033.CoverageDetail.CoveredF" + + "ile\0329\n\013CoveredFile\022\020\n\010file_ref\030\001 \001(\005\022\030\n\014" + + "covered_line\030\002 \003(\005B\002\020\001\"5\n\016FileDependency" + + "\022\023\n\013to_file_ref\030\001 \001(\005\022\016\n\006weight\030\002 \001(\005\"\275\001" + + "\n\022ModuleDependencies\0221\n\003dep\030\001 \003(\0132$.Modu" + + "leDependencies.ModuleDependency\032t\n\020Modul" + + "eDependency\022\013\n\003key\030\001 \001(\t\022\017\n\007version\030\002 \001(" + + "\t\022\r\n\005scope\030\003 \001(\t\0223\n\005child\030\004 \003(\0132$.Module", + "Dependencies.ModuleDependencyB#\n\037org.son" + + "ar.batch.protocol.outputH\001" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { @@ -26077,7 +25998,7 @@ public final class BatchReport { internal_static_Measure_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_Measure_descriptor, - new java.lang.String[] { "ValueType", "BooleanValue", "IntValue", "LongValue", "DoubleValue", "StringValue", "MetricKey", "Description", "RuleKey", "Severity", "AlertStatus", "AlertText", "VariationValue1", "VariationValue2", "VariationValue3", "VariationValue4", "VariationValue5", "Tendency", "CharactericId", "PersonId", }); + new java.lang.String[] { "ValueType", "BooleanValue", "IntValue", "LongValue", "DoubleValue", "StringValue", "MetricKey", "Description", "RuleKey", "Severity", "AlertStatus", "AlertText", "VariationValue1", "VariationValue2", "VariationValue3", "VariationValue4", "VariationValue5", "CharactericId", "PersonId", }); internal_static_Measures_descriptor = getDescriptor().getMessageTypes().get(5); internal_static_Measures_fieldAccessorTable = new diff --git a/sonar-batch-protocol/src/main/protobuf/batch_report.proto b/sonar-batch-protocol/src/main/protobuf/batch_report.proto index 02af18c8520..9a955eb1323 100644 --- a/sonar-batch-protocol/src/main/protobuf/batch_report.proto +++ b/sonar-batch-protocol/src/main/protobuf/batch_report.proto @@ -108,9 +108,8 @@ message Measure { optional double variation_value_3 = 16; optional double variation_value_4 = 17; optional double variation_value_5 = 18; - optional int32 tendency = 19; - optional int32 characteric_id = 20; - optional int32 person_id = 21; + optional int32 characteric_id = 19; + optional int32 person_id = 20; } message Measures { diff --git a/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/DefaultTimeMachine.java b/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/DefaultTimeMachine.java index c077a060861..35a47982461 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/DefaultTimeMachine.java +++ b/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/DefaultTimeMachine.java @@ -59,7 +59,7 @@ public class DefaultTimeMachine implements TimeMachine { public List getMeasures(TimeMachineQuery query) { Map metricById = getMetricsById(query); - List objects = execute(query, true, metricById.keySet()); + List objects = execute(query, metricById.keySet()); List result = Lists.newArrayList(); for (Object[] object : objects) { @@ -75,15 +75,10 @@ public class DefaultTimeMachine implements TimeMachine { @Override public List getMeasuresFields(TimeMachineQuery query) { - Map metricById = getMetricsById(query); - List rows = execute(query, false, metricById.keySet()); - for (Object[] fields : rows) { - fields[1] = metricById.get(fields[1]); - } - return rows; + return Collections.emptyList(); } - protected List execute(TimeMachineQuery query, boolean selectAllFields, Set metricIds) { + protected List execute(TimeMachineQuery query, Set metricIds) { Resource resource = query.getResource(); if (resource != null && resource.getId() == null) { resource = index.getResource(query.getResource()); @@ -95,11 +90,7 @@ public class DefaultTimeMachine implements TimeMachine { StringBuilder sb = new StringBuilder(); Map params = Maps.newHashMap(); - if (selectAllFields) { - sb.append("SELECT m, s.createdAt "); - } else { - sb.append("SELECT s.createdAt, m.metricId, m.value "); - } + sb.append("SELECT m, s.createdAt "); sb.append(" FROM ") .append(MeasureModel.class.getSimpleName()) .append(" m, ") @@ -163,7 +154,6 @@ public class DefaultTimeMachine implements TimeMachine { measure.setData(model.getData(metric)); measure.setAlertStatus(model.getAlertStatus()); measure.setAlertText(model.getAlertText()); - measure.setTendency(model.getTendency()); measure.setVariation1(model.getVariationValue1()); measure.setVariation2(model.getVariationValue2()); measure.setVariation3(model.getVariationValue3()); diff --git a/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PeriodsDefinition.java b/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PeriodsDefinition.java index b235129693f..3cab5d098c8 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PeriodsDefinition.java +++ b/sonar-batch/src/main/java/org/sonar/batch/deprecated/components/PeriodsDefinition.java @@ -37,7 +37,6 @@ import static org.sonar.api.utils.DateUtils.dateToLong; public class PeriodsDefinition implements BatchComponent { - public static final int CORE_TENDENCY_DEPTH_DEFAULT_VALUE = 30; private static final int NUMBER_OF_VARIATION_SNAPSHOTS = 5; private DatabaseSession session; diff --git a/sonar-batch/src/main/java/org/sonar/batch/report/MeasuresPublisher.java b/sonar-batch/src/main/java/org/sonar/batch/report/MeasuresPublisher.java index 0613432376b..8c68e6b787f 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/report/MeasuresPublisher.java +++ b/sonar-batch/src/main/java/org/sonar/batch/report/MeasuresPublisher.java @@ -153,10 +153,6 @@ public class MeasuresPublisher implements ReportPublisherStep { if (variation5 != null) { builder.setVariationValue5(variation5); } - Integer tendency = measure.getTendency(); - if (tendency != null) { - builder.setTendency(tendency); - } Characteristic charac = measure.getCharacteristic(); if (charac != null) { builder.setCharactericId(charac.id()); diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/measure/MeasureValueCoder.java b/sonar-batch/src/main/java/org/sonar/batch/scan/measure/MeasureValueCoder.java index 8bb5a91081f..e7dae02780d 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/measure/MeasureValueCoder.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/measure/MeasureValueCoder.java @@ -51,7 +51,6 @@ class MeasureValueCoder implements ValueCoder { putUTFOrNull(value, m.getDescription()); value.putString(m.getAlertStatus() != null ? m.getAlertStatus().name() : null); putUTFOrNull(value, m.getAlertText()); - value.put(m.getTendency()); value.putDate(m.getDate()); value.put(m.getVariation1()); value.put(m.getVariation2()); @@ -91,7 +90,6 @@ class MeasureValueCoder implements ValueCoder { m.setDescription(value.getString()); m.setAlertStatus(value.isNull(true) ? null : Metric.Level.valueOf(value.getString())); m.setAlertText(value.getString()); - m.setTendency(value.isNull(true) ? null : value.getInt()); m.setDate(value.getDate()); m.setVariation1(value.isNull(true) ? null : value.getDouble()); m.setVariation2(value.isNull(true) ? null : value.getDouble()); diff --git a/sonar-batch/src/test/java/org/sonar/batch/report/MeasuresPublisherTest.java b/sonar-batch/src/test/java/org/sonar/batch/report/MeasuresPublisherTest.java index 3089a67cbee..74389bc0466 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/report/MeasuresPublisherTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/report/MeasuresPublisherTest.java @@ -86,7 +86,6 @@ public class MeasuresPublisherTest { .setValue(2.0) .setAlertStatus(Level.ERROR) .setAlertText("Foo") - .setTendency(-1) .setCharacteristic(mock(Characteristic.class)) .setPersonId(2); // No value on new_xxx diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/measure/MeasureCacheTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/measure/MeasureCacheTest.java index 7aa5c49856d..fce979b23c4 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/scan/measure/MeasureCacheTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/scan/measure/MeasureCacheTest.java @@ -296,7 +296,6 @@ public class MeasureCacheTest { when(r.id()).thenReturn(7); when(techDebtModel.requirementsById(7)).thenReturn(r); measure.setRequirement(r); - measure.setTendency(4); measure.setUrl("http://foo"); measure.setVariation1(11.0); measure.setVariation2(12.0); diff --git a/sonar-core/src/main/java/org/sonar/core/measure/db/MeasureDto.java b/sonar-core/src/main/java/org/sonar/core/measure/db/MeasureDto.java index e037b59ede7..990e8dfd512 100644 --- a/sonar-core/src/main/java/org/sonar/core/measure/db/MeasureDto.java +++ b/sonar-core/src/main/java/org/sonar/core/measure/db/MeasureDto.java @@ -36,7 +36,6 @@ public class MeasureDto { private Double value; private String textValue; private byte[] dataValue; - private Integer tendency; private Double variation1, variation2, variation3, variation4, variation5; private String alertStatus; private String alertText; @@ -137,16 +136,6 @@ public class MeasureDto { return this; } - @CheckForNull - public Integer getTendency() { - return tendency; - } - - public MeasureDto setTendency(@Nullable Integer tendency) { - this.tendency = tendency; - return this; - } - @CheckForNull public String getAlertStatus() { return alertStatus; diff --git a/sonar-core/src/main/resources/org/sonar/core/measure/db/MeasureMapper.xml b/sonar-core/src/main/resources/org/sonar/core/measure/db/MeasureMapper.xml index 8b9500661cc..4a65b908e35 100644 --- a/sonar-core/src/main/resources/org/sonar/core/measure/db/MeasureMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/measure/db/MeasureMapper.xml @@ -70,12 +70,12 @@ INSERT INTO project_measures ( - value, metric_id, snapshot_id, rule_id, text_value, tendency, project_id, alert_status, alert_text, description, + value, metric_id, snapshot_id, rule_id, text_value, project_id, alert_status, alert_text, description, rule_priority, characteristic_id, person_id, variation_value_1, variation_value_2, variation_value_3, variation_value_4, variation_value_5, measure_data) VALUES ( #{value, jdbcType=DOUBLE}, #{metricId, jdbcType=INTEGER}, #{snapshotId, jdbcType=INTEGER}, - #{ruleId, jdbcType=INTEGER}, #{textValue, jdbcType=VARCHAR}, #{tendency, jdbcType=INTEGER}, + #{ruleId, jdbcType=INTEGER}, #{textValue, jdbcType=VARCHAR}, #{projectId, jdbcType=INTEGER}, #{alertStatus, jdbcType=VARCHAR}, #{alertText, jdbcType=VARCHAR}, #{description, jdbcType=VARCHAR}, #{severityIndex, jdbcType=INTEGER}, #{characteristicId, jdbcType=INTEGER}, #{personId, jdbcType=INTEGER}, #{variation1, jdbcType=DOUBLE}, #{variation2, jdbcType=DOUBLE}, #{variation3, jdbcType=DOUBLE}, diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/DecoratorBarriers.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/DecoratorBarriers.java index 6289dd9cb2d..710de16c3c5 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/DecoratorBarriers.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/DecoratorBarriers.java @@ -110,7 +110,7 @@ public interface DecoratorBarriers { /** * Any kinds of time machine data are calculated before this barrier. Decorators executed after this barrier can use - * Measure#getVariationValue() and Measure#getTendency() methods. + * Measure#getVariationValue() method. * * @since 2.5 */ diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/TimeMachine.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/TimeMachine.java index eb6341b5135..81ffb504294 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/TimeMachine.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/TimeMachine.java @@ -42,10 +42,7 @@ public interface TimeMachine extends BatchComponent { List getMeasures(TimeMachineQuery query); /** - * Past measures sorted by date. Return only a subset of basic fields : [date (java.util.Date), metric (org.sonar.api.measures.Metric), value (Double)]. - *

- *

Measures of current analysis are not included.

- *

This method is recommended instead of getMeasures() for performance reasons. It needs less memory.

+ * Return an empty list since 5.2. See https://jira.codehaus.org/browse/SONAR-6392 */ List getMeasuresFields(TimeMachineQuery query); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/database/model/MeasureModel.java b/sonar-plugin-api/src/main/java/org/sonar/api/database/model/MeasureModel.java index fdf32504847..7725d50ce49 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/database/model/MeasureModel.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/database/model/MeasureModel.java @@ -27,6 +27,7 @@ import org.sonar.api.database.DatabaseSession; import org.sonar.api.measures.Metric; import org.sonar.api.rules.RulePriority; +import javax.annotation.CheckForNull; import javax.persistence.*; import java.io.UnsupportedEncodingException; @@ -51,9 +52,6 @@ public class MeasureModel implements Cloneable { @Column(name = "text_value", updatable = true, nullable = true, length = TEXT_VALUE_LENGTH) private String textValue; - @Column(name = "tendency", updatable = true, nullable = true) - private Integer tendency; - @Column(name = "metric_id", updatable = false, nullable = false) private Integer metricId; @@ -208,19 +206,20 @@ public class MeasureModel implements Cloneable { } /** - * @return the measure tendency + * Concept of measure trend is dropped. This method always returns {@code null} since version 5.2. + * @deprecated since 5.2. See https://jira.codehaus.org/browse/SONAR-6392 + * @return null */ + @CheckForNull public Integer getTendency() { - return tendency; + return null; } /** - * Sets the measure tendency - * - * @return the current object + * Concept of measure trend is dropped. This method does nothing. + * @deprecated since 5.2. See https://jira.codehaus.org/browse/SONAR-6392 */ public MeasureModel setTendency(Integer tendency) { - this.tendency = tendency; return this; } @@ -468,7 +467,6 @@ public class MeasureModel implements Cloneable { clone.setTextValue(getTextValue()); clone.setAlertStatus(getAlertStatus()); clone.setAlertText(getAlertText()); - clone.setTendency(getTendency()); clone.setVariationValue1(getVariationValue1()); clone.setVariationValue2(getVariationValue2()); clone.setVariationValue3(getVariationValue3()); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java index 0cd77c10ddf..260efe3be55 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java @@ -55,7 +55,6 @@ public class Measure implements Serializable { protected String description; protected Metric.Level alertStatus; protected String alertText; - protected Integer tendency; protected Date date; protected Double variation1, variation2, variation3, variation4, variation5; protected String url; @@ -438,22 +437,22 @@ public class Measure implements Serializable { } /** - * Gets the measure tendency - * - * @return the tendency + * Concept of measure trend is dropped. + * @deprecated since 5.2. See https://jira.codehaus.org/browse/SONAR-6392 + * @return {@code null} since version 5.2 */ + @Deprecated + @CheckForNull public Integer getTendency() { - return tendency; + return null; } /** - * Sets the tendency for the measure - Internal use only - * - * @param tendency the tendency + * Concept of measure trend is dropped. This method does nothing. + * @deprecated since 5.2. See https://jira.codehaus.org/browse/SONAR-6392 * @return the measure object instance */ public Measure setTendency(@Nullable Integer tendency) { - this.tendency = tendency; return this; } @@ -684,7 +683,7 @@ public class Measure implements Serializable { return metric.isOptimizedBestValue() == Boolean.TRUE && bestValue != null && (value == null || NumberUtils.compare(bestValue, value) == 0) - && allNull(alertStatus, description, tendency, url, data) + && allNull(alertStatus, description, url, data) && isZeroVariation(variation1, variation2, variation3, variation4, variation5); } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/RuleMeasure.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/RuleMeasure.java index 6c507bcb34f..ca201e7ca06 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/RuleMeasure.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/RuleMeasure.java @@ -161,7 +161,6 @@ public class RuleMeasure extends Measure { .append("description", description) .append("alertStatus", alertStatus) .append("alertText", alertText) - .append("tendency", tendency) .append("severity", rulePriority) .toString(); }