CodeSOD: onFunctionCall

Annalise has a pile of… unfortunate JavaScript. It's thousands of files with no real organization or logic behind their organization. It's got so much tech debt that it takes a full time developer just to keep it running, let alone provide support or add features or fix bugs. And the backlog of features and bugs is so long that it's best described in terms of א.

Which is to say, there's a lot in there that nobody understands. So when you see a bunch of callbacks registered to onFunctionCall, you might assume that this handler is doing… something. You'd be wrong.

onFunctionCall(varA, varB){ for (let i = 0; i < varA.length; i++){ if (varA.condition){ if (varA.field[i][varB.attr] == varB.id){ let temp = varA.field[i]; } } } }

This… doesn't do anything. It has no purpose or point. And yet, it's sitting in this giant pile of code, registered as a callback in all sorts of cases, because someone felt like it must be important. It is not.

[Advertisement] Keep the plebs out of prod. Restrict NuGet feed privileges with ProGet. Learn more.

This post originally appeared on The Daily WTF.

Leave a Reply

Your email address will not be published.