Skip to content

Commit

Permalink
fix(kubernetes-maven-plugin): SonarQube AI fixes (3581)
Browse files Browse the repository at this point in the history
fix: uses safe Boolean check instead of error prone unboxing

Signed-off-by: jonathan.vila <[email protected]>
---
fix: rename variable to not hide variable

Signed-off-by: jonathan.vila <[email protected]>
---
fix: remove commented line

Signed-off-by: jonathan.vila <[email protected]>
  • Loading branch information
jonathanvila authored Dec 10, 2024
1 parent 07a1da7 commit 3fcd5e9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,20 +178,20 @@ protected ResourceClassifier getResourceClassifier() {
private void validateIfRequired(File resourceDir, ResourceClassifier classifier)
throws MojoExecutionException, MojoFailureException {
try {
if (!skipResourceValidation) {
if (Boolean.FALSE.equals(skipResourceValidation)) {
log.verbose("Validating resources");
new ResourceValidator(resourceDir, classifier, log).validate();
}
} catch (ConstraintViolationException e) {
if (failOnValidationError) {
if (Boolean.TRUE.equals(failOnValidationError)) {
log.error("[[R]]" + e.getMessage() + "[[R]]");
log.error("[[R]]use \"mvn -Djkube.skipResourceValidation=true\" option to skip the validation[[R]]");
throw new MojoFailureException("Failed to generate kubernetes descriptor");
} else {
log.warn("[[Y]]" + e.getMessage() + "[[Y]]");
}
} catch (Exception e) {
if (failOnValidationError) {
if (Boolean.TRUE.equals(failOnValidationError)) {
throw new MojoExecutionException("Failed to validate resources", e);
} else {
log.warn("Failed to validate resources: %s", e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@ void execute_withException_shouldStop() throws Exception {
// Then
assertThat(remoteDevelopmentService.constructed())
.singleElement()
.satisfies(remoteDevelopmentService -> verify(remoteDevelopmentService, times(1)).stop());
.satisfies(service -> verify(service, times(1)).stop());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void setUp() throws IOException {
.log(new KitLogger.SilentLogger())
.platformMode(RuntimeMode.KUBERNETES)
.build();
// log = new KitLogger.SilentLogger();

mojoExecution = new MojoExecution(new MojoDescriptor());
mojoExecution.getMojoDescriptor().setPluginDescriptor(new PluginDescriptor());
mojoExecution.getMojoDescriptor().getPluginDescriptor().setGoalPrefix("k8s");
Expand Down

0 comments on commit 3fcd5e9

Please sign in to comment.