diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2015-01-23 15:50:17 +0100 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2015-01-23 15:50:17 +0100 |
commit | 51b8c91b138aab690921e647e30deabbaf61e75b (patch) | |
tree | 7295f35a5068aa7f9640e32f431c771a6ab1f613 | |
parent | fa8406f747589de519a6ba1c75e1e8ee64365b52 (diff) | |
download | sonarqube-51b8c91b138aab690921e647e30deabbaf61e75b.tar.gz sonarqube-51b8c91b138aab690921e647e30deabbaf61e75b.zip |
Fix quality flaws
6 files changed, 38 insertions, 5 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/duplication/ws/DuplicationsParser.java b/server/sonar-server/src/main/java/org/sonar/server/duplication/ws/DuplicationsParser.java index 26721ddb5a6..4b6cd2f96b2 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/duplication/ws/DuplicationsParser.java +++ b/server/sonar-server/src/main/java/org/sonar/server/duplication/ws/DuplicationsParser.java @@ -35,6 +35,7 @@ import javax.annotation.Nullable; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamException; +import java.io.Serializable; import java.io.StringReader; import java.util.Collections; import java.util.Comparator; @@ -103,7 +104,7 @@ public class DuplicationsParser implements ServerComponent { } @VisibleForTesting - static class DuplicationComparator implements Comparator<Duplication> { + static class DuplicationComparator implements Comparator<Duplication>, Serializable { private static final long serialVersionUID = 1; private final ComponentDto component; @@ -146,7 +147,7 @@ public class DuplicationsParser implements ServerComponent { } } - private static class BlockComparator implements Comparator<Block> { + private static class BlockComparator implements Comparator<Block>, Serializable { private static final long serialVersionUID = 1; @Override diff --git a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/ActiveRule.java b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/ActiveRule.java index 4fda09f8910..d9bf2e3bea7 100644 --- a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/ActiveRule.java +++ b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/ActiveRule.java @@ -30,7 +30,7 @@ public class ActiveRule { private final String name, severity, internalKey, language; private final Map<String, String> params = new HashMap<String, String>(); - public ActiveRule(String repositoryKey, String ruleKey, String name, String severity, @Nullable String internalKey, String language) { + public ActiveRule(String repositoryKey, String ruleKey, String name, @Nullable String severity, @Nullable String internalKey, @Nullable String language) { this.repositoryKey = repositoryKey; this.ruleKey = ruleKey; this.name = name; @@ -51,10 +51,18 @@ public class ActiveRule { return name; } + /** + * Is null on manual rules + */ + @CheckForNull public String severity() { return severity; } + /** + * Is null on manual rules + */ + @CheckForNull public String language() { return language; } diff --git a/sonar-core/src/main/java/org/sonar/core/user/AuthorDao.java b/sonar-core/src/main/java/org/sonar/core/user/AuthorDao.java index 24f5d440de3..224d7201cb3 100644 --- a/sonar-core/src/main/java/org/sonar/core/user/AuthorDao.java +++ b/sonar-core/src/main/java/org/sonar/core/user/AuthorDao.java @@ -19,6 +19,7 @@ */ package org.sonar.core.user; +import com.google.common.base.Strings; import org.apache.ibatis.session.SqlSession; import org.sonar.api.BatchComponent; import org.sonar.api.ServerComponent; @@ -78,7 +79,7 @@ public class AuthorDao implements BatchComponent, ServerComponent { SqlSession session = mybatis.openSession(false); try { // Hack in order to set "." on DEV - if (resourceDto.getModuleUuidPath() == null || resourceDto.getModuleUuidPath().isEmpty()) { + if (Strings.isNullOrEmpty(resourceDto.getModuleUuidPath())) { resourceDto.setModuleUuidPath(ComponentDto.MODULE_UUID_PATH_SEP); } resourceDao.insertUsingExistingSession(resourceDto, session); diff --git a/sonar-core/src/test/java/org/sonar/core/user/AuthorDaoTest.java b/sonar-core/src/test/java/org/sonar/core/user/AuthorDaoTest.java index a8296eebebe..8b547471fe2 100644 --- a/sonar-core/src/test/java/org/sonar/core/user/AuthorDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/user/AuthorDaoTest.java @@ -72,7 +72,7 @@ public class AuthorDaoTest extends AbstractDaoTestCase { setupData("shouldInsertAuthorAndDeveloper"); String login = "developer@company.net"; - ResourceDto resourceDto = new ResourceDto().setName(login).setQualifier("DEV").setUuid("ABCD").setProjectUuid("ABCD"); + ResourceDto resourceDto = new ResourceDto().setName(login).setQualifier("DEV").setUuid("ABCD").setProjectUuid("ABCD").setModuleUuidPath("."); dao.insertAuthorAndDeveloper(login, resourceDto); checkTables("shouldInsertAuthorAndDeveloper", @@ -82,6 +82,20 @@ public class AuthorDaoTest extends AbstractDaoTestCase { } @Test + public void add_missing_module_uuid_path() throws Exception { + setupData("add_missing_module_uuid_path"); + + dao.insertAuthorAndDeveloper("developer@company.net", new ResourceDto().setName("developer@company.net").setQualifier("DEV").setUuid("ABCD").setProjectUuid("ABCD") + .setModuleUuidPath("")); + dao.insertAuthorAndDeveloper("developer2@company.net", new ResourceDto().setName("developer2@company.net").setQualifier("DEV").setUuid("BCDE").setProjectUuid("BCDE")); + + checkTables("add_missing_module_uuid_path", + new String[] {"created_at", "updated_at", "copy_resource_id", "description", "enabled", "kee", "deprecated_kee", "path", "language", "long_name", "person_id", "root_id", + "scope", "authorization_updated_at"}, + "authors", "projects"); + } + + @Test public void shouldPreventAuthorsDuplication() { setupData("shouldPreventAuthorsDuplication"); diff --git a/sonar-core/src/test/resources/org/sonar/core/user/AuthorDaoTest/add_missing_module_uuid_path-result.xml b/sonar-core/src/test/resources/org/sonar/core/user/AuthorDaoTest/add_missing_module_uuid_path-result.xml new file mode 100644 index 00000000000..b8737c88118 --- /dev/null +++ b/sonar-core/src/test/resources/org/sonar/core/user/AuthorDaoTest/add_missing_module_uuid_path-result.xml @@ -0,0 +1,7 @@ +<dataset> + <projects id="1" name="developer@company.net" qualifier="DEV" uuid="ABCD" project_uuid="ABCD" module_uuid="[null]" module_uuid_path="."/> + <authors id="1" person_id="1" login="developer@company.net"/> + + <projects id="2" name="developer2@company.net" qualifier="DEV" uuid="BCDE" project_uuid="BCDE" module_uuid="[null]" module_uuid_path="."/> + <authors id="2" person_id="2" login="developer2@company.net"/> +</dataset> diff --git a/sonar-core/src/test/resources/org/sonar/core/user/AuthorDaoTest/add_missing_module_uuid_path.xml b/sonar-core/src/test/resources/org/sonar/core/user/AuthorDaoTest/add_missing_module_uuid_path.xml new file mode 100644 index 00000000000..fb0854fccbe --- /dev/null +++ b/sonar-core/src/test/resources/org/sonar/core/user/AuthorDaoTest/add_missing_module_uuid_path.xml @@ -0,0 +1,2 @@ +<dataset> +</dataset> |