aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistMeasuresStep.java20
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistMeasuresStepTest.java33
-rw-r--r--server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java2
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeConfiguration.java8
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeConfigurationTest.java16
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/setting/ws/ValuesAction.java2
-rw-r--r--sonar-core/src/main/java/org/sonar/core/config/PurgeConstants.java1
-rw-r--r--sonar-core/src/main/java/org/sonar/core/config/PurgeProperties.java11
-rw-r--r--sonar-core/src/test/java/org/sonar/core/config/CorePropertyDefinitionsTest.java2
-rw-r--r--sonar-core/src/test/java/org/sonar/core/config/PurgePropertiesTest.java2
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/settings/ValuesRequest.java2
11 files changed, 18 insertions, 81 deletions
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistMeasuresStep.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistMeasuresStep.java
index 222aa7a35f9..1fd6f718120 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistMeasuresStep.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistMeasuresStep.java
@@ -19,14 +19,12 @@
*/
package org.sonar.ce.task.projectanalysis.step;
-import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Multimap;
import java.util.Collection;
import java.util.Map;
import java.util.function.Predicate;
import javax.annotation.Nonnull;
import org.sonar.ce.task.projectanalysis.component.Component;
-import org.sonar.ce.task.projectanalysis.component.ConfigurationRepository;
import org.sonar.ce.task.projectanalysis.component.CrawlerDepthLimit;
import org.sonar.ce.task.projectanalysis.component.DepthTraversalTypeAwareCrawler;
import org.sonar.ce.task.projectanalysis.component.TreeRootHolder;
@@ -37,7 +35,6 @@ import org.sonar.ce.task.projectanalysis.measure.MeasureToMeasureDto;
import org.sonar.ce.task.projectanalysis.metric.Metric;
import org.sonar.ce.task.projectanalysis.metric.MetricRepository;
import org.sonar.ce.task.step.ComputationStep;
-import org.sonar.core.config.PurgeConstants;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.measure.MeasureDao;
@@ -52,23 +49,14 @@ public class PersistMeasuresStep implements ComputationStep {
private final MeasureToMeasureDto measureToMeasureDto;
private final TreeRootHolder treeRootHolder;
private final MeasureRepository measureRepository;
- private final boolean persistDirectories;
- public PersistMeasuresStep(DbClient dbClient, MetricRepository metricRepository, MeasureToMeasureDto measureToMeasureDto,
- TreeRootHolder treeRootHolder, MeasureRepository measureRepository, ConfigurationRepository settings) {
- this(dbClient, metricRepository, measureToMeasureDto, treeRootHolder, measureRepository,
- !settings.getConfiguration().getBoolean(PurgeConstants.PROPERTY_CLEAN_DIRECTORY).orElseThrow(() -> new IllegalStateException("Missing default value")));
- }
-
- @VisibleForTesting
- PersistMeasuresStep(DbClient dbClient, MetricRepository metricRepository, MeasureToMeasureDto measureToMeasureDto, TreeRootHolder treeRootHolder,
- MeasureRepository measureRepository, boolean persistDirectories) {
+ public PersistMeasuresStep(DbClient dbClient, MetricRepository metricRepository, MeasureToMeasureDto measureToMeasureDto, TreeRootHolder treeRootHolder,
+ MeasureRepository measureRepository) {
this.dbClient = dbClient;
this.metricRepository = metricRepository;
this.measureToMeasureDto = measureToMeasureDto;
this.treeRootHolder = treeRootHolder;
this.measureRepository = measureRepository;
- this.persistDirectories = persistDirectories;
}
@Override
@@ -102,9 +90,7 @@ public class PersistMeasuresStep implements ComputationStep {
@Override
public void visitDirectory(Component directory) {
- if (persistDirectories) {
- persistMeasures(directory);
- }
+ // measures of directories are never read. No need to persist them.
}
@Override
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistMeasuresStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistMeasuresStepTest.java
index 06d708ed31a..9154eefb15d 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistMeasuresStepTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistMeasuresStepTest.java
@@ -85,25 +85,6 @@ public class PersistMeasuresStepTest extends BaseStepTest {
}
@Test
- public void persist_measures_of_project_analysis() {
- prepareProject();
-
- // the computed measures
- measureRepository.addRawMeasure(REF_1, STRING_METRIC.getKey(), newMeasureBuilder().create("project-value"));
- measureRepository.addRawMeasure(REF_3, STRING_METRIC.getKey(), newMeasureBuilder().create("dir-value"));
- measureRepository.addRawMeasure(REF_4, STRING_METRIC.getKey(), newMeasureBuilder().create("file-value"));
-
- TestComputationStepContext context = execute(true);
-
- // project and dir measures are persisted, but not file measures
- assertThat(db.countRowsOfTable("project_measures")).isEqualTo(2);
- assertThat(selectMeasure("project-uuid", STRING_METRIC).get().getData()).isEqualTo("project-value");
- assertThat(selectMeasure("dir-uuid", STRING_METRIC).get().getData()).isEqualTo("dir-value");
- assertThatMeasuresAreNotPersisted("file-uuid");
- assertNbOfInserts(context, 2);
- }
-
- @Test
public void persist_measures_of_project_analysis_excluding_directories() {
prepareProject();
@@ -112,7 +93,7 @@ public class PersistMeasuresStepTest extends BaseStepTest {
measureRepository.addRawMeasure(REF_3, STRING_METRIC.getKey(), newMeasureBuilder().create("dir-value"));
measureRepository.addRawMeasure(REF_4, STRING_METRIC.getKey(), newMeasureBuilder().create("file-value"));
- TestComputationStepContext context = execute(false);
+ TestComputationStepContext context = execute();
// project and dir measures are persisted, but not file measures
assertThat(db.countRowsOfTable("project_measures")).isEqualTo(1);
@@ -128,7 +109,7 @@ public class PersistMeasuresStepTest extends BaseStepTest {
measureRepository.addRawMeasure(REF_1, STRING_METRIC.getKey(), newMeasureBuilder().createNoValue());
measureRepository.addRawMeasure(REF_1, INT_METRIC.getKey(), newMeasureBuilder().createNoValue());
- TestComputationStepContext context = execute(false);
+ TestComputationStepContext context = execute();
assertThatMeasureIsNotPersisted("project-uuid", STRING_METRIC);
assertThatMeasureIsNotPersisted("project-uuid", INT_METRIC);
@@ -140,7 +121,7 @@ public class PersistMeasuresStepTest extends BaseStepTest {
prepareProject();
measureRepository.addRawMeasure(REF_1, INT_METRIC.getKey(), newMeasureBuilder().setVariation(42.0).createNoValue());
- TestComputationStepContext context = execute(false);
+ TestComputationStepContext context = execute();
MeasureDto persistedMeasure = selectMeasure("project-uuid", INT_METRIC).get();
assertThat(persistedMeasure.getValue()).isNull();
@@ -157,7 +138,7 @@ public class PersistMeasuresStepTest extends BaseStepTest {
measureRepository.addRawMeasure(REF_2, STRING_METRIC.getKey(), newMeasureBuilder().create("subview-value"));
measureRepository.addRawMeasure(REF_3, STRING_METRIC.getKey(), newMeasureBuilder().create("project-value"));
- TestComputationStepContext context = execute(true);
+ TestComputationStepContext context = execute();
assertThat(db.countRowsOfTable("project_measures")).isEqualTo(2);
assertThat(selectMeasure("view-uuid", STRING_METRIC).get().getData()).isEqualTo("view-value");
@@ -212,9 +193,9 @@ public class PersistMeasuresStepTest extends BaseStepTest {
assertThatMeasureIsNotPersisted(componentUuid, INT_METRIC);
}
- private TestComputationStepContext execute(boolean persistDirectories) {
+ private TestComputationStepContext execute() {
TestComputationStepContext context = new TestComputationStepContext();
- new PersistMeasuresStep(dbClient, metricRepository, new MeasureToMeasureDto(analysisMetadataHolder, treeRootHolder), treeRootHolder, measureRepository, persistDirectories)
+ new PersistMeasuresStep(dbClient, metricRepository, new MeasureToMeasureDto(analysisMetadataHolder, treeRootHolder), treeRootHolder, measureRepository)
.execute(context);
return context;
}
@@ -241,6 +222,6 @@ public class PersistMeasuresStepTest extends BaseStepTest {
@Override
protected ComputationStep step() {
- return new PersistMeasuresStep(dbClient, metricRepository, new MeasureToMeasureDto(analysisMetadataHolder, treeRootHolder), treeRootHolder, measureRepository, true);
+ return new PersistMeasuresStep(dbClient, metricRepository, new MeasureToMeasureDto(analysisMetadataHolder, treeRootHolder), treeRootHolder, measureRepository);
}
}
diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java
index 4ad9c4d8cf7..e78a2b93cea 100644
--- a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java
+++ b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java
@@ -123,7 +123,7 @@ public class ComputeEngineContainerImplTest {
+ 26 // level 1
+ 60 // content of DaoModule
+ 3 // content of EsModule
- + 55 // content of CorePropertyDefinitions
+ + 54 // content of CorePropertyDefinitions
+ 1 // StopFlagContainer
);
assertThat(
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeConfiguration.java b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeConfiguration.java
index 0babdc1246a..c7e46b549c6 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeConfiguration.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeConfiguration.java
@@ -31,8 +31,6 @@ import org.sonar.api.utils.DateUtils;
import org.sonar.api.utils.System2;
import org.sonar.core.config.PurgeConstants;
-import static java.util.Collections.singletonList;
-
public class PurgeConfiguration {
private final IdUuidPair rootProjectIdUuid;
@@ -53,11 +51,7 @@ public class PurgeConfiguration {
}
public static PurgeConfiguration newDefaultPurgeConfiguration(Configuration config, IdUuidPair rootId, Collection<String> disabledComponentUuids) {
- Collection<String> scopes = singletonList(Scopes.FILE);
- if (config.getBoolean(PurgeConstants.PROPERTY_CLEAN_DIRECTORY).orElse(false)) {
- scopes = Arrays.asList(Scopes.DIRECTORY, Scopes.FILE);
- }
- return new PurgeConfiguration(rootId, scopes, config.getInt(PurgeConstants.DAYS_BEFORE_DELETING_CLOSED_ISSUES).get(),
+ return new PurgeConfiguration(rootId, Arrays.asList(Scopes.DIRECTORY, Scopes.FILE), config.getInt(PurgeConstants.DAYS_BEFORE_DELETING_CLOSED_ISSUES).get(),
config.getInt(PurgeConstants.DAYS_BEFORE_DELETING_INACTIVE_SHORT_LIVING_BRANCHES), System2.INSTANCE, disabledComponentUuids);
}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeConfigurationTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeConfigurationTest.java
index fdb0733ed28..914ad8d5cd8 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeConfigurationTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeConfigurationTest.java
@@ -70,27 +70,15 @@ public class PurgeConfigurationTest {
}
@Test
- public void delete_files_but_not_directories_by_default() {
+ public void delete_files_and_directories() {
MapSettings settings = new MapSettings(new PropertyDefinitions(PurgeProperties.all()));
- settings.setProperty(PurgeConstants.PROPERTY_CLEAN_DIRECTORY, false);
settings.setProperty(PurgeConstants.DAYS_BEFORE_DELETING_CLOSED_ISSUES, 5);
Date now = new Date();
PurgeConfiguration underTest = PurgeConfiguration.newDefaultPurgeConfiguration(settings.asConfig(), new IdUuidPair(42L, "any-uuid"), emptyList());
assertThat(underTest.getScopesWithoutHistoricalData())
- .containsExactlyInAnyOrder(Scopes.FILE);
- assertThat(underTest.maxLiveDateOfClosedIssues(now)).isEqualTo(DateUtils.addDays(now, -5));
- }
-
- @Test
- public void delete_directory_if_enabled_in_settings() {
- MapSettings settings = new MapSettings(new PropertyDefinitions(PurgeProperties.all()));
- settings.setProperty(PurgeConstants.PROPERTY_CLEAN_DIRECTORY, true);
-
- PurgeConfiguration underTest = PurgeConfiguration.newDefaultPurgeConfiguration(settings.asConfig(), new IdUuidPair(42L, "any-uuid"), emptyList());
-
- assertThat(underTest.getScopesWithoutHistoricalData())
.containsExactlyInAnyOrder(Scopes.DIRECTORY, Scopes.FILE);
+ assertThat(underTest.maxLiveDateOfClosedIssues(now)).isEqualTo(DateUtils.addDays(now, -5));
}
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/setting/ws/ValuesAction.java b/server/sonar-server/src/main/java/org/sonar/server/setting/ws/ValuesAction.java
index c3b0b47cf51..1e7806aac34 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/setting/ws/ValuesAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/setting/ws/ValuesAction.java
@@ -118,7 +118,7 @@ public class ValuesAction implements SettingsWsAction {
.setHandler(this);
action.createParam(PARAM_KEYS)
.setDescription("List of setting keys")
- .setExampleValue("sonar.test.inclusions,sonar.dbcleaner.cleanDirectory");
+ .setExampleValue("sonar.test.inclusions,sonar.exclusions");
action.createParam(PARAM_COMPONENT)
.setDescription("Component key")
.setExampleValue(KEY_PROJECT_EXAMPLE_001);
diff --git a/sonar-core/src/main/java/org/sonar/core/config/PurgeConstants.java b/sonar-core/src/main/java/org/sonar/core/config/PurgeConstants.java
index 28d1e54b785..7e83f4deb69 100644
--- a/sonar-core/src/main/java/org/sonar/core/config/PurgeConstants.java
+++ b/sonar-core/src/main/java/org/sonar/core/config/PurgeConstants.java
@@ -21,7 +21,6 @@ package org.sonar.core.config;
public interface PurgeConstants {
- String PROPERTY_CLEAN_DIRECTORY = "sonar.dbcleaner.cleanDirectory";
String HOURS_BEFORE_KEEPING_ONLY_ONE_SNAPSHOT_BY_DAY = "sonar.dbcleaner.hoursBeforeKeepingOnlyOneSnapshotByDay";
String WEEKS_BEFORE_KEEPING_ONLY_ONE_SNAPSHOT_BY_WEEK = "sonar.dbcleaner.weeksBeforeKeepingOnlyOneSnapshotByWeek";
String WEEKS_BEFORE_KEEPING_ONLY_ONE_SNAPSHOT_BY_MONTH = "sonar.dbcleaner.weeksBeforeKeepingOnlyOneSnapshotByMonth";
diff --git a/sonar-core/src/main/java/org/sonar/core/config/PurgeProperties.java b/sonar-core/src/main/java/org/sonar/core/config/PurgeProperties.java
index 9d1fcdbf01b..0c6637e5014 100644
--- a/sonar-core/src/main/java/org/sonar/core/config/PurgeProperties.java
+++ b/sonar-core/src/main/java/org/sonar/core/config/PurgeProperties.java
@@ -102,17 +102,6 @@ public final class PurgeProperties {
.category(CoreProperties.CATEGORY_GENERAL)
.subCategory(CoreProperties.SUBCATEGORY_DATABASE_CLEANER)
.index(6)
- .build(),
-
- PropertyDefinition.builder(PurgeConstants.PROPERTY_CLEAN_DIRECTORY)
- .defaultValue("true")
- .name("Clean directory/package history")
- .description("If set to true, no history is kept at directory/package level. Setting this to false can cause database bloat.")
- .type(PropertyType.BOOLEAN)
- .onQualifiers(Qualifiers.PROJECT)
- .category(CoreProperties.CATEGORY_GENERAL)
- .subCategory(CoreProperties.SUBCATEGORY_DATABASE_CLEANER)
- .index(7)
.build()
);
}
diff --git a/sonar-core/src/test/java/org/sonar/core/config/CorePropertyDefinitionsTest.java b/sonar-core/src/test/java/org/sonar/core/config/CorePropertyDefinitionsTest.java
index a6c90b4b9f6..54c4a7aac16 100644
--- a/sonar-core/src/test/java/org/sonar/core/config/CorePropertyDefinitionsTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/config/CorePropertyDefinitionsTest.java
@@ -30,7 +30,7 @@ public class CorePropertyDefinitionsTest {
@Test
public void all() {
List<PropertyDefinition> defs = CorePropertyDefinitions.all();
- assertThat(defs).hasSize(55);
+ assertThat(defs).hasSize(54);
}
@Test
diff --git a/sonar-core/src/test/java/org/sonar/core/config/PurgePropertiesTest.java b/sonar-core/src/test/java/org/sonar/core/config/PurgePropertiesTest.java
index af1e320526b..bf121dd8964 100644
--- a/sonar-core/src/test/java/org/sonar/core/config/PurgePropertiesTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/config/PurgePropertiesTest.java
@@ -27,6 +27,6 @@ public class PurgePropertiesTest {
@Test
public void shouldGetExtensions() {
- assertThat(PurgeProperties.all()).hasSize(7);
+ assertThat(PurgeProperties.all()).hasSize(6);
}
}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/settings/ValuesRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/settings/ValuesRequest.java
index f32f92c7c46..ba19b01bc12 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/settings/ValuesRequest.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/settings/ValuesRequest.java
@@ -62,7 +62,7 @@ public class ValuesRequest {
}
/**
- * Example value: "sonar.test.inclusions,sonar.dbcleaner.cleanDirectory"
+ * Example value: "sonar.test.inclusions,sonar.cpd.cross_project"
*/
public ValuesRequest setKeys(List<String> keys) {
this.keys = keys;