aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/sonar-cpd-plugin
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@gmail.com>2013-08-22 10:25:12 +0200
committerJulien Lancelot <julien.lancelot@gmail.com>2013-08-22 10:25:12 +0200
commitbce5d445c4be210e8693916ec1820199477634f6 (patch)
tree3940ce5f14ffc6c8fb68d1d5eb3616a93263ad88 /plugins/sonar-cpd-plugin
parent172403a9eadc6bd4e34fbb7e3e5108db26a984b5 (diff)
downloadsonarqube-bce5d445c4be210e8693916ec1820199477634f6.tar.gz
sonarqube-bce5d445c4be210e8693916ec1820199477634f6.zip
Fix quality flaws
Diffstat (limited to 'plugins/sonar-cpd-plugin')
-rw-r--r--plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarBridgeEngine.java10
-rw-r--r--plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarEngine.java24
2 files changed, 9 insertions, 25 deletions
diff --git a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarBridgeEngine.java b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarBridgeEngine.java
index bbd43660d82..4336afa0a74 100644
--- a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarBridgeEngine.java
+++ b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarBridgeEngine.java
@@ -44,11 +44,7 @@ import org.sonar.plugins.cpd.index.SonarDuplicationsIndex;
import java.io.File;
import java.util.Collection;
import java.util.List;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
+import java.util.concurrent.*;
public class SonarBridgeEngine extends CpdEngine {
@@ -123,9 +119,9 @@ public class SonarBridgeEngine extends CpdEngine {
filtered = null;
LOG.warn("Timeout during detection of duplications for " + file, e);
} catch (InterruptedException e) {
- throw new SonarException(e);
+ throw new SonarException("Fail during detection of duplication for "+ file, e);
} catch (ExecutionException e) {
- throw new SonarException(e);
+ throw new SonarException("Fail during detection of duplication for "+ file, e);
}
SonarEngine.save(context, resource, filtered);
diff --git a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarEngine.java b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarEngine.java
index 3fabbecc0be..4d9cf3bade5 100644
--- a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarEngine.java
+++ b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarEngine.java
@@ -32,11 +32,7 @@ import org.sonar.api.database.model.ResourceModel;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.measures.Measure;
import org.sonar.api.measures.PersistenceMode;
-import org.sonar.api.resources.Java;
-import org.sonar.api.resources.JavaFile;
-import org.sonar.api.resources.Language;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.Resource;
+import org.sonar.api.resources.*;
import org.sonar.api.scan.filesystem.FileQuery;
import org.sonar.api.scan.filesystem.ModuleFileSystem;
import org.sonar.api.scan.filesystem.PathResolver;
@@ -58,20 +54,12 @@ import org.sonar.plugins.cpd.index.SonarDuplicationsIndex;
import javax.annotation.Nullable;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStreamReader;
-import java.io.Reader;
+import java.io.*;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
+import java.util.concurrent.*;
public class SonarEngine extends CpdEngine {
@@ -140,7 +128,7 @@ public class SonarEngine extends CpdEngine {
reader = new InputStreamReader(new FileInputStream(file), fileSystem.sourceCharset());
statements = statementChunker.chunk(tokenChunker.chunk(reader));
} catch (FileNotFoundException e) {
- throw new SonarException(e);
+ throw new SonarException("Cannot find file "+ file, e);
} finally {
IOUtils.closeQuietly(reader);
}
@@ -169,9 +157,9 @@ public class SonarEngine extends CpdEngine {
clones = null;
LOG.warn("Timeout during detection of duplications for " + file, e);
} catch (InterruptedException e) {
- throw new SonarException(e);
+ throw new SonarException("Fail during detection of duplication for "+ file, e);
} catch (ExecutionException e) {
- throw new SonarException(e);
+ throw new SonarException("Fail during detection of duplication for "+ file, e);
}
save(context, resource, clones);