]> source.dussan.org Git - sonarqube.git/commitdiff
fix quality flaws 2244/head
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Wed, 12 Jul 2017 14:20:52 +0000 (16:20 +0200)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Wed, 12 Jul 2017 15:47:43 +0000 (17:47 +0200)
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/DropColumnsBuilder.java
server/sonar-server/src/main/java/org/sonar/server/platform/ws/UpgradesAction.java
server/sonar-server/src/main/java/org/sonar/server/rule/CachingRuleFinder.java
server/sonar-server/src/main/java/org/sonar/server/rule/WebServerRuleFinderImpl.java

index dce0c61fb8cb52fb172f34bc91cb1e2ec56593b7..4680aff0dd7cae8d3812bb148df58d782071593a 100644 (file)
@@ -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();
index 4dda292d8b1e82f0e6aaa9a7a1f9b851446f5b8b..9d905ba5d6347b7cd070ef637c987144a10318e9 100644 (file)
@@ -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) {
index ff11d30b20c9ae42ef8bf65d98a7a32c9f401660..f4a5555f8ffa2b9ca9f40e2c80af68ba7494c410 100644 (file)
@@ -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())
index 72b4e4dfc50ee86d920ea46503ff9a51b3e3c45a..b5a91ce01e079707cce47697de9f9c581f1b0be8 100644 (file)
@@ -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);
   }