aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2016-05-10 18:12:35 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2016-05-12 08:49:09 +0200
commitf785c62ff8259184c889eacea78c5dc25cb9e1a3 (patch)
tree7041dfa84407c19f3287d1a9e4b4d50e8f9dad96 /sonar-scanner-engine
parent73f40c17f4b9cdd03636d7198ac5ae1b563de7d1 (diff)
downloadsonarqube-f785c62ff8259184c889eacea78c5dc25cb9e1a3.tar.gz
sonarqube-f785c62ff8259184c889eacea78c5dc25cb9e1a3.zip
SONAR-7612 Move new Sensor API out of @Beta
Diffstat (limited to 'sonar-scanner-engine')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/batch/postjob/DefaultPostJobContext.java32
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/batch/postjob/PostJobOptimizer.java9
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/batch/postjob/DefaultPostJobContextTest.java16
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/batch/postjob/PostJobOptimizerTest.java18
4 files changed, 15 insertions, 60 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/postjob/DefaultPostJobContext.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/postjob/DefaultPostJobContext.java
index 02b1582b999..341bc7991a8 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/batch/postjob/DefaultPostJobContext.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/batch/postjob/DefaultPostJobContext.java
@@ -19,35 +19,29 @@
*/
package org.sonar.batch.postjob;
-import org.sonar.batch.issue.tracking.TrackedIssue;
-
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
-
import javax.annotation.Nullable;
-
-import org.sonar.api.batch.AnalysisMode;
import org.sonar.api.batch.fs.InputComponent;
import org.sonar.api.batch.postjob.PostJobContext;
-import org.sonar.api.batch.postjob.issue.Issue;
+import org.sonar.api.batch.postjob.issue.PostJobIssue;
import org.sonar.api.batch.rule.Severity;
import org.sonar.api.config.Settings;
import org.sonar.api.rule.RuleKey;
import org.sonar.batch.index.BatchComponent;
import org.sonar.batch.index.BatchComponentCache;
import org.sonar.batch.issue.IssueCache;
+import org.sonar.batch.issue.tracking.TrackedIssue;
public class DefaultPostJobContext implements PostJobContext {
private final Settings settings;
- private final AnalysisMode analysisMode;
private final IssueCache cache;
private final BatchComponentCache resourceCache;
- public DefaultPostJobContext(Settings settings, AnalysisMode analysisMode, IssueCache cache, BatchComponentCache resourceCache) {
+ public DefaultPostJobContext(Settings settings, IssueCache cache, BatchComponentCache resourceCache) {
this.settings = settings;
- this.analysisMode = analysisMode;
this.cache = cache;
this.resourceCache = resourceCache;
}
@@ -58,21 +52,16 @@ public class DefaultPostJobContext implements PostJobContext {
}
@Override
- public AnalysisMode analysisMode() {
- return analysisMode;
- }
-
- @Override
- public Iterable<Issue> issues() {
+ public Iterable<PostJobIssue> issues() {
return Iterables.transform(Iterables.filter(cache.all(), new ResolvedPredicate(false)), new IssueTransformer());
}
@Override
- public Iterable<Issue> resolvedIssues() {
+ public Iterable<PostJobIssue> resolvedIssues() {
return Iterables.transform(Iterables.filter(cache.all(), new ResolvedPredicate(true)), new IssueTransformer());
}
- private class DefaultIssueWrapper implements Issue {
+ private class DefaultIssueWrapper implements PostJobIssue {
private final TrackedIssue wrapped;
@@ -107,11 +96,6 @@ public class DefaultPostJobContext implements PostJobContext {
}
@Override
- public Double effortToFix() {
- return wrapped.gap();
- }
-
- @Override
public String message() {
return wrapped.getMessage();
}
@@ -128,9 +112,9 @@ public class DefaultPostJobContext implements PostJobContext {
}
}
- private class IssueTransformer implements Function<TrackedIssue, Issue> {
+ private class IssueTransformer implements Function<TrackedIssue, PostJobIssue> {
@Override
- public Issue apply(TrackedIssue input) {
+ public PostJobIssue apply(TrackedIssue input) {
return new DefaultIssueWrapper(input);
}
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/postjob/PostJobOptimizer.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/postjob/PostJobOptimizer.java
index b27e89e87f8..e1b0cca1c1e 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/batch/postjob/PostJobOptimizer.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/batch/postjob/PostJobOptimizer.java
@@ -22,7 +22,6 @@ package org.sonar.batch.postjob;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.batch.BatchSide;
-import org.sonar.api.batch.AnalysisMode;
import org.sonar.api.batch.postjob.internal.DefaultPostJobDescriptor;
import org.sonar.api.config.Settings;
@@ -32,11 +31,9 @@ public class PostJobOptimizer {
private static final Logger LOG = LoggerFactory.getLogger(PostJobOptimizer.class);
private final Settings settings;
- private final AnalysisMode analysisMode;
- public PostJobOptimizer(Settings settings, AnalysisMode analysisMode) {
+ public PostJobOptimizer(Settings settings) {
this.settings = settings;
- this.analysisMode = analysisMode;
}
/**
@@ -47,10 +44,6 @@ public class PostJobOptimizer {
LOG.debug("'{}' skipped because one of the required properties is missing", descriptor.name());
return false;
}
- if (descriptor.isDisabledInIssues() && analysisMode.isIssues()) {
- LOG.debug("'{}' skipped in issues mode", descriptor.name());
- return false;
- }
return true;
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/batch/postjob/DefaultPostJobContextTest.java b/sonar-scanner-engine/src/test/java/org/sonar/batch/postjob/DefaultPostJobContextTest.java
index 12f00a55d90..5f9916919ec 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/batch/postjob/DefaultPostJobContextTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/batch/postjob/DefaultPostJobContextTest.java
@@ -19,20 +19,18 @@
*/
package org.sonar.batch.postjob;
-import org.sonar.batch.issue.tracking.TrackedIssue;
-
import java.util.Arrays;
-
import org.junit.Before;
import org.junit.Test;
-import org.sonar.api.batch.AnalysisMode;
import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.postjob.issue.Issue;
+import org.sonar.api.batch.postjob.issue.PostJobIssue;
import org.sonar.api.batch.rule.Severity;
import org.sonar.api.config.Settings;
import org.sonar.api.resources.File;
import org.sonar.batch.index.BatchComponentCache;
import org.sonar.batch.issue.IssueCache;
+import org.sonar.batch.issue.tracking.TrackedIssue;
+
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -41,7 +39,6 @@ public class DefaultPostJobContextTest {
private IssueCache issueCache;
private BatchComponentCache resourceCache;
- private AnalysisMode analysisMode;
private DefaultPostJobContext context;
private Settings settings;
@@ -49,15 +46,13 @@ public class DefaultPostJobContextTest {
public void prepare() {
issueCache = mock(IssueCache.class);
resourceCache = new BatchComponentCache();
- analysisMode = mock(AnalysisMode.class);
settings = new Settings();
- context = new DefaultPostJobContext(settings, analysisMode, issueCache, resourceCache);
+ context = new DefaultPostJobContext(settings, issueCache, resourceCache);
}
@Test
public void test() {
assertThat(context.settings()).isSameAs(settings);
- assertThat(context.analysisMode()).isSameAs(analysisMode);
TrackedIssue defaultIssue = new TrackedIssue();
defaultIssue.setComponentKey("foo:src/Foo.php");
@@ -69,9 +64,8 @@ public class DefaultPostJobContextTest {
defaultIssue.setSeverity("BLOCKER");
when(issueCache.all()).thenReturn(Arrays.asList(defaultIssue));
- Issue issue = context.issues().iterator().next();
+ PostJobIssue issue = context.issues().iterator().next();
assertThat(issue.componentKey()).isEqualTo("foo:src/Foo.php");
- assertThat(issue.effortToFix()).isEqualTo(2.0);
assertThat(issue.isNew()).isTrue();
assertThat(issue.key()).isEqualTo("xyz");
assertThat(issue.line()).isEqualTo(1);
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/batch/postjob/PostJobOptimizerTest.java b/sonar-scanner-engine/src/test/java/org/sonar/batch/postjob/PostJobOptimizerTest.java
index e5d30f1dfa3..3420e45f209 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/batch/postjob/PostJobOptimizerTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/batch/postjob/PostJobOptimizerTest.java
@@ -23,13 +23,10 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.batch.AnalysisMode;
import org.sonar.api.batch.postjob.internal.DefaultPostJobDescriptor;
import org.sonar.api.config.Settings;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
public class PostJobOptimizerTest {
@@ -38,13 +35,11 @@ public class PostJobOptimizerTest {
private PostJobOptimizer optimizer;
private Settings settings;
- private AnalysisMode analysisMode;
@Before
public void prepare() {
settings = new Settings();
- analysisMode = mock(AnalysisMode.class);
- optimizer = new PostJobOptimizer(settings, analysisMode);
+ optimizer = new PostJobOptimizer(settings);
}
@Test
@@ -63,15 +58,4 @@ public class PostJobOptimizerTest {
settings.setProperty("sonar.foo.reportPath", "foo");
assertThat(optimizer.shouldExecute(descriptor)).isTrue();
}
-
- @Test
- public void should_disabled_in_issues_mode() {
- DefaultPostJobDescriptor descriptor = new DefaultPostJobDescriptor()
- .disabledInIssues();
- assertThat(optimizer.shouldExecute(descriptor)).isTrue();
-
- when(analysisMode.isIssues()).thenReturn(true);
-
- assertThat(optimizer.shouldExecute(descriptor)).isFalse();
- }
}