From 554fd8eb15f00f07886129d71922d202f8dda96b Mon Sep 17 00:00:00 2001 From: Benjamin Campomenosi Date: Wed, 19 Jul 2023 16:36:48 +0200 Subject: [PATCH] SONAR-19850 Fix code smells --- .../ws/azure/ImportAzureProjectAction.java | 14 +++++++------- .../newcodeperiod/NewCodeDefinitionResolver.java | 2 +- .../sonar/server/project/ws/BulkDeleteAction.java | 5 ++--- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almintegration/ws/azure/ImportAzureProjectAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almintegration/ws/azure/ImportAzureProjectAction.java index ffd00262e30..4f7b971c215 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almintegration/ws/azure/ImportAzureProjectAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almintegration/ws/azure/ImportAzureProjectAction.java @@ -91,8 +91,8 @@ public class ImportAzureProjectAction implements AlmIntegrationsWsAction { public void define(WebService.NewController context) { WebService.NewAction action = context.createAction("import_azure_project") .setDescription("Create a SonarQube project with the information from the provided Azure DevOps project.
" + - "Autoconfigure pull request decoration mechanism.
" + - "Requires the 'Create Projects' permission") + "Autoconfigure pull request decoration mechanism.
" + + "Requires the 'Create Projects' permission") .setPost(true) .setInternal(true) .setSince("8.6") @@ -175,11 +175,11 @@ public class ImportAzureProjectAction implements AlmIntegrationsWsAction { boolean visibility = projectDefaultVisibility.get(dbSession).isPrivate(); String uniqueProjectKey = projectKeyGenerator.generateUniqueProjectKey(repo.getProject().getName(), repo.getName()); return componentUpdater.createWithoutCommit(dbSession, newComponentBuilder() - .setKey(uniqueProjectKey) - .setName(repo.getName()) - .setPrivate(visibility) - .setQualifier(PROJECT) - .build(), + .setKey(uniqueProjectKey) + .setName(repo.getName()) + .setPrivate(visibility) + .setQualifier(PROJECT) + .build(), userSession.isLoggedIn() ? userSession.getUuid() : null, userSession.isLoggedIn() ? userSession.getLogin() : null, repo.getDefaultBranchName()); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/NewCodeDefinitionResolver.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/NewCodeDefinitionResolver.java index a91268891c2..cbe969d59f7 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/NewCodeDefinitionResolver.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/NewCodeDefinitionResolver.java @@ -71,7 +71,7 @@ public class NewCodeDefinitionResolver { } public void createNewCodeDefinition(DbSession dbSession, String projectUuid, String mainBranchUuid, - String defaultBranchName, String newCodeDefinitionType, String newCodeDefinitionValue) { + String defaultBranchName, String newCodeDefinitionType, @Nullable String newCodeDefinitionValue) { boolean isCommunityEdition = editionProvider.get().filter(EditionProvider.Edition.COMMUNITY::equals).isPresent(); NewCodePeriodType newCodePeriodType = parseNewCodeDefinitionType(newCodeDefinitionType); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/BulkDeleteAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/BulkDeleteAction.java index 9f1d77e6658..1e2e947e031 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/BulkDeleteAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/BulkDeleteAction.java @@ -51,7 +51,6 @@ import org.sonar.server.project.Visibility; import org.sonar.server.user.UserSession; import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.collect.ImmutableSet.toImmutableSet; import static java.lang.Math.min; import static java.lang.String.format; import static java.util.stream.Collectors.toSet; @@ -160,13 +159,13 @@ public class BulkDeleteAction implements ProjectsWsAction { try { entities.forEach(p -> componentCleanerService.deleteEntity(dbSession, p)); } finally { - callDeleteListeners(dbSession, mainBranchUuidByEntityUuid, entities); + callDeleteListeners(mainBranchUuidByEntityUuid, entities); } } response.noContent(); } - private void callDeleteListeners(DbSession dbSession, Map mainBranchUuidByEntityUuid , List entities) { + private void callDeleteListeners(Map mainBranchUuidByEntityUuid , List entities) { Set deletedProjects = entities.stream().map(entity -> new DeletedProject(Project.from(entity), mainBranchUuidByEntityUuid.get(entity.getUuid()))).collect(toSet()); projectLifeCycleListeners.onProjectsDeleted(deletedProjects); -- 2.39.5