aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2018-08-17 15:41:12 +0200
committersonartech <sonartech@sonarsource.com>2018-09-19 10:51:40 +0200
commit57987b49f0b273811165818e54334c4f7eb3d24a (patch)
tree040e6efe02e6b4f7acca4baf96bae1e904162de0 /sonar-scanner-engine
parent236840051693278ab5438711a81ad13c47c4656f (diff)
downloadsonarqube-57987b49f0b273811165818e54334c4f7eb3d24a.tar.gz
sonarqube-57987b49f0b273811165818e54334c4f7eb3d24a.zip
SONAR-11125 Save coverage in PRs and SLB
Diffstat (limited to 'sonar-scanner-engine')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorContext.java5
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/noop/NoOpNewCoverage.java56
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/DefaultSensorContextTest.java10
3 files changed, 1 insertions, 70 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorContext.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorContext.java
index 04b3ca16a2d..299e7eadb98 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorContext.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorContext.java
@@ -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
index 7d9ce51e1bc..00000000000
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/noop/NoOpNewCoverage.java
+++ /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
- }
-}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/DefaultSensorContextTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/DefaultSensorContextTest.java
index 1d0e59b46c2..e7f82f77ab5 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/DefaultSensorContextTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/DefaultSensorContextTest.java
@@ -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);
}
}