aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-webserver-auth
diff options
context:
space:
mode:
authorMatteo Mara <matteo.mara@sonarsource.com>2023-01-10 15:16:50 +0100
committersonartech <sonartech@sonarsource.com>2023-01-10 20:03:01 +0000
commit54b60b1adac5b703398163ee5edf5a621efc0d24 (patch)
tree2c4595fea6ddefca2b5f33cc9c26000ffb5750ce /server/sonar-webserver-auth
parent295a87208f8c9898fbdc733a438587dc03a16877 (diff)
downloadsonarqube-54b60b1adac5b703398163ee5edf5a621efc0d24.tar.gz
sonarqube-54b60b1adac5b703398163ee5edf5a621efc0d24.zip
[NO-JIRA] Remove reported code smells about usages of toList
Diffstat (limited to 'server/sonar-webserver-auth')
-rw-r--r--server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/IdentityProviderRepository.java3
-rw-r--r--server/sonar-webserver-auth/src/main/java/org/sonar/server/permission/PermissionServiceImpl.java6
-rw-r--r--server/sonar-webserver-auth/src/main/java/org/sonar/server/user/ServerUserSession.java2
-rw-r--r--server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/UserRegistrarImplTest.java3
4 files changed, 5 insertions, 9 deletions
diff --git a/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/IdentityProviderRepository.java b/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/IdentityProviderRepository.java
index c634b1783c8..e926c85d6c0 100644
--- a/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/IdentityProviderRepository.java
+++ b/server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/IdentityProviderRepository.java
@@ -26,7 +26,6 @@ import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
import java.util.function.Predicate;
-import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.sonar.api.server.authentication.IdentityProvider;
@@ -53,7 +52,7 @@ public class IdentityProviderRepository {
return providersByKey.values().stream()
.filter(IS_ENABLED_FILTER)
.sorted(Comparator.comparing(TO_NAME))
- .collect(Collectors.toList());
+ .toList();
}
}
diff --git a/server/sonar-webserver-auth/src/main/java/org/sonar/server/permission/PermissionServiceImpl.java b/server/sonar-webserver-auth/src/main/java/org/sonar/server/permission/PermissionServiceImpl.java
index 4df08e2c9cc..f8f75ebd7eb 100644
--- a/server/sonar-webserver-auth/src/main/java/org/sonar/server/permission/PermissionServiceImpl.java
+++ b/server/sonar-webserver-auth/src/main/java/org/sonar/server/permission/PermissionServiceImpl.java
@@ -26,8 +26,6 @@ import org.sonar.api.resources.ResourceTypes;
import org.sonar.api.web.UserRole;
import org.sonar.db.permission.GlobalPermission;
-import static java.util.stream.Collectors.toList;
-
@Immutable
public class PermissionServiceImpl implements PermissionService {
private static final List<String> ALL_PROJECT_PERMISSIONS = List.of(
@@ -48,11 +46,11 @@ public class PermissionServiceImpl implements PermissionService {
globalPermissions = List.copyOf(ALL_GLOBAL_PERMISSIONS.stream()
.filter(s -> !s.equals(GlobalPermission.APPLICATION_CREATOR) || resourceTypes.isQualifierPresent(Qualifiers.APP))
.filter(s -> !s.equals(GlobalPermission.PORTFOLIO_CREATOR) || resourceTypes.isQualifierPresent(Qualifiers.VIEW))
- .collect(toList()));
+ .toList());
projectPermissions = List.copyOf(ALL_PROJECT_PERMISSIONS.stream()
.filter(s -> !s.equals(GlobalPermission.APPLICATION_CREATOR.getKey()) || resourceTypes.isQualifierPresent(Qualifiers.APP))
.filter(s -> !s.equals(GlobalPermission.PORTFOLIO_CREATOR.getKey()) || resourceTypes.isQualifierPresent(Qualifiers.VIEW))
- .collect(toList()));
+ .toList());
}
/**
diff --git a/server/sonar-webserver-auth/src/main/java/org/sonar/server/user/ServerUserSession.java b/server/sonar-webserver-auth/src/main/java/org/sonar/server/user/ServerUserSession.java
index 11b2df502b9..060e8f8341f 100644
--- a/server/sonar-webserver-auth/src/main/java/org/sonar/server/user/ServerUserSession.java
+++ b/server/sonar-webserver-auth/src/main/java/org/sonar/server/user/ServerUserSession.java
@@ -189,7 +189,7 @@ public class ServerUserSession extends AbstractUserSession {
return projects.stream()
.filter(project -> authorizedProjectsUuids.contains(project.getUuid()))
- .collect(toList());
+ .toList();
}
private Set<String> keepProjectsUuidsByPermission(String permission, Collection<String> projectsUuids) {
diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/UserRegistrarImplTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/UserRegistrarImplTest.java
index 88eab297ea5..920f3595997 100644
--- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/UserRegistrarImplTest.java
+++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/UserRegistrarImplTest.java
@@ -22,7 +22,6 @@ package org.sonar.server.authentication;
import java.util.Optional;
import java.util.Set;
import java.util.function.Consumer;
-import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.junit.Before;
import org.junit.Rule;
@@ -564,7 +563,7 @@ public class UserRegistrarImplTest {
}
private void checkGroupMembership(UserDto user, GroupDto... expectedGroups) {
- assertThat(db.users().selectGroupUuidsOfUser(user)).containsOnly(stream(expectedGroups).map(GroupDto::getUuid).collect(Collectors.toList()).toArray(new String[]{}));
+ assertThat(db.users().selectGroupUuidsOfUser(user)).containsOnly(stream(expectedGroups).map(GroupDto::getUuid).toList().toArray(new String[]{}));
}
private GroupDto insertDefaultGroup() {