Skip to content

Commit f2f4e65

Browse files
committed
Codacy Fixes
1 parent 3ddc181 commit f2f4e65

6 files changed

Lines changed: 36 additions & 39 deletions

File tree

services/assistant/v2.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ module.exports = function(RED) {
5454
username : sUsername || node.credentials.username,
5555
password : sPassword || node.credentials.password || config.password,
5656
apikey : sApikey || node.credentials.apikey || config.apikey,
57-
}
57+
};
5858

5959
if (msg.params) {
6060
if (msg.params.username) {
@@ -191,10 +191,11 @@ module.exports = function(RED) {
191191

192192
function setServiceSettings(msg, creds) {
193193
const serviceSettings = {
194-
headers: {
195-
'User-Agent': pkg.name + '-' + pkg.version
196-
}
194+
headers: {
195+
'User-Agent': pkg.name + '-' + pkg.version
196+
}
197197
};
198+
198199
let endpoint = '',
199200
optoutLearning = false,
200201
version = SERVICE_VERSION;
@@ -254,7 +255,7 @@ module.exports = function(RED) {
254255

255256
function buildService(settings) {
256257
node.service = new AssistantV2(settings);
257-
return Promise.resolve()
258+
return Promise.resolve();
258259
}
259260

260261
function checkSession(params) {
@@ -267,16 +268,14 @@ module.exports = function(RED) {
267268
}, function(err, response) {
268269
if (err) {
269270
reject(err);
270-
} else {
271-
if (response && response.session_id) {
272-
params.session_id = response.session_id;
273-
if (!config.multisession) {
274-
node.context().flow.set('session_id', params.session_id);
275-
}
276-
resolve();
277-
} else {
278-
reject('Unable to set session');
271+
} else if (response && response.session_id) {
272+
params.session_id = response.session_id;
273+
if (!config.multisession) {
274+
node.context().flow.set('session_id', params.session_id);
279275
}
276+
resolve();
277+
} else {
278+
reject('Unable to set session');
280279
}
281280
});
282281
}

services/discovery/v1.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ module.exports = function (RED) {
263263

264264
function executeMethod(node, method, params, msg) {
265265
let discovery = discoveryutils.buildService(username, password, apikey, endpoint);
266+
var p = null;
266267

267268
switch (method) {
268269
case 'createEnvrionment':

services/language_translator/v3-doc.js

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ module.exports = function (RED) {
7474
lt.listModels({}, function (err, models) {
7575
if (err) {
7676
res.json(err);
77-
}
78-
else {
77+
} else {
7978
res.json(models);
8079
}
8180
});
@@ -164,7 +163,7 @@ module.exports = function (RED) {
164163
try {
165164
data = JSON.parse(body);
166165
} catch(e) {
167-
data = body
166+
data = body;
168167
}
169168
resolve(data);
170169
break;
@@ -260,24 +259,12 @@ module.exports = function (RED) {
260259
if (msg && msg.filename) {
261260
name = msg.filename;
262261
} else if (config && config.filename ) {
263-
name = config.filename
262+
name = config.filename;
264263
}
265264
name = name.replace(/[^0-9a-z]/gi, '');
266265
return (name + suffix);
267266
}
268267

269-
function docID(msg) {
270-
if (msg.payload && 'string' === typeof msg.payload) {
271-
return msg.payload;
272-
} else if (msg.payload &&
273-
'object' === typeof msg.payload &&
274-
msg.payload.document_id) {
275-
return msg.payload.document_id;
276-
} else {
277-
return config['document-id'];
278-
}
279-
}
280-
281268
function sourceLang(msg) {
282269
if (msg.payload &&
283270
'object' === typeof msg.payload &&
@@ -288,6 +275,18 @@ module.exports = function (RED) {
288275
return msg.srclang ? msg.srclang : config.srclang;
289276
}
290277

278+
function docID(msg) {
279+
if (msg.payload && 'string' === typeof msg.payload) {
280+
return msg.payload;
281+
}
282+
if (msg.payload &&
283+
'object' === typeof msg.payload &&
284+
msg.payload.document_id) {
285+
return msg.payload.document_id;
286+
}
287+
return config['document-id'];
288+
}
289+
291290
function executePostRequest(uriAddress, params, msg) {
292291
return new Promise(function resolver(resolve, reject){
293292
var authSettings = buildAuthSettings();
@@ -298,7 +297,7 @@ module.exports = function (RED) {
298297
auth: authSettings,
299298
formData: params
300299
}, (error, response, body) => {
301-
if (!error && response.statusCode == 200) {
300+
if (!error && response.statusCode === 200) {
302301
let data = JSON.parse(body);
303302
resolve(data);
304303
} else if (error) {
@@ -407,7 +406,7 @@ module.exports = function (RED) {
407406
'documentStatus' : executeGetDocumentStatus,
408407
'deleteDocument' : executeDeleteDocument,
409408
'getDocument' : executeGetDocument
410-
}
409+
};
411410

412411
f = execute[action] || executeUnknownMethod;
413412
node.status({ fill: 'blue', shape: 'dot', text: 'processing' });

services/natural_language_understanding/v1.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ module.exports = function (RED) {
8383
var limitCharacters = parseInt(config.limittextcharacters);
8484

8585
if (! isNaN(limitCharacters) && 0 < limitCharacters) {
86-
options.limit_text_characters = limitCharacters
86+
options.limit_text_characters = limitCharacters;
8787
}
8888

8989
return Promise.resolve();

services/personality_insights/v3.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ module.exports = function (RED) {
5151
if (!msg.payload) {
5252
return Promise.reject('Missing property: msg.payload');
5353
}
54-
if ('string' !== typeof msg.payload &&
54+
if ('string' !== typeof msg.payload &&
5555
'object' !== typeof msg.payload) {
5656
return Promise.reject('submitted msg.payload is not text or json object');
5757
}

utilities/payload-utils.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,12 @@ PayloadUtils.prototype = {
157157
// Function that is returns a function to count
158158
// the characters in each language.
159159
word_count: function(ct) {
160-
var count = require('word-count') ;
160+
var count = require('word-count'),
161161
fn = function(txt, cb) {
162162
// default
163163
return cb(txt.split(' ').length);
164-
},
165-
dic_path = '/../../kuromoji/dict',
166-
dic_dir = path.normalize(__dirname + dic_path),
167-
tokenizer = null;
164+
};
165+
168166
if (ct === 'ja') {
169167
fn = function(txt, cb) {
170168
cb(200);

0 commit comments

Comments
 (0)