aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/events/InitializerExecutionHandler.java3
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/events/InitializersPhaseHandler.java3
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/events/PostJobExecutionHandler.java3
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/events/PostJobsPhaseHandler.java6
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/events/ProjectAnalysisHandler.java3
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/events/SensorExecutionHandler.java3
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/events/SensorsPhaseHandler.java4
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueHandler.java68
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/measures/Metrics.java2
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/batch/bootstrap/ProjectDefinitionTest.java14
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/resources/FileTest.java5
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/batch/deprecated/DeprecatedSensorContext.java4
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/batch/index/DefaultIndex.java21
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/batch/rule/RuleFinderCompatibility.java34
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/batch/sensor/SensorWrapper.java4
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/batch/index/DefaultIndexTest.java3
16 files changed, 39 insertions, 141 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/InitializerExecutionHandler.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/InitializerExecutionHandler.java
index 4d5063eadfd..3dad1067862 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/InitializerExecutionHandler.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/InitializerExecutionHandler.java
@@ -23,7 +23,10 @@ import org.sonar.api.batch.Initializer;
/**
* @since 3.7
+ * @deprecated since 6.0
*/
+@Deprecated
+@FunctionalInterface
public interface InitializerExecutionHandler extends EventHandler {
/**
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/InitializersPhaseHandler.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/InitializersPhaseHandler.java
index 8ac2876e933..54af5f76aa1 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/InitializersPhaseHandler.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/InitializersPhaseHandler.java
@@ -24,7 +24,10 @@ import org.sonar.api.batch.Initializer;
/**
* @since 3.7
+ * @deprecated since 6.0
*/
+@Deprecated
+@FunctionalInterface
public interface InitializersPhaseHandler extends EventHandler {
/**
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/PostJobExecutionHandler.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/PostJobExecutionHandler.java
index de71e20bfb2..a486485c481 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/PostJobExecutionHandler.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/PostJobExecutionHandler.java
@@ -23,7 +23,10 @@ import org.sonar.api.batch.PostJob;
/**
* @since 3.6
+ * @deprecated since 6.0
*/
+@Deprecated
+@FunctionalInterface
public interface PostJobExecutionHandler extends EventHandler {
/**
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/PostJobsPhaseHandler.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/PostJobsPhaseHandler.java
index eaf448628ad..132361546c4 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/PostJobsPhaseHandler.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/PostJobsPhaseHandler.java
@@ -19,13 +19,15 @@
*/
package org.sonar.api.batch.events;
-import org.sonar.api.batch.PostJob;
-
import java.util.List;
+import org.sonar.api.batch.PostJob;
/**
* @since 3.6
+ * @deprecated since 6.0
*/
+@Deprecated
+@FunctionalInterface
public interface PostJobsPhaseHandler extends EventHandler {
/**
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/ProjectAnalysisHandler.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/ProjectAnalysisHandler.java
index 6680241e9f1..5acd1fa47a3 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/ProjectAnalysisHandler.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/ProjectAnalysisHandler.java
@@ -23,7 +23,10 @@ import org.sonar.api.resources.Project;
/**
* @since 2.8
+ * @deprecated since 6.0
*/
+@Deprecated
+@FunctionalInterface
public interface ProjectAnalysisHandler extends EventHandler {
/**
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/SensorExecutionHandler.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/SensorExecutionHandler.java
index 11330c3b653..c16d2d85970 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/SensorExecutionHandler.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/SensorExecutionHandler.java
@@ -23,7 +23,10 @@ import org.sonar.api.batch.Sensor;
/**
* @since 2.8
+ * @deprecated since 6.0
*/
+@Deprecated
+@FunctionalInterface
public interface SensorExecutionHandler extends EventHandler {
/**
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/SensorsPhaseHandler.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/SensorsPhaseHandler.java
index cedc0a32753..72416a2d76c 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/SensorsPhaseHandler.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/SensorsPhaseHandler.java
@@ -19,13 +19,13 @@
*/
package org.sonar.api.batch.events;
-import org.sonar.api.batch.Sensor;
-
import java.util.List;
+import org.sonar.api.batch.Sensor;
/**
* @since 2.8
*/
+@FunctionalInterface
public interface SensorsPhaseHandler extends EventHandler {
/**
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueHandler.java b/sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueHandler.java
deleted file mode 100644
index fb9bb62aff9..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueHandler.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact 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.issue;
-
-import org.sonar.api.batch.ScannerSide;
-import org.sonar.api.ExtensionPoint;
-import org.sonar.api.user.User;
-
-import javax.annotation.Nullable;
-
-/**
- * @since 3.6
- */
-@ScannerSide
-@ExtensionPoint
-public interface IssueHandler {
-
- interface Context {
- Issue issue();
-
- boolean isNew();
-
- boolean isEndOfLife();
-
- Context setLine(@Nullable Integer i);
-
- Context setMessage(@Nullable String s);
-
- Context setSeverity(String s);
-
- Context setEffortToFix(@Nullable Double d);
-
- Context setAuthorLogin(@Nullable String s);
-
- Context setAttribute(String key, @Nullable String value);
-
- /**
- * @deprecated since 3.7.1
- */
- @Deprecated
- Context assign(@Nullable String login);
-
- Context assign(@Nullable User user);
-
- Context addComment(String text);
-
- }
-
- void onIssue(Context context);
-
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metrics.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metrics.java
index 22565ff8612..c4914dc0e40 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metrics.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metrics.java
@@ -21,8 +21,8 @@ package org.sonar.api.measures;
import java.util.List;
import org.sonar.api.ExtensionPoint;
-import org.sonar.api.batch.ScannerSide;
import org.sonar.api.batch.InstantiationStrategy;
+import org.sonar.api.batch.ScannerSide;
import org.sonar.api.ce.ComputeEngineSide;
import org.sonar.api.server.ServerSide;
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/bootstrap/ProjectDefinitionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/bootstrap/ProjectDefinitionTest.java
index a02f7e226dd..2db3cef3a86 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/batch/bootstrap/ProjectDefinitionTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/batch/bootstrap/ProjectDefinitionTest.java
@@ -19,23 +19,14 @@
*/
package org.sonar.api.batch.bootstrap;
-import org.junit.Rule;
+import java.util.Properties;
import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
import org.sonar.api.CoreProperties;
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-import java.util.Properties;
-
import static org.assertj.core.api.Assertions.assertThat;
public class ProjectDefinitionTest {
- @Rule
- public TemporaryFolder temp = new TemporaryFolder();
-
@Test
public void shouldSetKey() {
ProjectDefinition def = ProjectDefinition.create();
@@ -89,7 +80,7 @@ public class ProjectDefinitionTest {
public void shouldTrimPaths() {
ProjectDefinition def = ProjectDefinition.create();
def.setSources("src1", " src2 ", " with whitespace");
- def.setTests("test1"," test2 "," with whitespace");
+ def.setTests("test1", " test2 ", " with whitespace");
assertThat(def.sources()).containsOnly("src1", "src2", "with whitespace");
assertThat(def.tests()).containsOnly("test1", "test2", "with whitespace");
@@ -128,5 +119,4 @@ public class ProjectDefinitionTest {
assertThat(root.tests()).isEmpty();
}
-
}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/resources/FileTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/resources/FileTest.java
index f707951bb76..f9110ec51e7 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/resources/FileTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/resources/FileTest.java
@@ -19,17 +19,12 @@
*/
package org.sonar.api.resources;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
import static org.assertj.core.api.Assertions.assertThat;
public class FileTest {
- @Rule
- public TemporaryFolder temp = new TemporaryFolder();
-
@Test
public void trimKeyAndName() {
File file = File.create(" foo/bar/toto.sql ");
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/deprecated/DeprecatedSensorContext.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/deprecated/DeprecatedSensorContext.java
index ca087ffdf93..de68c7fba5e 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/batch/deprecated/DeprecatedSensorContext.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/batch/deprecated/DeprecatedSensorContext.java
@@ -21,8 +21,6 @@ package org.sonar.batch.deprecated;
import java.io.Serializable;
import java.util.Collection;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.sonar.api.SonarQubeVersion;
import org.sonar.api.batch.AnalysisMode;
import org.sonar.api.batch.SensorContext;
@@ -48,8 +46,6 @@ import org.sonar.batch.sensor.coverage.CoverageExclusions;
public class DeprecatedSensorContext extends DefaultSensorContext implements SensorContext {
- private static final Logger LOG = LoggerFactory.getLogger(DeprecatedSensorContext.class);
-
private final DefaultIndex index;
private final Project project;
private final CoverageExclusions coverageFilter;
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/index/DefaultIndex.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/index/DefaultIndex.java
index 2831159d8dd..488f1714b28 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/batch/index/DefaultIndex.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/batch/index/DefaultIndex.java
@@ -41,10 +41,8 @@ import org.sonar.api.design.Dependency;
import org.sonar.api.measures.Measure;
import org.sonar.api.measures.MeasuresFilter;
import org.sonar.api.measures.MeasuresFilters;
-import org.sonar.api.resources.Directory;
import org.sonar.api.resources.File;
import org.sonar.api.resources.Project;
-import org.sonar.api.resources.Qualifiers;
import org.sonar.api.resources.Resource;
import org.sonar.api.resources.ResourceUtils;
import org.sonar.api.scan.filesystem.PathResolver;
@@ -59,18 +57,16 @@ public class DefaultIndex {
private final BatchComponentCache componentCache;
private final MeasureCache measureCache;
- private final PathResolver pathResolver;
private final DefaultProjectTree projectTree;
// caches
private DefaultSensorStorage sensorStorage;
private Project currentProject;
private Map<Resource, Bucket> buckets = Maps.newLinkedHashMap();
- public DefaultIndex(BatchComponentCache componentCache, DefaultProjectTree projectTree, MeasureCache measureCache, PathResolver pathResolver) {
+ public DefaultIndex(BatchComponentCache componentCache, DefaultProjectTree projectTree, MeasureCache measureCache) {
this.componentCache = componentCache;
this.projectTree = projectTree;
this.measureCache = measureCache;
- this.pathResolver = pathResolver;
}
public void start() {
@@ -297,21 +293,6 @@ public class DefaultIndex {
if (StringUtils.isNotBlank(reference.getKey())) {
return buckets.get(reference);
}
- String relativePathFromSourceDir = null;
- boolean isTest = false;
- boolean isDir = false;
- if (reference instanceof File) {
- File referenceFile = (File) reference;
- isTest = Qualifiers.UNIT_TEST_FILE.equals(referenceFile.getQualifier());
- relativePathFromSourceDir = referenceFile.relativePathFromSourceDir();
- } else if (reference instanceof Directory) {
- isDir = true;
- Directory referenceDir = (Directory) reference;
- relativePathFromSourceDir = referenceDir.relativePathFromSourceDir();
- if (Directory.ROOT.equals(relativePathFromSourceDir)) {
- relativePathFromSourceDir = "";
- }
- }
return null;
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/rule/RuleFinderCompatibility.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/rule/RuleFinderCompatibility.java
index fe763f873bd..93b55d7da01 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/batch/rule/RuleFinderCompatibility.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/batch/rule/RuleFinderCompatibility.java
@@ -19,24 +19,20 @@
*/
package org.sonar.batch.rule;
-import org.sonar.api.batch.rule.Rules;
-
-import com.google.common.base.Function;
-import com.google.common.collect.Collections2;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
+import org.sonar.api.batch.rule.Rules;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rules.Rule;
import org.sonar.api.rules.RuleFinder;
import org.sonar.api.rules.RuleQuery;
-import javax.annotation.CheckForNull;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
+import static org.sonar.core.util.stream.Collectors.toList;
/**
* FIXME Waiting for the list of all server rules on batch side this is implemented by redirecting on ActiveRules. This is not correct
@@ -46,12 +42,6 @@ import java.util.Collections;
public class RuleFinderCompatibility implements RuleFinder {
private final Rules rules;
- private static Function<org.sonar.api.batch.rule.Rule, Rule> ruleTransformer = new Function<org.sonar.api.batch.rule.Rule, Rule>() {
- @Override
- public Rule apply(@Nonnull org.sonar.api.batch.rule.Rule input) {
- return toRule(input);
- }
- };
public RuleFinderCompatibility(Rules rules) {
this.rules = rules;
@@ -101,18 +91,20 @@ public class RuleFinderCompatibility implements RuleFinder {
}
private Collection<Rule> byRepository(RuleQuery query) {
- return Collections2.transform(rules.findByRepository(query.getRepositoryKey()), ruleTransformer);
+ return rules.findByRepository(query.getRepositoryKey()).stream()
+ .map(RuleFinderCompatibility::toRule)
+ .collect(toList());
}
-
-
private Collection<Rule> byKey(RuleQuery query) {
Rule rule = toRule(rules.find(RuleKey.of(query.getRepositoryKey(), query.getKey())));
return rule != null ? Arrays.asList(rule) : Collections.<Rule>emptyList();
}
private Collection<Rule> byInternalKey(RuleQuery query) {
- return Collections2.transform(rules.findByInternalKey(query.getRepositoryKey(), query.getConfigKey()), ruleTransformer);
+ return rules.findByInternalKey(query.getRepositoryKey(), query.getConfigKey()).stream()
+ .map(RuleFinderCompatibility::toRule)
+ .collect(toList());
}
@CheckForNull
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/sensor/SensorWrapper.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/sensor/SensorWrapper.java
index 2fb6d98ecdb..f268a67da27 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/batch/sensor/SensorWrapper.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/batch/sensor/SensorWrapper.java
@@ -19,8 +19,6 @@
*/
package org.sonar.batch.sensor;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.sonar.api.batch.sensor.Sensor;
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor;
@@ -28,8 +26,6 @@ import org.sonar.api.resources.Project;
public class SensorWrapper implements org.sonar.api.batch.Sensor {
- private static final Logger LOG = LoggerFactory.getLogger(SensorWrapper.class);
-
private Sensor wrappedSensor;
private SensorContext adaptor;
private DefaultSensorDescriptor descriptor;
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/batch/index/DefaultIndexTest.java b/sonar-scanner-engine/src/test/java/org/sonar/batch/index/DefaultIndexTest.java
index 71d560b3d70..3c50e057ebe 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/batch/index/DefaultIndexTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/batch/index/DefaultIndexTest.java
@@ -34,7 +34,6 @@ import org.sonar.api.resources.Project;
import org.sonar.api.resources.Resource;
import org.sonar.api.rules.Rule;
import org.sonar.api.rules.RuleFinder;
-import org.sonar.api.scan.filesystem.PathResolver;
import org.sonar.batch.DefaultProjectTree;
import org.sonar.batch.FakeJava;
import org.sonar.batch.scan.measure.MeasureCache;
@@ -65,7 +64,7 @@ public class DefaultIndexTest {
DefaultProjectTree projectTree = mock(DefaultProjectTree.class);
BatchComponentCache resourceCache = new BatchComponentCache();
- index = new DefaultIndex(resourceCache, projectTree, mock(MeasureCache.class), new PathResolver());
+ index = new DefaultIndex(resourceCache, projectTree, mock(MeasureCache.class));
baseDir = temp.newFolder();
project = new Project("project");