aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-db/src/main/java/org/sonar
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2016-12-14 12:06:19 +0100
committerSimon Brandhof <simon.brandhof@sonarsource.com>2016-12-14 12:06:19 +0100
commit6267731ef43726692de95b9eea1f18312f288d17 (patch)
tree75a989e875cef3a7dc0ae9573fcbe199580245d8 /sonar-db/src/main/java/org/sonar
parent10ae35e46bd3deeb5a4d974b31ca606108bc2f50 (diff)
downloadsonarqube-6267731ef43726692de95b9eea1f18312f288d17.tar.gz
sonarqube-6267731ef43726692de95b9eea1f18312f288d17.zip
Fix some Quality flaws
Signed-off-by: Simon Brandhof <simon.brandhof@sonarsource.com>
Diffstat (limited to 'sonar-db/src/main/java/org/sonar')
-rw-r--r--sonar-db/src/main/java/org/sonar/db/version/v56/PopulateInitialSchema.java13
-rw-r--r--sonar-db/src/main/java/org/sonar/db/version/v60/MakeAnalysisUuidNotNullOnEvents.java7
-rw-r--r--sonar-db/src/main/java/org/sonar/db/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex.java13
-rw-r--r--sonar-db/src/main/java/org/sonar/db/version/v60/MakeComponentUuidColumnsNotNullOnSnapshots.java13
-rw-r--r--sonar-db/src/main/java/org/sonar/db/version/v60/MakeUuidColumnsNotNullOnResourceIndex.java13
5 files changed, 47 insertions, 12 deletions
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v56/PopulateInitialSchema.java b/sonar-db/src/main/java/org/sonar/db/version/v56/PopulateInitialSchema.java
index 70a18b20198..491db800cbb 100644
--- a/sonar-db/src/main/java/org/sonar/db/version/v56/PopulateInitialSchema.java
+++ b/sonar-db/src/main/java/org/sonar/db/version/v56/PopulateInitialSchema.java
@@ -66,7 +66,7 @@ public class PopulateInitialSchema extends BaseDataChange {
.commit();
}
- private void insertGroupRoles(Context context) throws SQLException {
+ private static void insertGroupRoles(Context context) throws SQLException {
truncateTable(context, "group_roles");
// admin group
@@ -92,8 +92,10 @@ public class PopulateInitialSchema extends BaseDataChange {
long now = system2.now();
context.prepareUpsert("insert into users " +
- "(login, name, email, external_identity, external_identity_provider, user_local, crypted_password, salt, created_at, updated_at, remember_token, remember_token_expires_at) " +
- "values ('" + ADMIN_USER + "', 'Administrator', '', 'admin', 'sonarqube', ?, 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', ?, ?, null, null)")
+ "(login, name, email, external_identity, external_identity_provider, user_local, crypted_password, salt, " +
+ "created_at, updated_at, remember_token, remember_token_expires_at) " +
+ "values ('" + ADMIN_USER + "', 'Administrator', '', 'admin', 'sonarqube', ?, " +
+ "'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', ?, ?, null, null)")
.setBoolean(1, true)
.setLong(2, now)
.setLong(3, now)
@@ -101,10 +103,11 @@ public class PopulateInitialSchema extends BaseDataChange {
.commit();
}
- private void insertGroupMemberships(Context context) throws SQLException {
+ private static void insertGroupMemberships(Context context) throws SQLException {
truncateTable(context, "groups_users");
- context.prepareUpsert("insert into groups_users (user_id, group_id) values ((select id from users where login='" + ADMIN_USER + "'), (select id from groups where name=?))")
+ context.prepareUpsert("insert into groups_users (user_id, group_id) values " +
+ "((select id from users where login='" + ADMIN_USER + "'), (select id from groups where name=?))")
.setString(1, ADMINS_GROUP).addBatch()
.setString(1, USERS_GROUP).addBatch()
.execute()
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/MakeAnalysisUuidNotNullOnEvents.java b/sonar-db/src/main/java/org/sonar/db/version/v60/MakeAnalysisUuidNotNullOnEvents.java
index 1cd74d96dc3..72edcd459d9 100644
--- a/sonar-db/src/main/java/org/sonar/db/version/v60/MakeAnalysisUuidNotNullOnEvents.java
+++ b/sonar-db/src/main/java/org/sonar/db/version/v60/MakeAnalysisUuidNotNullOnEvents.java
@@ -39,7 +39,12 @@ public class MakeAnalysisUuidNotNullOnEvents extends DdlChange {
@Override
public void execute(Context context) throws SQLException {
- VarcharColumnDef analysisUuidColumn = newVarcharColumnDefBuilder().setColumnName("analysis_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).setIgnoreOracleUnit(true).build();
+ VarcharColumnDef analysisUuidColumn = newVarcharColumnDefBuilder()
+ .setColumnName("analysis_uuid")
+ .setLimit(UUID_VARCHAR_SIZE)
+ .setIsNullable(false)
+ .setIgnoreOracleUnit(true)
+ .build();
context.execute(new AlterColumnsBuilder(getDatabase().getDialect(), TABLE_EVENTS)
.updateColumn(analysisUuidColumn)
.build());
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex.java b/sonar-db/src/main/java/org/sonar/db/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex.java
index 031f061dbd7..524e312ddd1 100644
--- a/sonar-db/src/main/java/org/sonar/db/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex.java
+++ b/sonar-db/src/main/java/org/sonar/db/version/v60/MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex.java
@@ -39,8 +39,8 @@ public class MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex extends
@Override
public void execute(Context context) throws SQLException {
- VarcharColumnDef analysisUuid = newVarcharColumnDefBuilder().setColumnName("analysis_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).setIgnoreOracleUnit(true).build();
- VarcharColumnDef componentUuid = newVarcharColumnDefBuilder().setColumnName("component_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).setIgnoreOracleUnit(true).build();
+ VarcharColumnDef analysisUuid = newUuidColumn("analysis_uuid");
+ VarcharColumnDef componentUuid = newUuidColumn("component_uuid");
context.execute(new AlterColumnsBuilder(getDatabase().getDialect(), TABLE_DUPLICATIONS_INDEX)
.updateColumn(componentUuid)
.updateColumn(analysisUuid)
@@ -54,4 +54,13 @@ public class MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex extends
.build());
}
+ private static VarcharColumnDef newUuidColumn(String columnName) {
+ return newVarcharColumnDefBuilder()
+ .setColumnName(columnName)
+ .setLimit(UUID_VARCHAR_SIZE)
+ .setIsNullable(false)
+ .setIgnoreOracleUnit(true)
+ .build();
+ }
+
}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/MakeComponentUuidColumnsNotNullOnSnapshots.java b/sonar-db/src/main/java/org/sonar/db/version/v60/MakeComponentUuidColumnsNotNullOnSnapshots.java
index 14d410ad400..64b86a884cf 100644
--- a/sonar-db/src/main/java/org/sonar/db/version/v60/MakeComponentUuidColumnsNotNullOnSnapshots.java
+++ b/sonar-db/src/main/java/org/sonar/db/version/v60/MakeComponentUuidColumnsNotNullOnSnapshots.java
@@ -39,8 +39,8 @@ public class MakeComponentUuidColumnsNotNullOnSnapshots extends DdlChange {
@Override
public void execute(Context context) throws SQLException {
- VarcharColumnDef componentUuid = newVarcharColumnDefBuilder().setColumnName("component_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).setIgnoreOracleUnit(true).build();
- VarcharColumnDef rootComponentUuid = newVarcharColumnDefBuilder().setColumnName("root_component_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).setIgnoreOracleUnit(true).build();
+ VarcharColumnDef componentUuid = newUuidColumn("component_uuid");
+ VarcharColumnDef rootComponentUuid = newUuidColumn("root_component_uuid");
context.execute(new AlterColumnsBuilder(getDatabase().getDialect(), TABLE_SNAPSHOTS)
.updateColumn(componentUuid)
.updateColumn(rootComponentUuid)
@@ -58,4 +58,13 @@ public class MakeComponentUuidColumnsNotNullOnSnapshots extends DdlChange {
.build());
}
+ private static VarcharColumnDef newUuidColumn(String columnName) {
+ return newVarcharColumnDefBuilder()
+ .setColumnName(columnName)
+ .setLimit(UUID_VARCHAR_SIZE)
+ .setIsNullable(false)
+ .setIgnoreOracleUnit(true)
+ .build();
+ }
+
}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/MakeUuidColumnsNotNullOnResourceIndex.java b/sonar-db/src/main/java/org/sonar/db/version/v60/MakeUuidColumnsNotNullOnResourceIndex.java
index d5705668828..77c6245a358 100644
--- a/sonar-db/src/main/java/org/sonar/db/version/v60/MakeUuidColumnsNotNullOnResourceIndex.java
+++ b/sonar-db/src/main/java/org/sonar/db/version/v60/MakeUuidColumnsNotNullOnResourceIndex.java
@@ -39,10 +39,10 @@ public class MakeUuidColumnsNotNullOnResourceIndex extends DdlChange {
@Override
public void execute(Context context) throws SQLException {
- VarcharColumnDef componentUuid = newVarcharColumnDefBuilder().setColumnName("component_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).setIgnoreOracleUnit(true).build();
+ VarcharColumnDef componentUuid = newUuidColumn("component_uuid");
context.execute(new AlterColumnsBuilder(getDialect(), TABLE_RESOURCE_INDEX)
.updateColumn(componentUuid)
- .updateColumn(newVarcharColumnDefBuilder().setColumnName("root_component_uuid").setLimit(UUID_VARCHAR_SIZE).setIsNullable(false).setIgnoreOracleUnit(true).build())
+ .updateColumn(newUuidColumn("root_component_uuid"))
.build());
context.execute(new CreateIndexBuilder(getDialect())
@@ -52,4 +52,13 @@ public class MakeUuidColumnsNotNullOnResourceIndex extends DdlChange {
.build());
}
+ private static VarcharColumnDef newUuidColumn(String columnName) {
+ return newVarcharColumnDefBuilder()
+ .setColumnName(columnName)
+ .setLimit(UUID_VARCHAR_SIZE)
+ .setIsNullable(false)
+ .setIgnoreOracleUnit(true)
+ .build();
+ }
+
}