-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fiqare secmotic rules #411
base: master
Are you sure you want to change the base?
Changes from 3 commits
3e79647
85f7388
da9359c
a2e11f6
46f6126
2e0a51d
662a458
9dfbdcb
484e833
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,7 @@ var http = require('http'), | |
}, | ||
transport = 'HTTP'; | ||
|
||
function handleError(error, req, res, next) { | ||
function handleError(error, req, res) { | ||
var code = 500; | ||
|
||
config.getLogger().debug(context, 'Error [%s] handing request: %s', error.name, error.message); | ||
|
@@ -135,7 +135,7 @@ function checkMandatoryParams(queryPayload) { | |
* This middleware checks whether there is any polling command pending to be sent to the device. If there is some, | ||
* add the command information to the return payload. Otherwise it returns an empty payload. | ||
*/ | ||
function returnCommands(req, res, next) { | ||
function returnCommands(req, res) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly to handleError() the solution should be to call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed in a2e11f6 |
||
function updateCommandStatus(device, commandList) { | ||
var updates, cleanCommands; | ||
|
||
|
@@ -159,7 +159,7 @@ function returnCommands(req, res, next) { | |
updates = commandList.map(createCommandUpdate); | ||
cleanCommands = commandList.map(cleanCommand); | ||
|
||
async.parallel(updates.concat(cleanCommands), function(error, results) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In that case the fix should be to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this case we continue to rely on ISO 25010 to improve software quality. Mainly: Rule 1: Unused function parameters should be removed, based on:
So, this is fixed in a2e11f6 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We agree that unused parameters should be avoided. However, we are proposing a different solution for this case: instead of removing the unused What do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Based on the maintainability axis of ISO 25010, I think it is counterproductive to add code to the function to use a variable that is currently deprecated, which makes it less readable. Therefore, before adding code that will not be functional, I prefer to leave the function as it was, with the variable "results". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed in 9dfbdcb |
||
async.parallel(updates.concat(cleanCommands), function(error) { | ||
if (error) { | ||
// prettier-ignore | ||
config.getLogger().error( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,7 +115,7 @@ function manageConfigurationRequest(apiKey, deviceId, device, objMessage) { | |
* @param {Number} index Index of the group in the array. | ||
* @return {Array} Updated array of functions. | ||
*/ | ||
function processMeasureGroup(device, apikey, previous, current, index) { | ||
function processMeasureGroup(device, apikey, previous, current) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. JavaDoc entry for index (L115) should be removed also. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed in 662a458 |
||
var values = []; | ||
|
||
if (current.command) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -154,6 +154,8 @@ function mergeDeviceWithConfiguration(deviceData, configuration, callback) { | |
deviceData[fields[i]] = configuration[confField]; | ||
} else if (!deviceData[fields[i]] && (!configuration || !configuration[confField])) { | ||
deviceData[fields[i]] = defaults[i]; | ||
} else { | ||
config.getLogger().debug(context, 'at field %d configuration merging logic did not merge anything', i); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is "%d" the right formatter for integer in JavaScript? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changing log from error to debug level, sure? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably you are seeing a partical commit... if you clear filters in diff tab the actual change shown is the addition of the a debug line. I mean, there wasn't any error() logging here before. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you're right There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Confirmed "%d" is correct. Thus NTC (I guess) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed in a2e11f6 |
||
} | ||
|
||
if (deviceData[fields[i]] && ['active', 'lazy', 'commands'].indexOf(fields[i]) >= 0) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if the fix for this is removing next from the signature of the function of this change is actually raising another kind of bug in the function: it should call next() upon completion but it is not doing it.
A similar case would be the one with returnCommands() modification, some lines below.
@AlvaroVega what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess express is expecting always a function with req, res, next) args
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have been discussing this case with @AlvaroVega and the solution here shouldn't be to remove "next" for the parametrs, but adding the
next();
call to the end of the function, i.e. just after L59.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in a2e11f6