]> source.dussan.org Git - sonarqube.git/commitdiff
Fix Quality flaws
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 3 May 2019 20:04:57 +0000 (22:04 +0200)
committerSonarTech <sonartech@sonarsource.com>
Wed, 22 May 2019 18:21:16 +0000 (20:21 +0200)
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutor.java
server/sonar-server/src/main/java/org/sonar/server/authentication/JwtHttpHandler.java
server/sonar-server/src/main/java/org/sonar/server/project/ws/SearchMyProjectsAction.java

index bf2346048744e942a40877f236628dd6f2fa1bbb..a75d150d79c8d5399c6b31295ccdee2e6eba5d11 100644 (file)
@@ -76,17 +76,17 @@ public class PostProjectAnalysisTasksExecutor implements ComputationStepExecutor
    * Constructor used by Pico when there is no {@link PostProjectAnalysisTask} in the container.
    */
   public PostProjectAnalysisTasksExecutor(org.sonar.ce.task.CeTask ceTask,
-                                          AnalysisMetadataHolder analysisMetadataHolder,
-                                          QualityGateHolder qualityGateHolder, QualityGateStatusHolder qualityGateStatusHolder,
-                                          BatchReportReader reportReader, System2 system2) {
+    AnalysisMetadataHolder analysisMetadataHolder,
+    QualityGateHolder qualityGateHolder, QualityGateStatusHolder qualityGateStatusHolder,
+    BatchReportReader reportReader, System2 system2) {
     this(ceTask, analysisMetadataHolder, qualityGateHolder, qualityGateStatusHolder, reportReader, system2, null);
   }
 
   public PostProjectAnalysisTasksExecutor(org.sonar.ce.task.CeTask ceTask,
-                                          AnalysisMetadataHolder analysisMetadataHolder,
-                                          QualityGateHolder qualityGateHolder, QualityGateStatusHolder qualityGateStatusHolder,
-                                          BatchReportReader reportReader, System2 system2,
-                                          @Nullable PostProjectAnalysisTask[] postProjectAnalysisTasks) {
+    AnalysisMetadataHolder analysisMetadataHolder,
+    QualityGateHolder qualityGateHolder, QualityGateStatusHolder qualityGateStatusHolder,
+    BatchReportReader reportReader, System2 system2,
+    @Nullable PostProjectAnalysisTask[] postProjectAnalysisTasks) {
     this.analysisMetadataHolder = analysisMetadataHolder;
     this.qualityGateHolder = qualityGateHolder;
     this.qualityGateStatusHolder = qualityGateStatusHolder;
@@ -126,8 +126,7 @@ public class PostProjectAnalysisTasksExecutor implements ComputationStepExecutor
       ScannerContextImpl.from(reportReader.readContextProperties()),
       status == SUCCESS ? createQualityGate() : null,
       createBranch(),
-      reportReader.readMetadata().getScmRevisionId()
-    );
+      reportReader.readMetadata().getScmRevisionId());
   }
 
   @CheckForNull
@@ -144,9 +143,8 @@ public class PostProjectAnalysisTasksExecutor implements ComputationStepExecutor
 
     if (analysisDate != null) {
       return of(new AnalysisImpl(analysisMetadataHolder.getUuid(), analysisDate));
-    } else {
-      return empty();
     }
+    return empty();
   }
 
   private static Project createProject(org.sonar.ce.task.CeTask ceTask) {
index 74deff2aa3ebde420a4518b4194017e6a9d46b3b..b961187789f46d7a1319c0d25b0e355411138e0d 100644 (file)
@@ -143,10 +143,7 @@ public class JwtHttpHandler {
     }
 
     Optional<UserDto> user = selectUserFromUuid(token.getSubject());
-    if (!user.isPresent()) {
-      return Optional.empty();
-    }
-    return Optional.of(new Token(user.get(), claims.get()));
+    return user.map(userDto -> new Token(userDto, claims.get()));
   }
 
   private static Date getLastRefreshDate(Claims token) {
index fe57e16a56bf1caa77d9ab6ff1c28af4b0eddfbf..e6b292f0760eef92fb1bcac1f4c0c17e26a5761f 100644 (file)
@@ -179,10 +179,10 @@ public class SearchMyProjectsAction implements ProjectsWsAction {
       .selectByComponentUuidsAndMetricKeys(dbSession, projectUuids, singletonList(CoreMetrics.ALERT_STATUS_KEY));
 
     data.setProjects(projects)
-            .setProjectLinks(projectLinks)
-            .setSnapshots(snapshots)
-            .setQualityGates(qualityGates)
-            .setTotalNbOfProjects(searchResult.total);
+      .setProjectLinks(projectLinks)
+      .setSnapshots(snapshots)
+      .setQualityGates(qualityGates)
+      .setTotalNbOfProjects(searchResult.total);
 
     return data.build();
   }
@@ -193,13 +193,13 @@ public class SearchMyProjectsAction implements ProjectsWsAction {
 
     List<Long> componentIds = dbClient.roleDao().selectComponentIdsByPermissionAndUserId(dbSession, UserRole.ADMIN, userId);
     ComponentQuery dbQuery = ComponentQuery.builder()
-            .setQualifiers(Qualifiers.PROJECT)
-            .setComponentIds(ImmutableSet.copyOf(componentIds.subList(0, Math.min(componentIds.size(), DatabaseUtils.PARTITION_SIZE_FOR_ORACLE))))
-            .build();
+      .setQualifiers(Qualifiers.PROJECT)
+      .setComponentIds(ImmutableSet.copyOf(componentIds.subList(0, Math.min(componentIds.size(), DatabaseUtils.PARTITION_SIZE_FOR_ORACLE))))
+      .build();
 
     return new ProjectsResult(
-            dbClient.componentDao().selectByQuery(dbSession, dbQuery, offset(request.getPage(), request.getPageSize()), request.getPageSize()),
-            dbClient.componentDao().countByQuery(dbSession, dbQuery));
+      dbClient.componentDao().selectByQuery(dbSession, dbQuery, offset(request.getPage(), request.getPageSize()), request.getPageSize()),
+      dbClient.componentDao().countByQuery(dbSession, dbQuery));
   }
 
   private static class ProjectsResult {