Skip to content

Commit 728d958

Browse files
committed
Cleanup using sonarcloud comments
1 parent 3d5dcfa commit 728d958

9 files changed

Lines changed: 57 additions & 37 deletions

File tree

src/main/frontend/app/routes/editor/editor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import {
3535
findFlowElementsStartLine,
3636
lineToOffset,
3737
normalizeFrankElements,
38-
wrapFlowXml
38+
wrapFlowXml,
3939
} from './xml-utils'
4040

4141
type LeftTab = 'files' | 'git'

src/main/java/org/frankframework/flow/file/FileService.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
import java.nio.file.FileAlreadyExistsException;
55
import java.nio.file.Files;
66
import java.nio.file.Path;
7+
78
import org.frankframework.flow.exception.ApiException;
89
import org.frankframework.flow.filesystem.FileSystemStorage;
910
import org.frankframework.flow.project.Project;
1011
import org.frankframework.flow.project.ProjectNotFoundException;
1112
import org.frankframework.flow.project.ProjectService;
13+
1214
import org.springframework.http.HttpStatus;
1315
import org.springframework.stereotype.Service;
1416

@@ -102,7 +104,7 @@ public void deleteFile(String projectName, String path) throws ApiException {
102104
// invalidateTreeCache(projectName);
103105
}
104106

105-
public void validateWithinProject(String projectName, String path) throws IOException, ApiException {
107+
public void validateWithinProject(String projectName, String path) throws ApiException {
106108
try {
107109
Project project = projectService.getProject(projectName);
108110
Path projectPath = fileSystemStorage.toAbsolutePath(project.getRootPath());

src/main/java/org/frankframework/flow/file/FileTreeNode.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.frankframework.flow.file;
22

33
import java.util.List;
4+
45
import lombok.Getter;
56
import lombok.Setter;
67

@@ -13,6 +14,4 @@ public class FileTreeNode {
1314
private boolean projectRoot;
1415
private List<FileTreeNode> children;
1516
private List<String> adapterNames;
16-
17-
public FileTreeNode() {}
1817
}

src/main/java/org/frankframework/flow/file/FileTreeService.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@
1010
import java.util.concurrent.ConcurrentHashMap;
1111
import java.util.stream.Collectors;
1212
import java.util.stream.Stream;
13+
1314
import javax.xml.parsers.DocumentBuilder;
15+
1416
import org.frankframework.flow.exception.ApiException;
1517
import org.frankframework.flow.filesystem.FileSystemStorage;
1618
import org.frankframework.flow.project.Project;
1719
import org.frankframework.flow.project.ProjectNotFoundException;
1820
import org.frankframework.flow.project.ProjectService;
1921
import org.frankframework.flow.utility.XmlSecurityUtils;
22+
2023
import org.springframework.stereotype.Service;
2124
import org.w3c.dom.Document;
2225
import org.w3c.dom.Element;
@@ -163,7 +166,7 @@ private FileTreeNode buildTree(Path path, Path relativizeRoot, boolean useRelati
163166
throw new UncheckedIOException(e);
164167
}
165168
})
166-
.collect(Collectors.toList());
169+
.toList();
167170

168171
node.setChildren(children);
169172
}

src/test/java/org/frankframework/flow/configuration/ConfigurationServiceTest.java

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
import java.nio.charset.StandardCharsets;
99
import java.nio.file.Files;
1010
import java.nio.file.Path;
11+
1112
import org.frankframework.flow.exception.ApiException;
1213
import org.frankframework.flow.filesystem.FileSystemStorage;
1314
import org.frankframework.flow.project.Project;
1415
import org.frankframework.flow.project.ProjectNotFoundException;
1516
import org.frankframework.flow.project.ProjectService;
17+
1618
import org.junit.jupiter.api.BeforeEach;
1719
import org.junit.jupiter.api.Test;
1820
import org.junit.jupiter.api.extension.ExtendWith;
@@ -56,13 +58,13 @@ private void stubReadFile() throws IOException {
5658

5759
private void stubWriteFile() throws IOException {
5860
doAnswer(invocation -> {
59-
String path = invocation.getArgument(0);
60-
String content = invocation.getArgument(1);
61-
Path filePath = Path.of(path);
62-
Files.createDirectories(filePath.getParent());
63-
Files.writeString(filePath, content, StandardCharsets.UTF_8);
64-
return null;
65-
})
61+
String path = invocation.getArgument(0);
62+
String content = invocation.getArgument(1);
63+
Path filePath = Path.of(path);
64+
Files.createDirectories(filePath.getParent());
65+
Files.writeString(filePath, content, StandardCharsets.UTF_8);
66+
return null;
67+
})
6668
.when(fileSystemStorage)
6769
.writeFile(anyString(), anyString());
6870
}
@@ -81,7 +83,7 @@ void getConfigurationContent_Success() throws Exception {
8183
}
8284

8385
@Test
84-
void getConfigurationContent_FileNotFound_ThrowsConfigurationNotFoundException() throws IOException {
86+
void getConfigurationContent_FileNotFound_ThrowsConfigurationNotFoundException() {
8587
stubToAbsolutePath();
8688

8789
String path = tempDir.resolve("missing.xml").toString();
@@ -97,7 +99,8 @@ void getConfigurationContent_IsDirectory_ThrowsConfigurationNotFoundException()
9799

98100
assertThrows(
99101
ApiException.class,
100-
() -> configurationService.getConfigurationContent("test", dir.toString()));
102+
() -> configurationService.getConfigurationContent("test", dir.toString())
103+
);
101104
}
102105

103106
@Test
@@ -115,14 +118,15 @@ void updateConfiguration_Success() throws Exception {
115118
}
116119

117120
@Test
118-
void updateConfiguration_FileNotFound_ThrowsConfigurationNotFoundException() throws IOException {
121+
void updateConfiguration_FileNotFound_ThrowsConfigurationNotFoundException() {
119122
stubToAbsolutePath();
120123

121124
String path = tempDir.resolve("missing.xml").toString();
122125

123126
assertThrows(
124127
ApiException.class,
125-
() -> configurationService.updateConfiguration("test", path, "<new/>"));
128+
() -> configurationService.updateConfiguration("test", path, "<new/>")
129+
);
126130
}
127131

128132
@Test
@@ -199,7 +203,8 @@ void addConfigurationToFolder_AlreadyExists_ThrowsException() throws Exception {
199203
assertThrows(
200204
ConfigurationAlreadyExistsException.class,
201205
() -> configurationService.addConfigurationToFolder(
202-
"myproject", "existing.xml", projectDir.toString()));
206+
"myproject", "existing.xml", projectDir.toString())
207+
);
203208
}
204209

205210
@Test
@@ -216,6 +221,7 @@ void addConfigurationToFolder_OutsideProject_ThrowsSecurityException() throws Ex
216221

217222
assertThrows(
218223
SecurityException.class,
219-
() -> configurationService.addConfigurationToFolder("myproject", "evil.xml", outsidePath));
224+
() -> configurationService.addConfigurationToFolder("myproject", "evil.xml", outsidePath)
225+
);
220226
}
221227
}

src/test/java/org/frankframework/flow/datamapper/DatamapperConfigServiceTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@
1313
import java.nio.file.Path;
1414
import java.nio.file.Paths;
1515
import java.util.Comparator;
16+
1617
import javax.naming.ConfigurationException;
18+
1719
import org.frankframework.flow.configuration.ConfigurationNotFoundException;
1820
import org.frankframework.flow.file.FileTreeNode;
1921
import org.frankframework.flow.file.FileTreeService;
2022
import org.frankframework.flow.filesystem.FileSystemStorage;
23+
2124
import org.junit.jupiter.api.AfterEach;
2225
import org.junit.jupiter.api.BeforeEach;
2326
import org.junit.jupiter.api.Disabled;
@@ -56,7 +59,7 @@ public void tearDown() throws IOException {
5659
}
5760
}
5861

59-
private void stubToAbsolutePath() throws IOException {
62+
private void stubToAbsolutePath() {
6063
when(fileSystemStorage.toAbsolutePath(anyString())).thenAnswer(invocation -> {
6164
String path = invocation.getArgument(0);
6265
Path p = Paths.get(path);
@@ -110,9 +113,8 @@ public void readFileContent_Success() throws IOException, ConfigurationNotFoundE
110113
assertEquals(content, result);
111114
}
112115

113-
/* Disabled due to it never throwing NoSuchFileException and creating the file itself when needed */
114116
@Test
115-
@Disabled
117+
@Disabled("Disabled due to it never throwing NoSuchFileException and creating the file itself when needed")
116118
@DisplayName("Should throw NoSuchFileException when file does not exist")
117119
public void readFileContent_FileNotFound() throws IOException {
118120
stubReadFile();

src/test/java/org/frankframework/flow/datamapper/DatamapperGeneratorServiceTest.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,23 @@
1515
import java.nio.file.Paths;
1616
import java.nio.file.StandardCopyOption;
1717
import java.util.Comparator;
18+
1819
import javax.xml.parsers.DocumentBuilder;
1920
import javax.xml.parsers.DocumentBuilderFactory;
2021
import javax.xml.parsers.ParserConfigurationException;
2122
import javax.xml.transform.*;
2223
import javax.xml.transform.dom.DOMSource;
2324
import javax.xml.transform.stream.StreamResult;
2425
import javax.xml.transform.stream.StreamSource;
26+
2527
import net.sf.saxon.s9api.*;
28+
2629
import org.frankframework.flow.exception.ApiException;
2730
import org.frankframework.flow.file.FileTreeNode;
2831
import org.frankframework.flow.file.FileTreeService;
2932
import org.frankframework.flow.filesystem.FileOperations;
3033
import org.frankframework.flow.filesystem.FileSystemStorage;
34+
3135
import org.junit.jupiter.api.*;
3236
import org.junit.jupiter.api.extension.ExtendWith;
3337
import org.mockito.Mock;
@@ -51,7 +55,7 @@ public class DatamapperGeneratorServiceTest {
5155

5256
private Path tempProjectRoot;
5357

54-
private void stubToAbsolutePath() throws IOException {
58+
private void stubToAbsolutePath() {
5559
when(fileSystemStorage.toAbsolutePath(anyString())).thenAnswer(invocation -> {
5660
String path = invocation.getArgument(0);
5761
return Paths.get(path);
@@ -202,7 +206,8 @@ public void testXMLtoXMLWithAttributesGeneratedMapping()
202206
stubToAbsolutePath();
203207
service.generate(
204208
"src/test/resources/datamapper/inputXmlToXmlWithArrayWithAttributes.json",
205-
tempProjectRoot.toAbsolutePath() + "/output.xslt");
209+
tempProjectRoot.toAbsolutePath() + "/output.xslt"
210+
);
206211

207212
XsltExecutable executable =
208213
compiler.compile(new StreamSource(new File(tempProjectRoot.toAbsolutePath() + "/output.xslt")));
@@ -220,6 +225,7 @@ public void testXMLtoXMLWithAttributesGeneratedMapping()
220225
Assertions.assertEquals(
221226
toString(expectedResult).trim(), writer.toString().trim());
222227
}
228+
223229
@Test
224230
@DisplayName("Test All functions")
225231
public void testAllFunctionsGeneratedMapping()
@@ -228,7 +234,8 @@ public void testAllFunctionsGeneratedMapping()
228234
stubToAbsolutePath();
229235
service.generate(
230236
"src/test/resources/datamapper/generationFileTestAllFunctions.json",
231-
tempProjectRoot.toAbsolutePath() + "/output.xslt");
237+
tempProjectRoot.toAbsolutePath() + "/output.xslt"
238+
);
232239

233240
XsltExecutable executable =
234241
compiler.compile(new StreamSource(new File(tempProjectRoot.toAbsolutePath() + "/output.xslt")));
@@ -246,6 +253,7 @@ public void testAllFunctionsGeneratedMapping()
246253
Assertions.assertEquals(
247254
toString(expectedResult).trim(), writer.toString().trim());
248255
}
256+
249257
@Test
250258
@DisplayName("Test XML to Json mapping")
251259
public void testXMLtoJSONGeneratedMapping() throws SaxonApiException, IOException, ApiException {

src/test/java/org/frankframework/flow/file/FileServiceTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@
1515
import java.nio.file.Path;
1616
import java.nio.file.Paths;
1717
import java.util.Comparator;
18+
1819
import org.frankframework.flow.exception.ApiException;
1920
import org.frankframework.flow.filesystem.FileOperations;
2021
import org.frankframework.flow.filesystem.FileSystemStorage;
2122
import org.frankframework.flow.project.Project;
2223
import org.frankframework.flow.project.ProjectNotFoundException;
2324
import org.frankframework.flow.project.ProjectService;
25+
2426
import org.junit.jupiter.api.AfterEach;
2527
import org.junit.jupiter.api.BeforeEach;
2628
import org.junit.jupiter.api.DisplayName;
@@ -56,6 +58,7 @@ public void tearDown() throws IOException {
5658
try {
5759
Files.delete(p);
5860
} catch (IOException ignored) {
61+
// Ignored to ensure cleanup continues even if some files couldn't be removed
5962
}
6063
});
6164
}

src/test/java/org/frankframework/flow/file/FileTreeServiceTest.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111
import java.nio.file.Paths;
1212
import java.util.Comparator;
1313
import java.util.List;
14+
1415
import org.frankframework.flow.exception.ApiException;
1516
import org.frankframework.flow.filesystem.FileSystemStorage;
1617
import org.frankframework.flow.project.Project;
1718
import org.frankframework.flow.project.ProjectNotFoundException;
1819
import org.frankframework.flow.project.ProjectService;
20+
1921
import org.junit.jupiter.api.AfterEach;
2022
import org.junit.jupiter.api.BeforeEach;
2123
import org.junit.jupiter.api.DisplayName;
@@ -52,6 +54,7 @@ public void tearDown() throws IOException {
5254
try {
5355
Files.delete(p);
5456
} catch (IOException ignored) {
57+
// Ignored to ensure cleanup continues even if some files couldn't be removed
5558
}
5659
});
5760
}
@@ -141,7 +144,7 @@ public void getShallowDirectoryTreeReturnsTreeForValidDirectory() throws IOExcep
141144
}
142145

143146
@Test
144-
void getShallowDirectoryTreeThrowsSecurityExceptionForPathTraversal() throws ProjectNotFoundException, IOException {
147+
void getShallowDirectoryTreeThrowsSecurityExceptionForPathTraversal() throws ProjectNotFoundException {
145148
stubToAbsolutePath();
146149

147150
Project project =
@@ -155,8 +158,7 @@ void getShallowDirectoryTreeThrowsSecurityExceptionForPathTraversal() throws Pro
155158
}
156159

157160
@Test
158-
void getShallowDirectoryTreeThrowsIllegalArgumentExceptionIfDirectoryDoesNotExist()
159-
throws ProjectNotFoundException, IOException {
161+
void getShallowDirectoryTreeThrowsIllegalArgumentExceptionIfDirectoryDoesNotExist() throws ProjectNotFoundException {
160162
stubToAbsolutePath();
161163

162164
Project project =
@@ -172,8 +174,7 @@ void getShallowDirectoryTreeThrowsIllegalArgumentExceptionIfDirectoryDoesNotExis
172174
}
173175

174176
@Test
175-
public void getShallowConfigurationsDirectoryTreeReturnsTreeForExistingDirectory()
176-
throws IOException, ProjectNotFoundException {
177+
public void getShallowConfigurationsDirectoryTreeReturnsTreeForExistingDirectory() throws IOException, ProjectNotFoundException {
177178
stubToAbsolutePath();
178179

179180
Path configsDir = tempProjectRoot.resolve("src/main/configurations");
@@ -198,12 +199,10 @@ public void getShallowConfigurationsDirectoryTreeReturnsTreeForExistingDirectory
198199
}
199200

200201
@Test
201-
public void getShallowConfigurationsDirectoryTreeThrowsIfDirectoryDoesNotExist()
202-
throws ProjectNotFoundException, IOException {
202+
public void getShallowConfigurationsDirectoryTreeThrowsIfDirectoryDoesNotExist() throws ProjectNotFoundException {
203203
stubToAbsolutePath();
204204

205-
Project project =
206-
new Project(TEST_PROJECT_NAME, tempProjectRoot.toAbsolutePath().toString());
205+
Project project = new Project(TEST_PROJECT_NAME, tempProjectRoot.toAbsolutePath().toString());
207206
when(projectService.getProject(TEST_PROJECT_NAME)).thenReturn(project);
208207

209208
IllegalArgumentException ex = assertThrows(
@@ -227,8 +226,7 @@ public void getShallowConfigurationsDirectoryTreeThrowsIfProjectDoesNotExist() t
227226
}
228227

229228
@Test
230-
public void getConfigurationsDirectoryTreeReturnsFullTreeForExistingDirectory()
231-
throws IOException, ProjectNotFoundException {
229+
public void getConfigurationsDirectoryTreeReturnsFullTreeForExistingDirectory() throws IOException, ProjectNotFoundException {
232230
stubToAbsolutePath();
233231
when(fileSystemStorage.isLocalEnvironment()).thenReturn(true);
234232

@@ -265,8 +263,7 @@ public void getConfigurationsDirectoryTreeReturnsFullTreeForExistingDirectory()
265263
}
266264

267265
@Test
268-
public void getConfigurationsDirectoryTreeThrowsIfDirectoryDoesNotExist()
269-
throws ProjectNotFoundException, IOException {
266+
public void getConfigurationsDirectoryTreeThrowsIfDirectoryDoesNotExist() throws ProjectNotFoundException {
270267
stubToAbsolutePath();
271268

272269
Project project =

0 commit comments

Comments
 (0)