Define a constant for a literal string that is duplicated n times (Sonar) (#978)

Co-authored-by: pixeebot[bot] <104101892+pixeebot[bot]@users.noreply.github.com>
This commit is contained in:
pixeebot[bot]
2024-03-28 17:44:10 +00:00
committed by GitHub
parent c16db14cd9
commit 1035a3be31
3 changed files with 16 additions and 10 deletions

View File

@@ -97,7 +97,7 @@ public class UserController {
// Logout using Spring's utility
new SecurityContextLogoutHandler().logout(request, response, null);
return new RedirectView("/login?messageType=credsUpdated");
return new RedirectView(LOGIN_MESSAGETYPE_CREDSUPDATED);
}
@PreAuthorize("!hasAuthority('ROLE_DEMO_USER')")
@@ -130,7 +130,7 @@ public class UserController {
// Logout using Spring's utility
new SecurityContextLogoutHandler().logout(request, response, null);
return new RedirectView("/login?messageType=credsUpdated");
return new RedirectView(LOGIN_MESSAGETYPE_CREDSUPDATED);
}
@PreAuthorize("!hasAuthority('ROLE_DEMO_USER')")
@@ -163,7 +163,7 @@ public class UserController {
// Logout using Spring's utility
new SecurityContextLogoutHandler().logout(request, response, null);
return new RedirectView("/login?messageType=credsUpdated");
return new RedirectView(LOGIN_MESSAGETYPE_CREDSUPDATED);
}
@PreAuthorize("!hasAuthority('ROLE_DEMO_USER')")
@@ -291,4 +291,6 @@ public class UserController {
}
return ResponseEntity.ok(apiKey);
}
private static final String LOGIN_MESSAGETYPE_CREDSUPDATED = "/login?messageType=credsUpdated";
}

View File

@@ -156,7 +156,7 @@ public class ExtractImageScansController {
// Create zip file if multiple images
if (processedImageBytes.size() > 1) {
String outputZipFilename =
fileName.replaceFirst("[.][^.]+$", "") + "_processed.zip";
fileName.replaceFirst(REPLACEFIRST, "") + "_processed.zip";
tempZipFile = Files.createTempFile("output_", ".zip");
try (ZipOutputStream zipOut =
@@ -165,7 +165,7 @@ public class ExtractImageScansController {
for (int i = 0; i < processedImageBytes.size(); i++) {
ZipEntry entry =
new ZipEntry(
fileName.replaceFirst("[.][^.]+$", "")
fileName.replaceFirst(REPLACEFIRST, "")
+ "_"
+ (i + 1)
+ ".png");
@@ -187,7 +187,7 @@ public class ExtractImageScansController {
byte[] imageBytes = processedImageBytes.get(0);
return WebResponseUtils.bytesToWebResponse(
imageBytes,
fileName.replaceFirst("[.][^.]+$", "") + ".png",
fileName.replaceFirst(REPLACEFIRST, "") + ".png",
MediaType.IMAGE_PNG);
}
} finally {
@@ -219,4 +219,6 @@ public class ExtractImageScansController {
});
}
}
private static final String REPLACEFIRST = "[.][^.]+$";
}