aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2014-12-19 11:41:22 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2014-12-19 11:41:29 +0100
commit1be6148ae4371650449a905d2237fa6abee8e1f5 (patch)
tree29fe1690594d1f49a404285cdb22782bb1d010d6
parent4742f1a30dfa08e9cc30b793c310bb693ce14e44 (diff)
downloadsonarqube-1be6148ae4371650449a905d2237fa6abee8e1f5.tar.gz
sonarqube-1be6148ae4371650449a905d2237fa6abee8e1f5.zip
Fix quality flaws
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/issue/IssueQueryService.java27
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/user/DefaultUserService.java4
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/user/UserService.java1
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/user/UserUpdater.java6
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/user/index/UserResultSetIterator.java2
-rw-r--r--sonar-duplications/src/main/java/net/sourceforge/pmd/cpd/package-info.java30
6 files changed, 46 insertions, 24 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/IssueQueryService.java b/server/sonar-server/src/main/java/org/sonar/server/issue/IssueQueryService.java
index 2b1648a4423..e3759cdf7a1 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/issue/IssueQueryService.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/issue/IssueQueryService.java
@@ -20,20 +20,18 @@
package org.sonar.server.issue;
-import com.google.common.collect.Lists;
-
-import org.sonar.server.component.ComponentService;
-import org.apache.commons.lang.ObjectUtils;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import org.apache.commons.lang.ObjectUtils;
import org.sonar.api.ServerComponent;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.server.ws.Request;
-import org.sonar.core.component.ComponentDto;
import org.sonar.core.persistence.DbSession;
+import org.sonar.server.component.ComponentService;
import org.sonar.server.db.DbClient;
import org.sonar.server.issue.filter.IssueFilterParameters;
import org.sonar.server.search.ws.SearchRequestHandler;
@@ -88,32 +86,29 @@ public class IssueQueryService implements ServerComponent {
ObjectUtils.defaultIfNull(
params.get(IssueFilterParameters.PROJECT_KEYS),
params.get(IssueFilterParameters.PROJECTS)
- )
- )
- );
+ )
+ ));
addComponentUuids(builder, session,
RubyUtils.toStrings(params.get(IssueFilterParameters.COMPONENT_UUIDS)),
RubyUtils.toStrings(
ObjectUtils.defaultIfNull(
params.get(IssueFilterParameters.COMPONENT_KEYS),
params.get(IssueFilterParameters.COMPONENTS)
- )
- )
- );
+ )
+ ));
addComponentRootUuids(builder, session,
RubyUtils.toStrings(
ObjectUtils.defaultIfNull(
params.get(IssueFilterParameters.MODULE_UUIDS),
params.get(IssueFilterParameters.COMPONENT_ROOT_UUIDS)
- )
- ),
+ )
+ ),
RubyUtils.toStrings(
ObjectUtils.defaultIfNull(
params.get(IssueFilterParameters.MODULE_KEYS),
params.get(IssueFilterParameters.COMPONENT_ROOTS)
- )
- )
- );
+ )
+ ));
String sort = (String) params.get(IssueFilterParameters.SORT);
if (!Strings.isNullOrEmpty(sort)) {
builder.sort(sort);
diff --git a/server/sonar-server/src/main/java/org/sonar/server/user/DefaultUserService.java b/server/sonar-server/src/main/java/org/sonar/server/user/DefaultUserService.java
index 9bd6465ebf6..354fbd0dab0 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/user/DefaultUserService.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/user/DefaultUserService.java
@@ -80,7 +80,7 @@ public class DefaultUserService implements RubyUserService {
.setLogin((String) params.get("login"))
.setName((String) params.get("name"))
.setEmail((String) params.get("email"))
- .setScmAccounts((RubyUtils.toStrings(params.get("scm_accounts"))))
+ .setScmAccounts(RubyUtils.toStrings(params.get("scm_accounts")))
.setPassword((String) params.get("password"))
.setPasswordConfirmation((String) params.get("password_confirmation"));
return userService.create(newUser);
@@ -95,7 +95,7 @@ public class DefaultUserService implements RubyUserService {
updateUser.setEmail((String) params.get("email"));
}
if (params.containsKey("scm_accounts")) {
- updateUser.setScmAccounts((RubyUtils.toStrings(params.get("scm_accounts"))));
+ updateUser.setScmAccounts(RubyUtils.toStrings(params.get("scm_accounts")));
}
if (params.containsKey("password")) {
updateUser.setPassword((String) params.get("password"));
diff --git a/server/sonar-server/src/main/java/org/sonar/server/user/UserService.java b/server/sonar-server/src/main/java/org/sonar/server/user/UserService.java
index 1adfc5bb511..e69d8c3e0d2 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/user/UserService.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/user/UserService.java
@@ -53,7 +53,6 @@ public class UserService implements ServerComponent {
userIndexer.index();
}
- @CheckForNull
public UserDoc getByLogin(String login) {
return userIndex.getByLogin(login);
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/user/UserUpdater.java b/server/sonar-server/src/main/java/org/sonar/server/user/UserUpdater.java
index 48bf1c9864d..77aaf0a3200 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/user/UserUpdater.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/user/UserUpdater.java
@@ -217,10 +217,8 @@ public class UserUpdater implements ServerComponent {
}
private static void validateEmailFormat(@Nullable String email, List<Message> messages) {
- if (email != null) {
- if (email.length() >= 100) {
- messages.add(Message.of(Validation.IS_TOO_LONG_MESSAGE, EMAIL_PARAM, 100));
- }
+ if (email != null && email.length() >= 100) {
+ messages.add(Message.of(Validation.IS_TOO_LONG_MESSAGE, EMAIL_PARAM, 100));
}
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/user/index/UserResultSetIterator.java b/server/sonar-server/src/main/java/org/sonar/server/user/index/UserResultSetIterator.java
index 352607553c6..7d8b4525699 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/user/index/UserResultSetIterator.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/user/index/UserResultSetIterator.java
@@ -111,7 +111,7 @@ class UserResultSetIterator extends ResultSetIterator<UserDoc> {
}
return result;
} catch (IOException e) {
- throw new IllegalStateException(String.format("Fail to read scm accounts for user '%s'", login));
+ throw new IllegalStateException(String.format("Fail to read scm accounts for user '%s'", login), e);
} finally {
IOUtils.closeQuietly(reader);
IOUtils.closeQuietly(csvParser);
diff --git a/sonar-duplications/src/main/java/net/sourceforge/pmd/cpd/package-info.java b/sonar-duplications/src/main/java/net/sourceforge/pmd/cpd/package-info.java
new file mode 100644
index 00000000000..d69063023a4
--- /dev/null
+++ b/sonar-duplications/src/main/java/net/sourceforge/pmd/cpd/package-info.java
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+/**
+ * Provides a basic framework to sequentially read any kind of character stream and create list of tokens.
+ *
+ * The entry point of this framework is the {@link org.sonar.duplications.token.TokenChunker} class.
+ */
+@ParametersAreNonnullByDefault
+package net.sourceforge.pmd.cpd;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+