1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Merge pull request #392 from hindessm/remove-redundant-null-checks

Remove redundant msg != null checks.
This commit is contained in:
Nick O'Leary 2014-09-08 21:31:55 +01:00
commit 94b196bfcf
7 changed files with 163 additions and 182 deletions

View File

@ -27,7 +27,6 @@ module.exports = function(RED) {
var node = this; var node = this;
this.on("input", function(msg) { this.on("input", function(msg) {
if (msg != null) {
node.status({fill:"blue",shape:"dot"}); node.status({fill:"blue",shape:"dot"});
if (this.useSpawn === true) { if (this.useSpawn === true) {
// make the extra args into an array // make the extra args into an array
@ -61,7 +60,6 @@ module.exports = function(RED) {
} }
else { node.error("Spawn command must be just the command - no spaces or extra parameters"); } else { node.error("Spawn command must be just the command - no spaces or extra parameters"); }
} }
else { else {
var cl = node.cmd+" "+msg.payload+" "+node.append; var cl = node.cmd+" "+msg.payload+" "+node.append;
node.log(cl); node.log(cl);
@ -79,8 +77,6 @@ module.exports = function(RED) {
node.send([msg,msg2,msg3]); node.send([msg,msg2,msg3]);
}); });
} }
}
}); });
} }

View File

@ -39,7 +39,6 @@ module.exports = function(RED) {
try { try {
this.script = vm.createScript(functionText); this.script = vm.createScript(functionText);
this.on("input", function(msg) { this.on("input", function(msg) {
if (msg != null) {
try { try {
var start = process.hrtime(); var start = process.hrtime();
context.msg = msg; context.msg = msg;
@ -71,7 +70,6 @@ module.exports = function(RED) {
} catch(err) { } catch(err) {
this.error(err.toString()); this.error(err.toString());
} }
}
}); });
} catch(err) { } catch(err) {
this.error(err); this.error(err);

View File

@ -47,7 +47,6 @@ module.exports = function(RED) {
} }
node.on("input", function(msg) { node.on("input", function(msg) {
if (msg != null) {
try { try {
m = msg; m = msg;
i = 0; i = 0;
@ -55,7 +54,6 @@ module.exports = function(RED) {
} catch(err) { } catch(err) {
node.error(err.message); node.error(err.message);
} }
}
}); });
} }

View File

@ -82,7 +82,6 @@ module.exports = function(RED) {
this.client = connectionPool.get(this.brokerConfig.broker,this.brokerConfig.port,this.brokerConfig.clientid,this.brokerConfig.username,this.brokerConfig.password); this.client = connectionPool.get(this.brokerConfig.broker,this.brokerConfig.port,this.brokerConfig.clientid,this.brokerConfig.username,this.brokerConfig.password);
var node = this; var node = this;
this.on("input",function(msg) { this.on("input",function(msg) {
if (msg != null) {
if (msg.qos) { if (msg.qos) {
msg.qos = parseInt(msg.qos); msg.qos = parseInt(msg.qos);
if ((msg.qos !== 0) && (msg.qos !== 1) && (msg.qos !== 2)) { if ((msg.qos !== 0) && (msg.qos !== 1) && (msg.qos !== 2)) {
@ -99,7 +98,6 @@ module.exports = function(RED) {
this.client.publish(msg); // send the message this.client.publish(msg); // send the message
} }
else { node.warn("Invalid topic specified"); } else { node.warn("Invalid topic specified"); }
}
}); });
this.client.on("connectionlost",function() { this.client.on("connectionlost",function() {
node.status({fill:"red",shape:"ring",text:"disconnected"}); node.status({fill:"red",shape:"ring",text:"disconnected"});

View File

@ -244,8 +244,6 @@ module.exports = function(RED) {
access_token_secret: credentials.access_token_secret access_token_secret: credentials.access_token_secret
}); });
node.on("input", function(msg) { node.on("input", function(msg) {
if (msg != null) {
node.status({fill:"blue",shape:"dot",text:"tweeting"}); node.status({fill:"blue",shape:"dot",text:"tweeting"});
if (msg.payload.length > 140) { if (msg.payload.length > 140) {
@ -279,8 +277,6 @@ module.exports = function(RED) {
form.append("status",msg.payload); form.append("status",msg.payload);
form.append("media[]",msg.media,{filename:"image"}); form.append("media[]",msg.media,{filename:"image"});
} else { } else {
twit.updateStatus(msg.payload, function (err, data) { twit.updateStatus(msg.payload, function (err, data) {
if (err) { if (err) {
@ -290,7 +286,6 @@ module.exports = function(RED) {
node.status({}); node.status({});
}); });
} }
}
}); });
} }
} }

View File

@ -69,7 +69,6 @@ module.exports = function(RED) {
}); });
this.on("input", function(msg) { this.on("input", function(msg) {
if (msg != null) {
if (smtpTransport) { if (smtpTransport) {
node.status({fill:"blue",shape:"dot",text:"sending"}); node.status({fill:"blue",shape:"dot",text:"sending"});
var payload = RED.util.ensureString(msg.payload); var payload = RED.util.ensureString(msg.payload);
@ -89,7 +88,6 @@ module.exports = function(RED) {
}); });
} }
else { node.warn("No Email credentials found. See info panel."); } else { node.warn("No Email credentials found. See info panel."); }
}
}); });
} }
RED.nodes.registerType("e-mail",EmailNode,{ RED.nodes.registerType("e-mail",EmailNode,{

View File

@ -79,7 +79,6 @@ module.exports = function(RED) {
}); });
this.on("input", function(msg) { this.on("input", function(msg) {
if (msg != null) {
var k = this.key || msg.topic; var k = this.key || msg.topic;
if (k) { if (k) {
if (this.structtype == "string") { if (this.structtype == "string") {
@ -99,7 +98,6 @@ module.exports = function(RED) {
} else { } else {
this.warn("No key or topic set"); this.warn("No key or topic set");
} }
}
}); });
this.on("close", function() { this.on("close", function() {
redisConnectionPool.close(node.client); redisConnectionPool.close(node.client);