diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2017-04-20 14:17:31 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2017-04-21 16:01:31 +0200 |
commit | 59f8f04d54439ab861bafb88864adc7789e99d23 (patch) | |
tree | b0df77bc3043591663a2975d4a571bf1e361ea3e | |
parent | 4444bcd48f8cd7319d0b9821baeb5bdc98c7276e (diff) | |
download | sonarqube-59f8f04d54439ab861bafb88864adc7789e99d23.tar.gz sonarqube-59f8f04d54439ab861bafb88864adc7789e99d23.zip |
SONAR-9143 Stop documenting 'previous_analysis' as a valid option for the leak period
3 files changed, 25 insertions, 9 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/PeriodResolver.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/PeriodResolver.java index fdf22d9efd2..3ea2fe10647 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/PeriodResolver.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/PeriodResolver.java @@ -70,6 +70,10 @@ public class PeriodResolver { if (StringUtils.isBlank(propertyValue)) { return null; } + if (propertyValue.equals(LEAK_PERIOD_MODE_PREVIOUS_ANALYSIS)) { + LOG.warn("Leak period is set to deprecated value '{}'. This value will be removed in next SonarQube LTS, please use another one instead.", + LEAK_PERIOD_MODE_PREVIOUS_ANALYSIS); + } Period period = resolve(propertyValue); if (period == null && StringUtils.isNotBlank(propertyValue)) { LOG.debug("Property " + LEAK_PERIOD + " is not valid: " + propertyValue); diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/LoadPeriodsStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/LoadPeriodsStepTest.java index 8ed21323d58..b3fc362bbb3 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/LoadPeriodsStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/LoadPeriodsStepTest.java @@ -31,6 +31,7 @@ import org.sonar.api.config.MapSettings; import org.sonar.api.config.Settings; import org.sonar.api.utils.System2; import org.sonar.api.utils.log.LogTester; +import org.sonar.api.utils.log.LoggerLevel; import org.sonar.db.DbClient; import org.sonar.db.DbTester; import org.sonar.server.computation.task.projectanalysis.analysis.AnalysisMetadataHolderRule; @@ -268,8 +269,8 @@ public class LoadPeriodsStepTest extends BaseStepTest { assertThat(period.getSnapshotDate()).isEqualTo(1227934800000L); assertThat(period.getAnalysisUuid()).isEqualTo("u1004"); - assertThat(logTester.logs()).hasSize(1); - assertThat(logTester.logs().get(0)).startsWith("Compare to previous analysis ("); + assertThat(logTester.logs(LoggerLevel.DEBUG)).hasSize(1); + assertThat(logTester.logs(LoggerLevel.DEBUG).get(0)).startsWith("Compare to previous analysis ("); } @Test @@ -285,6 +286,17 @@ public class LoadPeriodsStepTest extends BaseStepTest { } @Test + public void display_warning_log_when_using_previous_analysis() { + setupRoot(PROJECT_ROOT); + dbTester.prepareDbUnit(getClass(), "shared.xml"); + settings.setProperty("sonar.leak.period", "previous_analysis"); + + underTest.execute(); + + assertThat(logTester.logs(LoggerLevel.WARN)).containsOnly("Leak period is set to deprecated value 'previous_analysis'. This value will be removed in next SonarQube LTS, please use another one instead."); + } + + @Test public void feed_period_by_previous_version() { setupRoot(PROJECT_ROOT); dbTester.prepareDbUnit(getClass(), "shared.xml"); @@ -300,8 +312,8 @@ public class LoadPeriodsStepTest extends BaseStepTest { assertThat(period.getSnapshotDate()).isEqualTo(1226494680000L); assertThat(period.getAnalysisUuid()).isEqualTo("u1001"); - assertThat(logTester.logs()).hasSize(1); - assertThat(logTester.logs().get(0)).startsWith("Compare to previous version ("); + assertThat(logTester.logs(LoggerLevel.DEBUG)).hasSize(1); + assertThat(logTester.logs(LoggerLevel.DEBUG).get(0)).startsWith("Compare to previous version ("); } @Test diff --git a/sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java b/sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java index aa07d4ef842..9578500f944 100644 --- a/sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java +++ b/sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java @@ -204,12 +204,12 @@ public class CorePropertyDefinitions { PropertyDefinition.builder(LEAK_PERIOD) .name("Leak Period") .deprecatedKey("sonar.timemachine.period1") - .description("Period used to compare measures and track new issues. Values are : <ul class='bullet'><li>Number of days before " + - "analysis, for example 5.</li><li>A custom date. Format is yyyy-MM-dd, for example 2010-12-25</li><li>'previous_analysis' to " + - "compare to previous analysis</li><li>'previous_version' to compare to the previous version in the project history</li>" + + .description("Period used to compare measures and track new issues. Values are : " + + "<ul class='bullet'><li>Number of days before analysis, for example 5.</li>" + + "<li>A custom date. Format is yyyy-MM-dd, for example 2010-12-25</li>" + + "<li>'previous_version' to compare to the previous version in the project history</li>" + "<li>A version, for example '1.2' or 'BASELINE'</li></ul>" + - "<p>When specifying a number of days or a date, the snapshot selected for comparison is " + - " the first one available inside the corresponding time range. </p>" + + "<p>When specifying a number of days or a date, the snapshot selected for comparison is the first one available inside the corresponding time range. </p>" + "<p>Changing this property only takes effect after subsequent project inspections.<p/>") .defaultValue(DEFAULT_LEAK_PERIOD) .category(CoreProperties.CATEGORY_GENERAL) |