Skip to content

Conversation

@luk27official
Copy link

Again, this applies to ndbi021, unsure about other branches.
During the implementation of a new plugin to fastcompare, I have used the ParameterType.BOOL for some parameters of the algorithm. The problem is that in the current fastcompare template file, the following snippet of code "validates" the parameters.

if (result) {
for (let j in this.selectedAlgorithmsParameters[i]) {
let pVal = this.selectedAlgorithmsParameters[i][j].value;
let algoIdx = this.availableAlgorithmNames.indexOf(this.selectedAlgorithms[i]);
let algoParams = this.availableAlgorithmsData[algoIdx]["parameters"];
result = result && pVal != null && pVal != '';
if (result) {
let pType = this.findParamType(algoParams, j);
if (pType == "int") {
result = pVal >= 1;
} else if (pType == "float") {
result = pVal >= 0.0;
}
}
}

In JavaScript, an unchecked checkbox results let pVal = this.selectedAlgorithmsParameters[i][j].value; in pVal = false (which is correct), but then the validation fails here: result = result && pVal != null && pVal != ''; as pval != '' returns the wrong value, because false is a valid value for a checkbox (see the following image).

image

So, what all of this means is that the study cannot be created and there is no actual error description and I had no idea what's wrong. This pull request makes the comparsion strict which fixes the checkboxes problem.

To be honest, I'm not sure which of the comparsions should be !== instead of != (resp. === vs ==) in the entire file and if there are any similar issues. I don't have time to go through this, maybe using some linter would help.

@pdokoupil
Copy link
Owner

pdokoupil commented Jun 16, 2024

Right, this seems to be a bug

To be honest, I'm not sure which of the comparisons should be !== instead of != (resp. === vs ==) in the entire file and if there are any similar issues. I don't have time to go through this, maybe using some linter would help.

Honestly, these templates are messy and I do realize that. I suspect there will be many misplaced != '' (there is a somewhat complicated mix of checks for '', null, and undefined). I believe that at least all of the pVal != '' should have been pVal !== '' (there should be at least three occurrences, one for algorithm parameters, another for data loader parameters, and the last one for elicitation method parameters).

At some point (once I have enough time) I will try to revisit most of them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants