aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2014-09-26 10:22:12 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2014-09-26 10:22:12 +0200
commit8664470d82c4f682866ca271d4e7e2a89374212f (patch)
tree0f490693a69dee5211e8c7c0bf7453f56a25c766 /sonar-plugin-api
parent4234c8d5b402e751dfd0c17732cfc843ba807fe0 (diff)
downloadsonarqube-8664470d82c4f682866ca271d4e7e2a89374212f.tar.gz
sonarqube-8664470d82c4f682866ca271d4e7e2a89374212f.zip
Revert "SONAR-5644 Rework SCM API"
This reverts commit a4e76de07797ea2b9b809a0cc0b90286c90cd3cd.
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/scm/BlameCommand.java47
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/scm/BlameLine.java42
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/scm/ScmProvider.java29
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultIssue.java5
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/test/internal/DefaultTestCase.java4
5 files changed, 23 insertions, 104 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/scm/BlameCommand.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/scm/BlameCommand.java
deleted file mode 100644
index 385b3528e54..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/scm/BlameCommand.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.batch.scm;
-
-import org.sonar.api.batch.fs.FileSystem;
-import org.sonar.api.batch.fs.InputFile;
-
-import java.util.List;
-
-/**
- * @since 5.0
- */
-public interface BlameCommand {
-
- /**
- * Compute blame of the provided files. Computation can be done in parallel.
- * If there is an error that prevent to blame a file then an exception should be raised.
- */
- void blame(FileSystem fs, Iterable<InputFile> files, BlameResult result);
-
- /**
- * Callback for the provider to report results of blame per file.
- */
- public static interface BlameResult {
-
- void add(InputFile file, List<BlameLine> lines);
-
- }
-
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/scm/BlameLine.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/scm/BlameLine.java
index c4362f05a9b..2303b90f794 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/scm/BlameLine.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/scm/BlameLine.java
@@ -19,11 +19,6 @@
*/
package org.sonar.api.batch.scm;
-import org.apache.commons.lang.builder.EqualsBuilder;
-import org.apache.commons.lang.builder.HashCodeBuilder;
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.apache.commons.lang.builder.ToStringStyle;
-
import java.util.Date;
/**
@@ -104,41 +99,4 @@ public class BlameLine {
this.date = null;
}
}
-
- // For testing purpose
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (obj == this) {
- return true;
- }
- if (obj.getClass() != getClass()) {
- return false;
- }
- BlameLine rhs = (BlameLine) obj;
- return new EqualsBuilder()
- .append(date, rhs.date)
- .append(revision, rhs.revision)
- .append(author, rhs.author)
- .append(committer, rhs.committer)
- .isEquals();
- }
-
- @Override
- public int hashCode() {
- return new HashCodeBuilder(27, 45).
- append(date)
- .append(revision)
- .append(author)
- .append(committer)
- .toHashCode();
- }
-
- @Override
- public String toString() {
- return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
- }
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/scm/ScmProvider.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/scm/ScmProvider.java
index a32bec98538..2630f95b5e6 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/scm/ScmProvider.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/scm/ScmProvider.java
@@ -21,31 +21,42 @@ package org.sonar.api.batch.scm;
import org.sonar.api.BatchExtension;
import org.sonar.api.batch.InstantiationStrategy;
+import org.sonar.api.batch.fs.FileSystem;
+import org.sonar.api.batch.fs.InputFile;
import java.io.File;
+import java.util.List;
/**
* @since 5.0
*/
@InstantiationStrategy(InstantiationStrategy.PER_BATCH)
-public abstract class ScmProvider implements BatchExtension {
+public interface ScmProvider extends BatchExtension {
/**
* Unique identifier of the provider. Can be used in SCM URL to define the provider to use.
*/
- public abstract String key();
+ String key();
/**
* Does this provider able to manage files located in this directory.
- * Used by autodetection. Not considered if user has forced the provider key.
- * @return false by default
+ * Used by autodetection.
*/
- public boolean supports(File baseDir) {
- return false;
- }
+ boolean supports(File baseDir);
+
+ /**
+ * Compute blame of the provided files. Computation can be done in parallel.
+ * If there is an error that prevent to blame a file then an exception should be raised.
+ */
+ void blame(FileSystem fs, Iterable<InputFile> files, BlameResult result);
+
+ /**
+ * Callback for the provider to save results of blame per file.
+ */
+ public static interface BlameResult {
+
+ void add(InputFile file, List<BlameLine> lines);
- public BlameCommand blameCommand() {
- throw new UnsupportedOperationException("Blame command is not supported by " + key() + " provider");
}
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultIssue.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultIssue.java
index 42637fdd4cb..23148378f35 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultIssue.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultIssue.java
@@ -52,12 +52,10 @@ public class DefaultIssue implements Issue {
private final SensorStorage storage;
public DefaultIssue() {
- this.key = UUID.randomUUID().toString();
this.storage = null;
}
public DefaultIssue(SensorStorage storage) {
- this.key = UUID.randomUUID().toString();
this.storage = storage;
}
@@ -157,6 +155,9 @@ public class DefaultIssue implements Issue {
public void save() {
Preconditions.checkNotNull(this.storage, "No persister on this object");
Preconditions.checkNotNull(this.ruleKey, "ruleKey is mandatory on issue");
+ if (this.key == null) {
+ this.key = UUID.randomUUID().toString();
+ }
Preconditions.checkState(!Strings.isNullOrEmpty(key), "Fail to generate issue key");
storage.store(this);
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/test/internal/DefaultTestCase.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/test/internal/DefaultTestCase.java
index 023adec8106..7d05c23f259 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/test/internal/DefaultTestCase.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/test/internal/DefaultTestCase.java
@@ -43,10 +43,6 @@ public class DefaultTestCase implements TestCase {
private TestCase.Type type = Type.UNIT;
private String stackTrace;
- public DefaultTestCase() {
- this.storage = null;
- }
-
public DefaultTestCase(SensorStorage storage) {
this.storage = storage;
}