From: Julien Lancelot Date: Thu, 22 Aug 2013 08:25:12 +0000 (+0200) Subject: Fix quality flaws X-Git-Tag: 3.7.1-RC1-~57 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=bce5d445c4be210e8693916ec1820199477634f6;p=sonarqube.git Fix quality flaws --- diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/notification/NewIssuesEmailTemplate.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/notification/NewIssuesEmailTemplate.java index fa3c0e70880..6d4c99f7b18 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/notification/NewIssuesEmailTemplate.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/notification/NewIssuesEmailTemplate.java @@ -78,7 +78,7 @@ public class NewIssuesEmailTemplate extends EmailTemplate { try { return URLEncoder.encode(toEncode, "UTF-8"); } catch (UnsupportedEncodingException e) { - throw new IllegalStateException(e); + throw new IllegalStateException("Encoding not supported", e); } } 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); diff --git a/plugins/sonar-maven-batch-plugin/src/main/java/org/sonar/plugins/maven/MavenProjectConverter.java b/plugins/sonar-maven-batch-plugin/src/main/java/org/sonar/plugins/maven/MavenProjectConverter.java index ad7ad3bb664..3b877f3d479 100644 --- a/plugins/sonar-maven-batch-plugin/src/main/java/org/sonar/plugins/maven/MavenProjectConverter.java +++ b/plugins/sonar-maven-batch-plugin/src/main/java/org/sonar/plugins/maven/MavenProjectConverter.java @@ -60,7 +60,7 @@ public class MavenProjectConverter implements TaskExtension { rebuildModuleHierarchy(paths, defs); } catch (IOException e) { - throw new SonarException(e); + throw new SonarException("Cannot configure project", e); } ProjectDefinition rootProject = defs.get(root); diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/JdkUtils.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/JdkUtils.java index 90aff336e9c..2237aa96663 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/JdkUtils.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/JdkUtils.java @@ -47,7 +47,7 @@ public final class JdkUtils extends WSUtils { return URLEncoder.encode(url, "UTF-8"); } catch (UnsupportedEncodingException e) { - throw new IllegalStateException(e); + throw new IllegalStateException("Encoding not supported", e); } }