diff options
author | 2021-03-22 16:07:38 +0100 | |
---|---|---|
committer | 2021-03-23 08:54:12 +0100 | |
commit | 4bff1528f42ea5705a02cc8ba5c08bf2453b31f1 (patch) | |
tree | ffcc8f391620a3ec2bbb881ce8f08390d1f70ccc /src/main/java/org | |
parent | 25763727265dd20b0301db0164c3e5549700cab4 (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
Diffstat (limited to 'src/main/java/org')
-rw-r--r-- | src/main/java/org/onap/sdc/helmvalidator/helm/validation/ValidationService.java | 17 |
1 files changed, 12 insertions, 5 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"); |