]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-11125 Save coverage in PRs and SLB
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Fri, 17 Aug 2018 13:41:12 +0000 (15:41 +0200)
committersonartech <sonartech@sonarsource.com>
Wed, 19 Sep 2018 08:51:40 +0000 (10:51 +0200)
sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorContext.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/noop/NoOpNewCoverage.java [deleted file]
sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/DefaultSensorContextTest.java

index 04b3ca16a2d30b37c25ae36ec637fc59e6885bda..299e7eadb98ae0c992a915c97c049e0fb85ea981 100644 (file)
@@ -52,7 +52,6 @@ import org.sonar.api.config.Settings;
 import org.sonar.api.utils.Version;
 import org.sonar.scanner.scan.branch.BranchConfiguration;
 import org.sonar.scanner.sensor.noop.NoOpNewAnalysisError;
-import org.sonar.scanner.sensor.noop.NoOpNewCoverage;
 import org.sonar.scanner.sensor.noop.NoOpNewCpdTokens;
 import org.sonar.scanner.sensor.noop.NoOpNewExternalIssue;
 import org.sonar.scanner.sensor.noop.NoOpNewHighlighting;
@@ -66,7 +65,6 @@ public class DefaultSensorContext implements SensorContext {
   static final NoOpNewSymbolTable NO_OP_NEW_SYMBOL_TABLE = new NoOpNewSymbolTable();
   static final NoOpNewCpdTokens NO_OP_NEW_CPD_TOKENS = new NoOpNewCpdTokens();
   static final NoOpNewAnalysisError NO_OP_NEW_ANALYSIS_ERROR = new NoOpNewAnalysisError();
-  static final NoOpNewCoverage NO_OP_NEW_COVERAGE = new NoOpNewCoverage();
   static final NoOpNewExternalIssue NO_OP_NEW_EXTERNAL_ISSUE = new NoOpNewExternalIssue();
   static final NoOpNewSignificantCode NO_OP_NEW_SIGNIFICANT_CODE = new NoOpNewSignificantCode();
 
@@ -165,9 +163,6 @@ public class DefaultSensorContext implements SensorContext {
 
   @Override
   public NewCoverage newCoverage() {
-    if (branchConfiguration.isShortOrPullRequest()) {
-      return NO_OP_NEW_COVERAGE;
-    }
     return new DefaultCoverage(sensorStorage);
   }
 
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/noop/NoOpNewCoverage.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/noop/NoOpNewCoverage.java
deleted file mode 100644 (file)
index 7d9ce51..0000000
+++ /dev/null
@@ -1,56 +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.scanner.sensor.noop;
-
-import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.sensor.coverage.CoverageType;
-import org.sonar.api.batch.sensor.coverage.NewCoverage;
-
-public class NoOpNewCoverage implements NewCoverage {
-
-  @Override
-  public NewCoverage onFile(InputFile inputFile) {
-    // no op
-    return this;
-  }
-
-  @Override
-  public NewCoverage ofType(CoverageType type) {
-    // no op
-    return this;
-  }
-
-  @Override
-  public NewCoverage lineHits(int line, int hits) {
-    // no op
-    return this;
-  }
-
-  @Override
-  public NewCoverage conditions(int line, int conditions, int coveredConditions) {
-    // no op
-    return this;
-  }
-
-  @Override
-  public void save() {
-    // no op
-  }
-}
index 1d0e59b46c256970b6b2a89170ffc99dee9c9f15..e7f82f77ab510f3319ff9a0f60c75379d61f3a9d 100644 (file)
@@ -109,16 +109,8 @@ public class DefaultSensorContextTest {
   }
 
   @Test
-  public void shouldSkipDupsAndCoverageOnShortBranches() {
+  public void shouldSkipDupsOnShortBranchesAndPullRequests() {
     when(branchConfig.isShortOrPullRequest()).thenReturn(true);
     assertThat(adaptor.newCpdTokens()).isEqualTo(DefaultSensorContext.NO_OP_NEW_CPD_TOKENS);
-    assertThat(adaptor.newCoverage()).isEqualTo(DefaultSensorContext.NO_OP_NEW_COVERAGE);
-  }
-
-  @Test
-  public void shouldSkipDupsAndCoverageOnPullRequests() {
-    when(branchConfig.isShortOrPullRequest()).thenReturn(true);
-    assertThat(adaptor.newCpdTokens()).isEqualTo(DefaultSensorContext.NO_OP_NEW_CPD_TOKENS);
-    assertThat(adaptor.newCoverage()).isEqualTo(DefaultSensorContext.NO_OP_NEW_COVERAGE);
   }
 }