]> source.dussan.org Git - sonarqube.git/commitdiff
Fix quality flaws
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Mon, 11 Sep 2017 13:45:11 +0000 (15:45 +0200)
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Mon, 11 Sep 2017 15:14:22 +0000 (17:14 +0200)
server/sonar-db-dao/src/main/java/org/sonar/db/permission/PermissionQuery.java
server/sonar-server/src/main/java/org/sonar/server/duplication/ws/ShowResponseBuilder.java
server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndex.java
server/sonar-server/src/main/java/org/sonar/server/issue/notification/NewIssuesStatistics.java

index d70c5f1994c10eac4e8f77c07c9b62c08cf825d0..1d0f3cb6c4d18d428e7024fdde37c48661b59294 100644 (file)
@@ -183,7 +183,7 @@ public class PermissionQuery {
     }
 
     public PermissionQuery build() {
-      this.organizationUuid = requireNonNull(organizationUuid, "Organization UUID cannot be null");
+      requireNonNull(organizationUuid, "Organization UUID cannot be null");
       this.pageIndex = firstNonNull(pageIndex, DEFAULT_PAGE_INDEX);
       this.pageSize = firstNonNull(pageSize, DEFAULT_PAGE_SIZE);
       checkArgument(searchQuery == null || searchQuery.length() >= SEARCH_QUERY_MIN_LENGTH, "Search query should contains at least %s characters", SEARCH_QUERY_MIN_LENGTH);
index 58e1ac2e7ae6238dc49d77162cbffd404af91368..5b6e39551461250e24d28c77f9dab1d50ff99e7d 100644 (file)
@@ -74,11 +74,7 @@ public class ShowResponseBuilder {
     ComponentDto componentDto = duplication.file();
     if (componentDto != null) {
       String componentKey = componentDto.getDbKey();
-      ref = refByComponentKey.get(componentKey);
-      if (ref == null) {
-        ref = Integer.toString(refByComponentKey.size() + 1);
-        refByComponentKey.put(componentKey, ref);
-      }
+      ref = refByComponentKey.computeIfAbsent(componentKey, k -> Integer.toString(refByComponentKey.size() + 1));
     }
 
     Block.Builder block = Block.newBuilder();
index 6172308b6c7c4644510e5a376d44d5d31654d96c..b975c525d9d2db9af481f7a8d94a4911b5869023 100644 (file)
@@ -543,7 +543,7 @@ public class IssueIndex {
       .offset(offsetInSeconds + "s")
       // ES dateHistogram bounds are inclusive while createdBefore parameter is exclusive
       .extendedBounds(new ExtendedBounds(startTime, endTime - (offsetInSeconds*1_000L) -1L));
-    dateHistogram = addEffortAggregationIfNeeded(query, dateHistogram);
+    addEffortAggregationIfNeeded(query, dateHistogram);
     return Optional.of(dateHistogram);
   }
 
index 336e6a8a4bd2b2a16ae0c14b68d2de764730ff1f..b4746bed5f586203fc5423f1db1acd1b92e30fdb 100644 (file)
@@ -50,10 +50,7 @@ public class NewIssuesStatistics {
   }
 
   private Stats getOrCreate(String assignee) {
-    if (assigneesStatistics.get(assignee) == null) {
-      assigneesStatistics.put(assignee, new Stats());
-    }
-    return assigneesStatistics.get(assignee);
+    return assigneesStatistics.computeIfAbsent(assignee, a -> new Stats());
   }
 
   public Map<String, Stats> assigneesStatistics() {