aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2014-07-01 17:45:56 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2014-07-01 17:46:04 +0200
commitb34de6cbb17ae0f15c5ddc19573e0c8704ac564c (patch)
tree19c3a56918d9f7fcffe5dcc1afc60292a8d7d062
parent0fa2a818b9614e4cd555a4816622e2f4ef45d16d (diff)
downloadsonarqube-b34de6cbb17ae0f15c5ddc19573e0c8704ac564c.tar.gz
sonarqube-b34de6cbb17ae0f15c5ddc19573e0c8704ac564c.zip
Fix quality flaws
-rw-r--r--sonar-application/src/main/java/org/sonar/application/StartServer.java3
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapter.java1
-rw-r--r--sonar-core/src/main/java/org/sonar/core/rule/CacheRuleFinder.java16
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/utils/PathUtilsTest.java2
-rw-r--r--sonar-server/src/main/java/org/sonar/server/issue/IssueService.java1
-rw-r--r--sonar-server/src/main/java/org/sonar/server/rule/DefaultRuleFinder.java5
6 files changed, 7 insertions, 21 deletions
diff --git a/sonar-application/src/main/java/org/sonar/application/StartServer.java b/sonar-application/src/main/java/org/sonar/application/StartServer.java
index 0d1c8ef5093..dd51a5247c4 100644
--- a/sonar-application/src/main/java/org/sonar/application/StartServer.java
+++ b/sonar-application/src/main/java/org/sonar/application/StartServer.java
@@ -22,7 +22,6 @@ package org.sonar.application;
import org.apache.catalina.LifecycleException;
import java.io.IOException;
-import java.net.URISyntaxException;
public final class StartServer {
@@ -46,7 +45,7 @@ public final class StartServer {
tomcat.stop();
}
- public static void main(String[] args) throws URISyntaxException, IOException, LifecycleException {
+ public static void main(String[] args) throws Exception {
new StartServer(new Env()).start();
}
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapter.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapter.java
index c42c1d75fac..ba0fe388bca 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapter.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapter.java
@@ -56,7 +56,6 @@ public class ProjectFileSystemAdapter implements ProjectFileSystem {
this.target = target;
this.pom = pom;
- // TODO See http://jira.codehaus.org/browse/SONAR-2126
// previously MavenProjectBuilder was responsible for creation of ProjectFileSystem
project.setFileSystem(this);
}
diff --git a/sonar-core/src/main/java/org/sonar/core/rule/CacheRuleFinder.java b/sonar-core/src/main/java/org/sonar/core/rule/CacheRuleFinder.java
index 8747055a4ee..76a59f8ea80 100644
--- a/sonar-core/src/main/java/org/sonar/core/rule/CacheRuleFinder.java
+++ b/sonar-core/src/main/java/org/sonar/core/rule/CacheRuleFinder.java
@@ -90,29 +90,19 @@ public final class CacheRuleFinder implements RuleFinder {
}
+ @Override
@CheckForNull
public Rule findByKey(RuleKey key) {
return findByKey(key.repository(), key.rule());
}
-
- @CheckForNull
- protected final Rule doFindByKey(String repositoryKey, String key) {
- DatabaseSession session = sessionFactory.getSession();
- return session.getSingleResult(
- session.createQuery("FROM " + Rule.class.getSimpleName() + " r WHERE r.key=:key and r.pluginName=:pluginName and r.status<>:status")
- .setParameter("key", key)
- .setParameter("pluginName", repositoryKey)
- .setParameter("status", Rule.STATUS_REMOVED
- ),
- null);
- }
-
+ @Override
public final Rule find(RuleQuery query) {
DatabaseSession session = sessionFactory.getSession();
return session.getSingleResult(createHqlQuery(session, query), null);
}
+ @Override
public final Collection<Rule> findAll(RuleQuery query) {
DatabaseSession session = sessionFactory.getSession();
return createHqlQuery(session, query).getResultList();
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/PathUtilsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/PathUtilsTest.java
index 4ffd592d5ac..57a75e2437e 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/PathUtilsTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/PathUtilsTest.java
@@ -26,7 +26,6 @@ import org.junit.rules.TemporaryFolder;
import java.io.File;
import java.io.IOException;
-import java.lang.reflect.Method;
import static org.fest.assertions.Assertions.assertThat;
import static org.fest.assertions.Fail.fail;
@@ -65,6 +64,7 @@ public class PathUtilsTest {
File file = temp.newFile();
String path = PathUtils.canonicalPath(file);
assertThat(path).isEqualTo(FilenameUtils.separatorsToUnix(file.getCanonicalPath()));
+ assertThat(PathUtils.canonicalPath(null)).isNull();
}
@Test
diff --git a/sonar-server/src/main/java/org/sonar/server/issue/IssueService.java b/sonar-server/src/main/java/org/sonar/server/issue/IssueService.java
index 3d2dded5fbf..f1bba567579 100644
--- a/sonar-server/src/main/java/org/sonar/server/issue/IssueService.java
+++ b/sonar-server/src/main/java/org/sonar/server/issue/IssueService.java
@@ -121,7 +121,6 @@ public class IssueService implements ServerComponent {
* Never return null, but an empty list if the issue does not exist.
* No security check is done since it should already have been done to get the issue
*/
- // TODO remove userSession parameter ?
public List<Transition> listTransitions(@Nullable Issue issue, UserSession userSession) {
if (issue == null) {
return Collections.emptyList();
diff --git a/sonar-server/src/main/java/org/sonar/server/rule/DefaultRuleFinder.java b/sonar-server/src/main/java/org/sonar/server/rule/DefaultRuleFinder.java
index 4939964bf25..ddcd033de8d 100644
--- a/sonar-server/src/main/java/org/sonar/server/rule/DefaultRuleFinder.java
+++ b/sonar-server/src/main/java/org/sonar/server/rule/DefaultRuleFinder.java
@@ -53,11 +53,10 @@ public class DefaultRuleFinder implements RuleFinder {
@CheckForNull
public org.sonar.api.rules.Rule findById(int ruleId) {
Rule rule = index.getById(ruleId);
- if (rule.status() != RuleStatus.REMOVED) {
+ if (rule != null && rule.status() != RuleStatus.REMOVED) {
return toRule(rule);
- } else {
- return null;
}
+ return null;
}
@CheckForNull