@@ -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); |
@@ -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 | |||
@@ -284,6 +285,17 @@ public class LoadPeriodsStepTest extends BaseStepTest { | |||
assertThat(periodsHolder.getPeriod()).isNull(); | |||
} | |||
@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); | |||
@@ -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 |
@@ -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) |