Skip to content

Commit

Permalink
Merge pull request #48 from jason-fox/feature/120-width
Browse files Browse the repository at this point in the history
Amend prettier config to 120 width.
  • Loading branch information
fgalan committed Feb 26, 2019
2 parents d004722 + bae6a6d commit 306ecfb
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 69 deletions.
2 changes: 1 addition & 1 deletion .prettierrc.json
Expand Up @@ -3,7 +3,7 @@
"bracketSpacing": true,
"singleQuote": true,
"parser": "flow",
"printWidth": 100,
"printWidth": 120,
"trailingComma": "none",
"tabWidth": 4
}
3 changes: 1 addition & 2 deletions bin/sigfox-test.js
Expand Up @@ -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: {
Expand Down
9 changes: 2 additions & 7 deletions lib/iotagentCore.js
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down
19 changes: 3 additions & 16 deletions lib/sigfoxHandlers.js
Expand Up @@ -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
Expand All @@ -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);
}
}

Expand Down
12 changes: 2 additions & 10 deletions lib/sigfoxServer.js
Expand Up @@ -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');
Expand Down
11 changes: 1 addition & 10 deletions test/tools/ngsiUtils.js
Expand Up @@ -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',
Expand Down
17 changes: 5 additions & 12 deletions test/unit/deviceProvisioning-test.js
Expand Up @@ -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();
});
});
});

Expand All @@ -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'
Expand All @@ -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'
Expand Down
13 changes: 4 additions & 9 deletions test/unit/plugin-config-test.js
Expand Up @@ -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();
});
});
});

Expand All @@ -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'
Expand Down
3 changes: 1 addition & 2 deletions test/unit/sigfox-parser-test.js
Expand Up @@ -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() {
Expand Down

0 comments on commit 306ecfb

Please sign in to comment.