diff options
author | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2017-07-12 16:20:52 +0200 |
---|---|---|
committer | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2017-07-12 17:47:43 +0200 |
commit | 5dbc2d97361f2425816402a9ee0519b914833141 (patch) | |
tree | ac526afad1167092cfb9e01ad1677a3b290dfaf1 /server | |
parent | 7685a10da73247cf3e6bcbc5989523856e2293ab (diff) | |
download | sonarqube-5dbc2d97361f2425816402a9ee0519b914833141.tar.gz sonarqube-5dbc2d97361f2425816402a9ee0519b914833141.zip |
fix quality flaws
Diffstat (limited to 'server')
4 files changed, 12 insertions, 8 deletions
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/DropColumnsBuilder.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/DropColumnsBuilder.java index dce0c61fb8c..4680aff0dd7 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/DropColumnsBuilder.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/DropColumnsBuilder.java @@ -36,6 +36,8 @@ import org.sonar.db.dialect.PostgreSql; */ public class DropColumnsBuilder { + private static final String ALTER_TABLE = "ALTER TABLE "; + private final Dialect dialect; private final String tableName; private final String[] columns; @@ -50,7 +52,7 @@ public class DropColumnsBuilder { switch (dialect.getId()) { case PostgreSql.ID: case MySql.ID: - StringBuilder sql = new StringBuilder().append("ALTER TABLE ").append(tableName).append(" "); + StringBuilder sql = new StringBuilder().append(ALTER_TABLE).append(tableName).append(" "); dropColumns(sql, "DROP COLUMN ", columns); return Collections.singletonList(sql.toString()); case MsSql.ID: @@ -65,7 +67,7 @@ public class DropColumnsBuilder { } private String getOracleStatement() { - StringBuilder sql2 = new StringBuilder().append("ALTER TABLE ").append(tableName).append(" "); + StringBuilder sql2 = new StringBuilder().append(ALTER_TABLE).append(tableName).append(" "); sql2.append("DROP ("); dropColumns(sql2, "", columns); sql2.append(")"); @@ -73,7 +75,7 @@ public class DropColumnsBuilder { } private String getMsSQLStatement(String... columnNames) { - StringBuilder sql1 = new StringBuilder().append("ALTER TABLE ").append(tableName).append(" "); + StringBuilder sql1 = new StringBuilder().append(ALTER_TABLE).append(tableName).append(" "); sql1.append("DROP COLUMN "); dropColumns(sql1, "", columnNames); return sql1.toString(); diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/ws/UpgradesAction.java b/server/sonar-server/src/main/java/org/sonar/server/platform/ws/UpgradesAction.java index 4dda292d8b1..9d905ba5d63 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/ws/UpgradesAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/ws/UpgradesAction.java @@ -85,11 +85,13 @@ public class UpgradesAction implements SystemWsAction { @Override public void handle(Request request, Response response) throws Exception { - JsonWriter jsonWriter = response.newJsonWriter().setSerializeEmptys(false); + try (JsonWriter jsonWriter = response.newJsonWriter()) { + jsonWriter.setSerializeEmptys(false); - writeResponse(jsonWriter); + writeResponse(jsonWriter); - jsonWriter.close(); + jsonWriter.close(); + } } private void writeResponse(JsonWriter jsonWriter) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/CachingRuleFinder.java b/server/sonar-server/src/main/java/org/sonar/server/rule/CachingRuleFinder.java index ff11d30b20c..f4a5555f8ff 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/CachingRuleFinder.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/CachingRuleFinder.java @@ -162,7 +162,7 @@ public class CachingRuleFinder implements RuleFinder { String description = ruleDefinition.getDescription(); RuleDto.Format descriptionFormat = ruleDefinition.getDescriptionFormat(); - org.sonar.api.rules.Rule apiRule = new org.sonar.api.rules.Rule(); + Rule apiRule = new Rule(); apiRule .setName(ruleDefinition.getName()) .setLanguage(ruleDefinition.getLanguage()) diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/WebServerRuleFinderImpl.java b/server/sonar-server/src/main/java/org/sonar/server/rule/WebServerRuleFinderImpl.java index 72b4e4dfc50..b5a91ce01e0 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/rule/WebServerRuleFinderImpl.java +++ b/server/sonar-server/src/main/java/org/sonar/server/rule/WebServerRuleFinderImpl.java @@ -54,7 +54,7 @@ public class WebServerRuleFinderImpl implements WebServerRuleFinder { @Override @CheckForNull @Deprecated - public org.sonar.api.rules.Rule findById(int ruleId) { + public Rule findById(int ruleId) { return delegate.findById(ruleId); } |