PadMessageHandler: reversed condition to make core logic evident. No behavioural changes.

This one replaces a big "if (message)" negating its truthy condition.

Being lame, I erred on the safe side and wrote a super ugly statement that is
guaranteed to respect the original logic.

In the hope that eventual logic errors become more evident now.

See: https://stackoverflow.com/questions/36661748/what-is-the-exact-negation-of-ifvariable-in-javascript#36661843
This commit is contained in:
muxator 2018-08-29 01:23:38 +02:00
parent 324929ca2d
commit b60c0b122c

View file

@ -244,7 +244,19 @@ exports.handleMessage = function(client, message)
} }
}; };
if (message) { /*
* In a previous version of this code, an "if (message)" wrapped the
* following async.series().
* This ugly "!Boolean(message)" is a lame way to exactly negate the truthy
* condition and replace it with an early return, while being sure to leave
* the original behaviour unchanged.
*
* A shallower code could maybe make more evident latent logic errors.
*/
if (!Boolean(message)) {
return;
}
async.series([ async.series([
handleMessageHook, handleMessageHook,
//check permissions //check permissions
@ -297,7 +309,6 @@ exports.handleMessage = function(client, message)
}, },
finalHandler finalHandler
]); ]);
}
} }