aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-webserver-webapi
diff options
context:
space:
mode:
authorMatteo Mara <matteo.mara@sonarsource.com>2023-01-09 10:21:46 +0100
committersonartech <sonartech@sonarsource.com>2023-01-10 20:03:01 +0000
commit295a87208f8c9898fbdc733a438587dc03a16877 (patch)
tree9771ee3245ab6e978b20b9d8b800450947fc7199 /server/sonar-webserver-webapi
parent8868a5ff310c74f44f2c94e46ba31065017f50b4 (diff)
downloadsonarqube-295a87208f8c9898fbdc733a438587dc03a16877.tar.gz
sonarqube-295a87208f8c9898fbdc733a438587dc03a16877.zip
[NO-JIRA] Remove reported code smells about usage of instanceof
Diffstat (limited to 'server/sonar-webserver-webapi')
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/batch/ProjectAction.java4
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/PermissionUpdater.java8
2 files changed, 6 insertions, 6 deletions
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/batch/ProjectAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/batch/ProjectAction.java
index 28edcefa656..bb125f8b175 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/batch/ProjectAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/batch/ProjectAction.java
@@ -103,8 +103,8 @@ public class ProjectAction implements BatchWsAction {
private static WsProjectResponse buildResponse(ProjectRepositories data) {
WsProjectResponse.Builder response = WsProjectResponse.newBuilder();
- if (data instanceof SingleProjectRepository) {
- response.putAllFileDataByPath(buildFileDataByPath((SingleProjectRepository) data));
+ if (data instanceof SingleProjectRepository singleProjectRepository) {
+ response.putAllFileDataByPath(buildFileDataByPath(singleProjectRepository));
} else {
response.putAllFileDataByModuleAndPath(buildFileDataByModuleAndPath((MultiModuleProjectRepository) data));
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/PermissionUpdater.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/PermissionUpdater.java
index d6ab624c000..f3bdf455d6b 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/PermissionUpdater.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/PermissionUpdater.java
@@ -55,11 +55,11 @@ public class PermissionUpdater {
}
private boolean doApply(DbSession dbSession, PermissionChange change) {
- if (change instanceof UserPermissionChange) {
- return userPermissionChanger.apply(dbSession, (UserPermissionChange) change);
+ if (change instanceof UserPermissionChange userPermissionChange) {
+ return userPermissionChanger.apply(dbSession, userPermissionChange);
}
- if (change instanceof GroupPermissionChange) {
- return groupPermissionChanger.apply(dbSession, (GroupPermissionChange) change);
+ if (change instanceof GroupPermissionChange groupPermissionChange) {
+ return groupPermissionChanger.apply(dbSession, groupPermissionChange);
}
throw new UnsupportedOperationException("Unsupported permission change: " + change.getClass());