]> source.dussan.org Git - sonarqube.git/commitdiff
Fix quality flaws
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 22 Sep 2015 08:51:50 +0000 (10:51 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 22 Sep 2015 08:51:50 +0000 (10:51 +0200)
server/sonar-server/src/main/java/org/sonar/server/computation/ReportFiles.java
server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndex.java
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleNormalizer.java
sonar-db/src/main/java/org/sonar/db/component/ResourceIndexDao.java

index 43067b71fee55982e2bc17f5549dcd9876d30acb..3aae2baac91330d33358a17f577e478e3e69cdb8 100644 (file)
@@ -33,7 +33,6 @@ import org.sonar.process.ProcessProperties;
 
 import static java.lang.String.format;
 
-// TODO deal with temporary unzipped files
 @ServerSide
 public class ReportFiles {
 
index df21cfbb5fa0d27fe5cfdb05645be388c158d491..07651b46cb3d86d9e4167dec7f892364eb911979 100644 (file)
@@ -476,7 +476,7 @@ public class IssueIndex extends BaseIndex {
       .interval(bucketSize)
       .minDocCount(0L)
       .format(DateUtils.DATETIME_FORMAT)
-      .preZone(timeZoneString)
+      .timeZone(timeZoneString)
       .postZone(timeZoneString)
       .extendedBounds(startTime, endTime);
     dateHistogram = addDebtAggregationIfNeeded(query, dateHistogram);
index 29f282aff75aee3369da298f44af6e2dedf1000d..f09b2a33916be629216501d77b1606e8d87a07b0 100644 (file)
@@ -22,7 +22,11 @@ package org.sonar.server.qualityprofile.index;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
-import org.elasticsearch.action.support.replication.ReplicationType;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import org.elasticsearch.action.update.UpdateRequest;
 import org.sonar.db.DbSession;
 import org.sonar.db.qualityprofile.ActiveRuleDto;
@@ -36,12 +40,6 @@ import org.sonar.server.search.BaseNormalizer;
 import org.sonar.server.search.IndexField;
 import org.sonar.server.search.Indexable;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
 public class ActiveRuleNormalizer extends BaseNormalizer<ActiveRuleDto, ActiveRuleKey> {
 
   public static class ActiveRuleField extends Indexable {
@@ -114,7 +112,6 @@ public class ActiveRuleNormalizer extends BaseNormalizer<ActiveRuleDto, ActiveRu
 
       /* Creating updateRequest */
       requests.add(new UpdateRequest()
-        .replicationType(ReplicationType.ASYNC)
         .routing(key.ruleKey().toString())
         .id(activeRuleDto.getKey().toString())
         .parent(activeRuleDto.getKey().ruleKey().toString())
@@ -136,7 +133,7 @@ public class ActiveRuleNormalizer extends BaseNormalizer<ActiveRuleDto, ActiveRu
 
   @Override
   public List<UpdateRequest> normalizeNested(Object object, ActiveRuleKey key) {
-    Preconditions.checkArgument(key != null, "key cannot be null");
+    Preconditions.checkNotNull(key);
     if (object.getClass().isAssignableFrom(ActiveRuleParamDto.class)) {
       return nestedUpdate((ActiveRuleParamDto) object, key);
     } else {
@@ -146,7 +143,7 @@ public class ActiveRuleNormalizer extends BaseNormalizer<ActiveRuleDto, ActiveRu
 
   @Override
   public List<UpdateRequest> deleteNested(Object object, ActiveRuleKey key) {
-    Preconditions.checkArgument(key != null, "key of Rule must be set");
+    Preconditions.checkNotNull(key);
     if (object.getClass().isAssignableFrom(ActiveRuleParamDto.class)) {
       return nestedDelete((ActiveRuleParamDto) object, key);
     } else {
@@ -154,15 +151,14 @@ public class ActiveRuleNormalizer extends BaseNormalizer<ActiveRuleDto, ActiveRu
     }
   }
 
-  private List<UpdateRequest> nestedUpdate(ActiveRuleParamDto param, ActiveRuleKey key) {
-    Preconditions.checkArgument(key != null, "Cannot normalize ActiveRuleParamDto for null key of ActiveRule");
+  private static List<UpdateRequest> nestedUpdate(ActiveRuleParamDto param, ActiveRuleKey key) {
+    Preconditions.checkNotNull(key);
 
     Map<String, Object> newParam = new HashMap<>();
     newParam.put(ActiveRuleParamField.NAME.field(), param.getKey());
     newParam.put(ActiveRuleParamField.VALUE.field(), param.getValue());
 
     return ImmutableList.of(new UpdateRequest()
-      .replicationType(ReplicationType.ASYNC)
       .routing(key.ruleKey().toString())
       .id(key.toString())
       .script(ProcessProperties.ES_PLUGIN_LISTUPDATE_SCRIPT_NAME)
@@ -173,9 +169,8 @@ public class ActiveRuleNormalizer extends BaseNormalizer<ActiveRuleDto, ActiveRu
       );
   }
 
-  private List<UpdateRequest> nestedDelete(ActiveRuleParamDto param, ActiveRuleKey key) {
+  private static List<UpdateRequest> nestedDelete(ActiveRuleParamDto param, ActiveRuleKey key) {
     return ImmutableList.of(new UpdateRequest()
-      .replicationType(ReplicationType.ASYNC)
       .routing(key.ruleKey().toString())
       .id(key.toString())
       .script(ProcessProperties.ES_PLUGIN_LISTUPDATE_SCRIPT_NAME)
index dd7103504ec303cd208c66aa0d5a6931f0f78860..83e06670edcb1e0b3697bd7b8eeebb5ade5448e6 100644 (file)
@@ -162,7 +162,7 @@ public class ResourceIndexDao extends AbstractDao {
     return indexed;
   }
 
-  private boolean indexResource(long id, String name, String qualifier, long rootId, SqlSession session, ResourceIndexMapper mapper) {
+  private static boolean indexResource(long id, String name, String qualifier, long rootId, SqlSession session, ResourceIndexMapper mapper) {
     boolean indexed = false;
     String key = nameToKey(name);
     if (key.length() >= MINIMUM_KEY_SIZE || key.length() == SINGLE_INDEX_SIZE) {