Skip to content

Commit

Permalink
Only set explicitly set parameters when creating the check
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastiaanspeck committed Nov 16, 2024
1 parent 9a768d7 commit bee6ed7
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -91,6 +92,10 @@ public MagikCheckHolder(
this.metadata = null;
}

private Set<Parameter> explicitlySetParameters() {
return this.parameters.stream().filter(Parameter::isExplicitlySet).collect(Collectors.toSet());
}

/**
* Get the wrapped check.
*
Expand All @@ -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<Parameter> explicitlySetParameters = this.explicitlySetParameters();
for (final Parameter parameter : explicitlySetParameters) {
final String name = parameter.getName();
final Object value = parameter.getValue();
check.setParameter(name, value);
Expand Down

0 comments on commit bee6ed7

Please sign in to comment.