diff --git a/.prettierrc.json b/.prettierrc.json index e8ed773..8238852 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -3,7 +3,7 @@ "bracketSpacing": true, "singleQuote": true, "parser": "flow", - "printWidth": 100, + "printWidth": 120, "trailingComma": "none", "tabWidth": 4 } \ No newline at end of file diff --git a/bin/sigfox-test.js b/bin/sigfox-test.js index 7162092..2b1b713 100755 --- a/bin/sigfox-test.js +++ b/bin/sigfox-test.js @@ -72,8 +72,7 @@ function setParameters(commands) { var commands = { showParameters: { parameters: [], - description: - '\tShow the current device parameters that will be sent along with the callback', + description: '\tShow the current device parameters that will be sent along with the callback', handler: showParameters }, setParameters: { diff --git a/lib/iotagentCore.js b/lib/iotagentCore.js index 06f6d59..3f6d394 100644 --- a/lib/iotagentCore.js +++ b/lib/iotagentCore.js @@ -42,9 +42,7 @@ function deviceProvisioningMiddleware(device, callback) { var mappingFound = false; if (device.internalAttributes) { for (var i = 0; i < device.internalAttributes.length; i++) { - config - .getLogger() - .debug('device provisioning handler %s', device.internalAttributes[i]); + config.getLogger().debug('device provisioning handler %s', device.internalAttributes[i]); if (device.internalAttributes[i].mapping) { mappingFound = true; } @@ -75,10 +73,7 @@ function start(newConfig, callback) { config.setConfig(newConfig); async.series( - [ - apply(sigfoxServer.start, config.getConfig()), - apply(iotAgentLib.activate, config.getConfig().iota) - ], + [apply(sigfoxServer.start, config.getConfig()), apply(iotAgentLib.activate, config.getConfig().iota)], function(error, results) { if (error) { callback(error); diff --git a/lib/sigfoxHandlers.js b/lib/sigfoxHandlers.js index 79e8f5f..cd9d49d 100644 --- a/lib/sigfoxHandlers.js +++ b/lib/sigfoxHandlers.js @@ -78,23 +78,13 @@ function generatePayload(queryParams, device, callback) { error ); } else { - config - .getLogger() - .debug( - context, - 'Single measure for device [%s] successfully updated', - device.id - ); + config.getLogger().debug(context, 'Single measure for device [%s] successfully updated', device.id); } }); callback(); } - if ( - device.internalAttributes && - device.internalAttributes.length === 1 && - device.internalAttributes[0].mapping - ) { + if (device.internalAttributes && device.internalAttributes.length === 1 && device.internalAttributes[0].mapping) { async.waterfall( [apply(decode, queryParams.data, device.internalAttributes[0].mapping), createPayload], callback @@ -112,10 +102,7 @@ function generatePayload(queryParams, device, callback) { callback(new errors.ErrorLoadingPlugin(plugin)); } } else { - async.waterfall( - [apply(mappings.get, device.type), apply(decode, queryParams.data), createPayload], - callback - ); + async.waterfall([apply(mappings.get, device.type), apply(decode, queryParams.data), createPayload], callback); } } diff --git a/lib/sigfoxServer.js b/lib/sigfoxServer.js index 4e52dfb..6e39a4c 100644 --- a/lib/sigfoxServer.js +++ b/lib/sigfoxServer.js @@ -73,16 +73,8 @@ function start(newConfig, callback) { router: express.Router() }; - config - .getLogger() - .info( - context, - 'Starting Sigfox server listening on port [%s]', - config.getConfig().sigfox.port - ); - config - .getLogger() - .debug(context, 'Using config:\n\n%s\n', JSON.stringify(config.getConfig(), null, 4)); + config.getLogger().info(context, 'Starting Sigfox server listening on port [%s]', config.getConfig().sigfox.port); + config.getLogger().debug(context, 'Using config:\n\n%s\n', JSON.stringify(config.getConfig(), null, 4)); iotServer.app.set('port', config.getConfig().sigfox.port); iotServer.app.set('host', '0.0.0.0'); diff --git a/test/tools/ngsiUtils.js b/test/tools/ngsiUtils.js index 987a93f..6ad8e1d 100644 --- a/test/tools/ngsiUtils.js +++ b/test/tools/ngsiUtils.js @@ -104,16 +104,7 @@ function queryEntity(host, port, service, subservice, id, type, attributes, call * @param {String} type Type of the entity to query. * @param {Array} attributes List of attributes to retrieve. */ -function discoverContextAvailability( - host, - port, - service, - subservice, - id, - type, - attributes, - callback -) { +function discoverContextAvailability(host, port, service, subservice, id, type, attributes, callback) { var options = { url: 'http://' + host + ':' + port + '/v1/registry/discoverContextAvailability ', method: 'POST', diff --git a/test/unit/deviceProvisioning-test.js b/test/unit/deviceProvisioning-test.js index 9794d96..2451bf4 100644 --- a/test/unit/deviceProvisioning-test.js +++ b/test/unit/deviceProvisioning-test.js @@ -43,12 +43,9 @@ var iotAgent = require('../../lib/iotagentCore'), describe('Device and configuration provisioning', function() { beforeEach(function(done) { iotAgent.start(config, function(error) { - async.series( - [apply(mongoUtils.cleanDbs, config.iota.contextBroker.host), mappings.clean], - function(error) { - done(); - } - ); + async.series([apply(mongoUtils.cleanDbs, config.iota.contextBroker.host), mappings.clean], function(error) { + done(); + }); }); }); @@ -59,9 +56,7 @@ describe('Device and configuration provisioning', function() { var provisioningOpts = { url: 'http://localhost:' + config.iota.server.port + '/iot/devices', method: 'POST', - json: utils.readExampleFile( - './test/examples/deviceProvisioning/deviceProvisioningNoMapping.json' - ), + json: utils.readExampleFile('./test/examples/deviceProvisioning/deviceProvisioningNoMapping.json'), headers: { 'fiware-service': 'dumbMordor', 'fiware-servicepath': '/deserts' @@ -81,9 +76,7 @@ describe('Device and configuration provisioning', function() { var provisioningOpts = { url: 'http://localhost:' + config.iota.server.port + '/iot/devices', method: 'POST', - json: utils.readExampleFile( - './test/examples/deviceProvisioning/deviceProvisioningRightMapping.json' - ), + json: utils.readExampleFile('./test/examples/deviceProvisioning/deviceProvisioningRightMapping.json'), headers: { 'fiware-service': 'dumbMordor', 'fiware-servicepath': '/deserts' diff --git a/test/unit/plugin-config-test.js b/test/unit/plugin-config-test.js index 697a8b9..2965df4 100644 --- a/test/unit/plugin-config-test.js +++ b/test/unit/plugin-config-test.js @@ -43,12 +43,9 @@ var iotAgent = require('../../lib/iotagentCore'), describe('Plugin configuration test', function() { beforeEach(function(done) { iotAgent.start(config, function() { - async.series( - [apply(mongoUtils.cleanDbs, config.iota.contextBroker.host), mappings.clean], - function() { - done(); - } - ); + async.series([apply(mongoUtils.cleanDbs, config.iota.contextBroker.host), mappings.clean], function() { + done(); + }); }); }); @@ -60,9 +57,7 @@ describe('Plugin configuration test', function() { var provisioningOpts = { url: 'http://localhost:' + config.iota.server.port + '/iot/devices', method: 'POST', - json: utils.readExampleFile( - './test/examples/deviceProvisioning/deviceProvisioningPluginMapping.json' - ), + json: utils.readExampleFile('./test/examples/deviceProvisioning/deviceProvisioningPluginMapping.json'), headers: { 'fiware-service': 'dumbMordor', 'fiware-servicepath': '/deserts' diff --git a/test/unit/sigfox-parser-test.js b/test/unit/sigfox-parser-test.js index 799e484..521227b 100644 --- a/test/unit/sigfox-parser-test.js +++ b/test/unit/sigfox-parser-test.js @@ -24,8 +24,7 @@ var sigfoxParser = require('../../lib/sigfoxParser'), should = require('should'), - key = - 'counter::uint:32 param1::uint:32 param2::uint:8 tempDegreesCelsius::uint:8 voltage::uint:16'; + key = 'counter::uint:32 param1::uint:32 param2::uint:8 tempDegreesCelsius::uint:8 voltage::uint:16'; describe('Parsing modules', function() { describe('A data payload "000000020000000000230c6f" is parsed with the given key', function() {