summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Wrobel <tomasz.wrobel@nokia.com>2021-03-22 16:07:38 +0100
committerTomasz Wrobel <tomasz.wrobel@nokia.com>2021-03-23 08:54:12 +0100
commit4bff1528f42ea5705a02cc8ba5c08bf2453b31f1 (patch)
treeffcc8f391620a3ec2bbb881ce8f08390d1f70ccc
parent25763727265dd20b0301db0164c3e5549700cab4 (diff)
Fix Sonar issues
- Remove blank characters from input data on validation service - Add NOSONAR to test application context Issue-ID: SDC-3185 Signed-off-by: Tomasz Wrobel <tomasz.wrobel@nokia.com> Change-Id: I3a8c3cdf447a2ffa49ee1c961fd73229144349b8
-rw-r--r--src/main/java/org/onap/sdc/helmvalidator/helm/validation/ValidationService.java17
-rw-r--r--src/test/java/org/onap/sdc/helmvalidator/HelmValidatorApplicationTests.java3
2 files changed, 14 insertions, 6 deletions
diff --git a/src/main/java/org/onap/sdc/helmvalidator/helm/validation/ValidationService.java b/src/main/java/org/onap/sdc/helmvalidator/helm/validation/ValidationService.java
index 53689c2..87363f9 100644
--- a/src/main/java/org/onap/sdc/helmvalidator/helm/validation/ValidationService.java
+++ b/src/main/java/org/onap/sdc/helmvalidator/helm/validation/ValidationService.java
@@ -47,6 +47,7 @@ public class ValidationService {
private static final String LINT_OPTION = "lint";
private static final String HELM_SUMMARY_MESSAGE_PATTERN =
"Error: \\d* chart\\(s\\) linted, \\d* chart\\(s\\) failed";
+ private static final String WHITESPACE_CHARACTER = "[\\s]";
private static final boolean INVALID_RESULT = false;
private final FileManager fileManager;
@@ -91,7 +92,9 @@ public class ValidationService {
String chartPath = fileManager.saveFile(file);
try {
String helmVersion = getSupportedHelmVersion(desiredVersion, chartPath);
- return validateChart(helmVersion, file, isLinted, isStrictLinted, chartPath);
+ LOGGER.info("Start validation of file: {}, with helm version: {}",
+ replaceBlankCharacters(file.getOriginalFilename()), helmVersion);
+ return validateChart(helmVersion, isLinted, isStrictLinted, chartPath);
} finally {
LOGGER.info("File process finished");
fileManager.removeFile(chartPath);
@@ -115,11 +118,15 @@ public class ValidationService {
.orElseThrow(() -> new NotSupportedVersionException(desiredVersion));
}
- private ValidationResult validateChart(String version, MultipartFile file, boolean isLinted, boolean isStrictLinted,
- String chartPath) {
- LOGGER.info("Start validation of file: {}, with helm version: {}",
- file.getOriginalFilename(), version);
+ private String replaceBlankCharacters(String string) {
+ if (string != null) {
+ return string.replaceAll(WHITESPACE_CHARACTER, "_");
+ }
+ return "_";
+ }
+ private ValidationResult validateChart(String version, boolean isLinted, boolean isStrictLinted,
+ String chartPath) {
TemplateValidationResult templateValidationResult = runHelmTemplate(
buildHelmTemplateCommand(version, chartPath));
LOGGER.info("Helm template finished");
diff --git a/src/test/java/org/onap/sdc/helmvalidator/HelmValidatorApplicationTests.java b/src/test/java/org/onap/sdc/helmvalidator/HelmValidatorApplicationTests.java
index 5b81936..5efbedc 100644
--- a/src/test/java/org/onap/sdc/helmvalidator/HelmValidatorApplicationTests.java
+++ b/src/test/java/org/onap/sdc/helmvalidator/HelmValidatorApplicationTests.java
@@ -27,7 +27,8 @@ import org.springframework.boot.test.context.SpringBootTest;
class HelmValidatorApplicationTests {
@Test
- void contextLoads() {
+ // This method check Spring context load - it no requires assertion (Sonar rule java:S2699)
+ void contextLoads() { // NOSONAR
}
}