From d92167018db1f8362861416a29c371ab9f12a715 Mon Sep 17 00:00:00 2001 From: Sebastiaan Speck <12570668+sebastiaanspeck@users.noreply.github.com> Date: Sat, 16 Nov 2024 15:57:51 +0000 Subject: [PATCH] Only set explicitly set parameters when creating the check --- .../nl/ramsolutions/sw/magik/checks/MagikCheckHolder.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/magik-checks/src/main/java/nl/ramsolutions/sw/magik/checks/MagikCheckHolder.java b/magik-checks/src/main/java/nl/ramsolutions/sw/magik/checks/MagikCheckHolder.java index 1463fa36..bc6bc7bf 100644 --- a/magik-checks/src/main/java/nl/ramsolutions/sw/magik/checks/MagikCheckHolder.java +++ b/magik-checks/src/main/java/nl/ramsolutions/sw/magik/checks/MagikCheckHolder.java @@ -10,6 +10,7 @@ import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.Collectors; import org.sonar.check.Rule; /** MagicCheck holder/factory. */ @@ -91,6 +92,10 @@ public MagikCheckHolder( this.metadata = null; } + private Set explicitlySetParameters() { + return this.parameters.stream().filter(Parameter::isExplicitlySet).collect(Collectors.toSet()); + } + /** * Get the wrapped check. * @@ -101,7 +106,8 @@ public MagikCheck createCheck() throws ReflectiveOperationException { final MagikCheck check = this.checkClass.getDeclaredConstructor().newInstance(); check.setHolder(this); - for (final Parameter parameter : this.parameters) { + final Set explicitlySetParameters = this.explicitlySetParameters(); + for (final Parameter parameter : explicitlySetParameters) { final String name = parameter.getName(); final Object value = parameter.getValue(); check.setParameter(name, value);