| Conditions | 2 | 
| Paths | 2 | 
| Total Lines | 48 | 
| Code Lines | 30 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 6 | ||
| Bugs | 0 | Features | 0 | 
| 1 | 'use strict'  | 
            ||
| 3 | module.exports = (input, callback) => { | 
            ||
| 4 | 	const mqtt = require('mqtt') | 
            ||
| 5 | 	const configuration = require('./configuration') | 
            ||
| 6 | 	const validate = require('./validate') | 
            ||
| 7 | let error = null  | 
            ||
| 8 | let output = null  | 
            ||
| 9 | |||
| 10 | 	validate.configuration(input, (validatedInput, thrownError) => { | 
            ||
| 11 | input = validatedInput  | 
            ||
| 12 | error = thrownError  | 
            ||
| 13 | })  | 
            ||
| 14 | |||
| 15 | // Send MQTT  | 
            ||
| 16 | 	if ( !error ) { | 
            ||
| 17 | let configurationMqtt = configuration.mqtt(input)  | 
            ||
| 18 | let client = mqtt.connect(input.source.url, configurationMqtt)  | 
            ||
| 19 | |||
| 20 | 		client.on('connect', () => { | 
            ||
| 21 | 			client.subscribe(input.source.topic, (errorConnection) => { | 
            ||
| 22 | 				if ( !errorConnection ) { | 
            ||
| 23 | 					client.publish(input.source.topic, input.params.payload, { | 
            ||
| 24 | qos: input.params.qos,  | 
            ||
| 25 | retain: false  | 
            ||
| 26 | })  | 
            ||
| 27 | 				} else { | 
            ||
| 28 | error = errorConnection  | 
            ||
| 29 | }  | 
            ||
| 30 | })  | 
            ||
| 31 | })  | 
            ||
| 32 | |||
| 33 | 		client.on('message', (topic, message) => { | 
            ||
| 34 | client.end()  | 
            ||
| 35 | })  | 
            ||
| 36 | |||
| 37 | 		output = { | 
            ||
| 38 | 			'version': {'ref': 'output'}, | 
            ||
| 39 | 'metadata': [  | 
            ||
| 40 | 				{'name': 'message', 'value': input.params.payload.toString()}, | 
            ||
| 41 | 				{'name': 'qos', 'value': input.params.qos.toString()}, | 
            ||
| 42 | 				{'name': 'timestamp', 'value': Date.now().toString()}, | 
            ||
| 43 | 				{'name': 'topic', 'value': input.source.topic} | 
            ||
| 44 | ]  | 
            ||
| 45 | }  | 
            ||
| 46 | }  | 
            ||
| 47 | |||
| 48 | callback(error, output)  | 
            ||
| 49 | |||
| 50 | }  | 
            ||
| 51 | 
This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.