From 7af0b945e6772b8e10ee8c7548b78ee12ea88712 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Tue, 9 Jan 2018 11:02:45 +0100 Subject: [PATCH] Drop deprecated class PersistenceMode --- .../api/measures/CoverageMeasuresBuilder.java | 8 ++-- .../java/org/sonar/api/measures/Measure.java | 31 ------------- .../sonar/api/measures/PersistenceMode.java | 44 ------------------- .../org/sonar/api/measures/MeasureTest.java | 12 ----- .../api/measures/PersistenceModeTest.java | 41 ----------------- 5 files changed, 3 insertions(+), 133 deletions(-) delete mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/measures/PersistenceMode.java delete mode 100644 sonar-plugin-api/src/test/java/org/sonar/api/measures/PersistenceModeTest.java diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoverageMeasuresBuilder.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoverageMeasuresBuilder.java index 4866a8c5594..61012817b82 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoverageMeasuresBuilder.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoverageMeasuresBuilder.java @@ -118,7 +118,7 @@ public final class CoverageMeasuresBuilder { if (getLinesToCover() > 0) { measures.add(new Measure(CoreMetrics.LINES_TO_COVER, (double) getLinesToCover())); measures.add(new Measure(CoreMetrics.UNCOVERED_LINES, (double) (getLinesToCover() - getCoveredLines()))); - measures.add(new Measure(CoreMetrics.COVERAGE_LINE_HITS_DATA).setData(KeyValueFormat.format(hitsByLine)).setPersistenceMode(PersistenceMode.DATABASE)); + measures.add(new Measure(CoreMetrics.COVERAGE_LINE_HITS_DATA).setData(KeyValueFormat.format(hitsByLine))); } if (getConditions() > 0) { measures.add(new Measure(CoreMetrics.CONDITIONS_TO_COVER, (double) getConditions())); @@ -131,14 +131,12 @@ public final class CoverageMeasuresBuilder { private Measure createCoveredConditionsByLine() { return new Measure(CoreMetrics.COVERED_CONDITIONS_BY_LINE) - .setData(KeyValueFormat.format(coveredConditionsByLine)) - .setPersistenceMode(PersistenceMode.DATABASE); + .setData(KeyValueFormat.format(coveredConditionsByLine)); } private Measure createConditionsByLine() { return new Measure(CoreMetrics.CONDITIONS_BY_LINE) - .setData(KeyValueFormat.format(conditionsByLine)) - .setPersistenceMode(PersistenceMode.DATABASE); + .setData(KeyValueFormat.format(conditionsByLine)); } public static CoverageMeasuresBuilder create() { 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 5829848f1c6..8523785a074 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 @@ -60,7 +60,6 @@ public class Measure implements Serializable { protected Double variation4; protected Double variation5; protected String url; - protected PersistenceMode persistenceMode = PersistenceMode.FULL; public Measure(String metricKey) { this.metricKey = metricKey; @@ -147,36 +146,6 @@ public class Measure implements Serializable { public Measure() { } - /** - * Gets the persistence mode of the measure. Default persistence mode is FULL, except when instantiating the measure with a String - * parameter. - */ - public PersistenceMode getPersistenceMode() { - return persistenceMode; - } - - /** - *

- * Sets the persistence mode of a measure. - * - *

- * WARNING : Being able to reuse measures saved in memory is only possible within the same tree. In a multi-module project for - * example, a measure save in memory at the module level will not be accessible by the root project. In that case, database should be - * used. - * - * - * @param mode the mode - * @return the measure object instance - */ - public Measure setPersistenceMode(@Nullable PersistenceMode mode) { - if (mode == null) { - this.persistenceMode = PersistenceMode.FULL; - } else { - this.persistenceMode = mode; - } - return this; - } - /** * @return return the measures underlying metric */ diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/PersistenceMode.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/PersistenceMode.java deleted file mode 100644 index ea5bebd50e7..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/PersistenceMode.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.api.measures; - -/** - * Mode of persistence for resources and measures. Usage : - *

    - *
  • MEMORY : temporary data used only in batch for calculations.
  • - *
  • DATABASE : measures with big data (several kB), like details of code coverage hits
  • - *
  • FULL : both MEMORY and DATABASE (default).
  • - *
- * - * @since 1.10 - * @deprecated since 5.6. No more used since 5.2. - */ -@Deprecated -public enum PersistenceMode { - MEMORY, DATABASE, FULL; - - public boolean useMemory() { - return equals(MEMORY) || equals(FULL); - } - - public boolean useDatabase() { - return equals(DATABASE) || equals(FULL); - } -} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/measures/MeasureTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/measures/MeasureTest.java index 1c253c828c5..ddf9e4ded72 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/measures/MeasureTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/measures/MeasureTest.java @@ -45,18 +45,6 @@ public class MeasureTest { new Measure("metric_key").setValue(Double.NaN); } - @Test - public void defaultPersistenceModeIsFull() { - assertThat(new Measure(CoreMetrics.LINES, 32.0).getPersistenceMode()).isEqualTo(PersistenceMode.FULL); - } - - @Test - public void persistenceModeIsDatabaseForBigDataMeasures() { - Measure bigDataMeasure = new Measure(CoreMetrics.COVERAGE_LINE_HITS_DATA, "long data") - .setPersistenceMode(PersistenceMode.DATABASE); - assertThat(bigDataMeasure.getPersistenceMode()).isEqualTo(PersistenceMode.DATABASE); - } - @Test public void measureWithLevelValue() { assertThat(new Measure(CoreMetrics.ALERT_STATUS, Metric.Level.ERROR).getData()).isEqualTo("ERROR"); diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/measures/PersistenceModeTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/measures/PersistenceModeTest.java deleted file mode 100644 index a37d2c9add4..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/measures/PersistenceModeTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program 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. - * - * This program 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.api.measures; - -import org.junit.Test; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PersistenceModeTest { - - @Test - public void useMemory() { - assertThat(PersistenceMode.MEMORY.useMemory()).isTrue(); - assertThat(PersistenceMode.DATABASE.useMemory()).isFalse(); - assertThat(PersistenceMode.FULL.useMemory()).isTrue(); - } - - @Test - public void useDatabase() { - assertThat(PersistenceMode.MEMORY.useDatabase()).isFalse(); - assertThat(PersistenceMode.DATABASE.useDatabase()).isTrue(); - assertThat(PersistenceMode.FULL.useDatabase()).isTrue(); - } -} -- 2.39.5