From e193b2bacfec4b602a9e369c38ba4b11e5273ff4 Mon Sep 17 00:00:00 2001 From: Renan Franca Date: Mon, 22 Jul 2024 10:56:00 -0300 Subject: [PATCH] fix(sonar): separate folder path and file name into two constants instead of one --- .../secondary/FileSystemProjectsRepository.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/tech/jhipster/lite/project/infrastructure/secondary/FileSystemProjectsRepository.java b/src/main/java/tech/jhipster/lite/project/infrastructure/secondary/FileSystemProjectsRepository.java index 587f1694f89..be5c1dc38ba 100644 --- a/src/main/java/tech/jhipster/lite/project/infrastructure/secondary/FileSystemProjectsRepository.java +++ b/src/main/java/tech/jhipster/lite/project/infrastructure/secondary/FileSystemProjectsRepository.java @@ -25,7 +25,8 @@ class FileSystemProjectsRepository implements ProjectsRepository { private static final String HISTORY_FOLDER = ".jhipster/modules"; private static final String HISTORY_FILE = "history.json"; - private static final String PRESET_FILE_PATH = "/preset.json"; + private static final String PRESET_FOLDER = "/"; + private static final String PRESET_FILE = "preset.json"; private final ObjectMapper json; private final ProjectFormatter formatter; @@ -94,9 +95,13 @@ private Path historyFilePath(ProjectPath path) { @Override public Collection getPresets() { try { - return json.readValue(projectFiles.readBytes(PRESET_FILE_PATH), PersistedPresets.class).toDomain(); + return json.readValue(projectFiles.readBytes(presetFilePath()), PersistedPresets.class).toDomain(); } catch (IOException e) { throw GeneratorException.technicalError("Can't read presets: " + e.getMessage(), e); } } + + private String presetFilePath() { + return PRESET_FOLDER + PRESET_FILE; + } }