From: Simon Brandhof Date: Fri, 3 May 2019 20:04:57 +0000 (+0200) Subject: Fix Quality flaws X-Git-Tag: 7.8~188 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=edbce3b7a43006e14d6fd6d408ad1549ddac3c84;p=sonarqube.git Fix Quality flaws --- diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutor.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutor.java index bf234604874..a75d150d79c 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutor.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutor.java @@ -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) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/authentication/JwtHttpHandler.java b/server/sonar-server/src/main/java/org/sonar/server/authentication/JwtHttpHandler.java index 74deff2aa3e..b961187789f 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/authentication/JwtHttpHandler.java +++ b/server/sonar-server/src/main/java/org/sonar/server/authentication/JwtHttpHandler.java @@ -143,10 +143,7 @@ public class JwtHttpHandler { } Optional 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) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/project/ws/SearchMyProjectsAction.java b/server/sonar-server/src/main/java/org/sonar/server/project/ws/SearchMyProjectsAction.java index fe57e16a56b..e6b292f0760 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/project/ws/SearchMyProjectsAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/project/ws/SearchMyProjectsAction.java @@ -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 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 {