From 687df257d0e9ff187061cd1849fbd4e71486797d Mon Sep 17 00:00:00 2001 From: Philipp Gritsch <philipp.gritsch@uibk.ac.at> Date: Mon, 1 Jul 2024 08:08:48 +0200 Subject: [PATCH] address sonar bugs --- .../service/edu_sharing/EduSharingService.java | 13 +++++++------ .../exerciseComponents/exercise-body.component.html | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/at/ac/uibk/gitsearch/service/edu_sharing/EduSharingService.java b/src/main/java/at/ac/uibk/gitsearch/service/edu_sharing/EduSharingService.java index 1d87db763..143c5cb08 100644 --- a/src/main/java/at/ac/uibk/gitsearch/service/edu_sharing/EduSharingService.java +++ b/src/main/java/at/ac/uibk/gitsearch/service/edu_sharing/EduSharingService.java @@ -60,7 +60,7 @@ import org.springframework.web.util.UriComponentsBuilder; @Service @Validated -@SuppressWarnings({ "PMD.AvoidDuplicateLiterals", "PMD.TooManyMethods" }) +@SuppressWarnings({ "PMD.AvoidDuplicateLiterals", "PMD.TooManyMethods", "PMD.CyclomaticComplexity" }) public class EduSharingService { private static final String DEFAULT_VERSION = "1.4"; @@ -365,7 +365,7 @@ public class EduSharingService { return dto; } - @SuppressWarnings({ "PMD.AvoidCatchingGenericException", "PMD.PreserveStackTrace" }) + @SuppressWarnings({ "PMD.AvoidCatchingGenericException", "PMD.PreserveStackTrace", "PMD.ConfusingTernary" }) private void deleteNodeSilently(@NotNull String nodeId) { try { final var uri = UriComponentsBuilder @@ -378,8 +378,8 @@ public class EduSharingService { ResponseEntity<String> response = answer.toEntity(String.class).block(); if (response == null || !response.getStatusCode().is2xxSuccessful()) { - LOGGER.error("DELETE request to " + uri + " failed!"); - LOGGER.error(response.getBody()); + String responseText = response != null ? response.getBody() : "Null response"; + LOGGER.error("DELETE request to " + uri + " failed! Response: " + responseText); } } catch (final Exception e) { LOGGER.error("Error on deleteNode for resource " + nodeId, e); @@ -566,6 +566,7 @@ public class EduSharingService { .block(); } + @SuppressWarnings("PMD.ConfusingTernary") private void addOrUpdatePermissionsToCuratorGroup(@NotNull final String nodeId) throws JsonProcessingException { final GetPermissionAnswerDTO currentPermissions = getCurrentPermissionsForNode(nodeId); LocalPermissionDTO localPermissions = currentPermissions.getLocalPermissions(); @@ -590,8 +591,8 @@ public class EduSharingService { ResponseEntity<String> response = answer.toEntity(String.class).block(); if (response == null || !response.getStatusCode().is2xxSuccessful()) { - LOGGER.error("POST request to " + uri + " failed!"); - LOGGER.error(response.getBody()); + String responseText = response != null ? response.getBody() : "Null response"; + LOGGER.error("POST request to " + uri + " failed! Response: " + responseText); } } diff --git a/src/main/webapp/app/exercise/exercise-details/exerciseComponents/exercise-body.component.html b/src/main/webapp/app/exercise/exercise-details/exerciseComponents/exercise-body.component.html index cf0357cb8..4cf9b275f 100644 --- a/src/main/webapp/app/exercise/exercise-details/exerciseComponents/exercise-body.component.html +++ b/src/main/webapp/app/exercise/exercise-details/exerciseComponents/exercise-body.component.html @@ -362,7 +362,7 @@ </h6> <span *ngIf="eduSharingStatus?.publishedCopies?.length == 0"> - <i>{{ 'exercise.export.edu-sharing.publishedProjects.noEntries' | translate }}</i> + <em>{{ 'exercise.export.edu-sharing.publishedProjects.noEntries' | translate }}</em> </span> <table -- GitLab