Description
Ok, here are the list of problems I noticed in the code:
- Code duplication
- Dead code
- Type confusions
- Logic differences between some of the duplicates
- Some broken logic
- @ts-check annotation could have saved lives
- Generated files are being tracked by git
I'm trying to solve all of that, but I need some help with the following issues I'm not sure about how to solve:
1st problem
WebGazer/src/worker_scripts/util.js
Line 389 in d309e07
y[i] = [y[i]]
: this will transform a number[][]
array into a number[][][] array. I would be surprised if that was intentional, provided the comment above. My guess is that the intended code was:
const line = y[0]
for (let i = 0; i<y.length; i++) {
y[i] = [line[i]]
}
2nd problem
WebGazer/src/worker_scripts/util.js
Line 381 in d309e07
z
is supposed to be of type number[]
while the sub
method expects a parameter of type number[][]
. In another file, I noticed the exact same code with that single difference: there was that extra line before:
const transposedZ = transpose([z])
const y = sub(transposedZ, mult(this.H, xP)) // This is the measurement error (between what we expect and the actual value)
I guess that this is the correct version?
3rd problem
WebGazer/src/util_regression.mjs
Line 157 in d309e07
mCoefficients[i] = solution[i]
: mCoefficients
is of type number[]
but solution
is of type number[][]
. I have no idea how this is supposed to be solved. Should I just take solution[i][i]
?
4th problem
WebGazer/src/util_regression.mjs
Line 151 in d309e07
if (mCoefficients.length * n !== mCoefficients.length)
: This can only be true if n === 1
. Is it what we want to test instead?
Anyway, the line above that define the value of n
is completely stupid: const n = (mCoefficients.length !== 0 ? mCoefficients.length / mCoefficients.length : 0)
This is equivalent to mCoefficients.length ? 1 : 0
. In short, those 2 lines could be simplified with if(mCoefficients.length)
. However, there is absolutely no relation with Array length being a multiple of m...
5th problem
WebGazer/src/util_regression.mjs
Line 50 in d309e07
H
is being declared twice. Which one is the correct value?
6th problem
Line 311 in d309e07
d
is of type string. This will lead to really problematic consequences in the get
and getTrueIndex
methods
7th problem
Line 639 in d309e07
debugVideoLoc
has to be a MediaStream, because we call getTracks()
on it. But it is a string, here...