Showing 122 of 2,019 total issues
Avoid deeply nested control flow statements. Open
Open
if (ansId === questions[l].Answers[n].sortorder) {
ans = questions[l].Answers[n].answer;
}
Avoid deeply nested control flow statements. Open
Open
if (ansId === questions[j].Answers[l].sortorder) {
ans = questions[j].Answers[l].answer;
break;
}
Avoid deeply nested control flow statements. Open
Open
if (isNaN(q)) {
continue;
}
Avoid deeply nested control flow statements. Open
Open
if ((answer.sortorder === -1) && (('q' + questions[j].question_order + '.value') in results[i])) {
value = answer.answer + ' (' + results[i]['q' + questions[j].question_order + '.value'] + ')';
} else {
value = answer.answer;
}
Avoid deeply nested control flow statements. Open
Open
if (req.files['img_' + i + '_' + j].size > 2000000) {
return Promise.reject({
message: "invalid image for question nr " + i + " answer nr " + j + ": image file exceeds the 2MB max size.",
code: 'answer_img_too_big'
});
Consider simplifying this complex logical expression. Open
Open
} else if (err && err.name === 'SequelizeUniqueConstraintError' &&
((err.errors && err.errors.constructor === Array && err.errors[0].path === 'login') ||
(err.message.indexOf('users_login_key') > -1))) {
req.session.error = 'username_duplicated_error_msg';
logger.debug('Login already in use: ' + err);
Consider simplifying this complex logical expression. Open
Open
if (err && err.name === 'SequelizeUniqueConstraintError' &&
((err.errors && err.errors.constructor === Array && err.errors[0].path === 'email') ||
(err.message.indexOf('users_email_key') > -1))) {
req.session.error = 'email_duplicated_error_msg';
logger.debug('E-mail already exists: ' + err);
Consider simplifying this complex logical expression. Open
Open
if (err && err.name === 'SequelizeUniqueConstraintError' &&
((err.errors && err.errors.constructor === Array && err.errors[0].path === 'login') ||
(err.message.indexOf('users_login_key') > -1))) {
user.login = originalLogin;
return nextLoginUserSignup(user, tryNr + 1);
Consider simplifying this complex logical expression. Open
Open
if (err && err.name === 'SequelizeUniqueConstraintError' &&
((err.errors && err.errors.constructor === Array && err.errors[0].path === 'login') ||
(err.message.indexOf('users_login_key') > -1))) {
req.session.error = 'username_duplicated_error_msg';
logger.debug('Login already in use: ' + err);
Function getPaginationHtml
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
getPaginationHtml: function(req, pageNr, pageSize, totalResults, elementName) {
Function generateTextInputQuestionHtml
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function generateTextInputQuestionHtml(question, validator, maxLength, placeholderText, req) {
Function transformImageSharp
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function transformImageSharp(input, width, height, upscale, format) {
Function generateTextAreaQuestionHtml
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function generateTextAreaQuestionHtml(question, validator, maxLength, placeholderText, req) {
Function transformImageJimp
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function transformImageJimp(input, width, height, upscale, format) {
Function generateTextInputQuestionHtml
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
function generateTextInputQuestionHtml(question, validator, maxLength, placeholderText, req) {
var opt = req.i18n.__('optional_note'),
max = req.i18n.__('max_length_note'),
validator = validator || null,
mandatory = question.mandatory;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid too many return
statements within this function. Open
Open
return Promise.reject({
message: "invalid answer for question nr " + question.question_order + " : selected file is not an image.",
status: 400,
code: 'invalid_request'
});
Avoid too many return
statements within this function. Open
Open
return Promise.resolve();
Avoid too many return
statements within this function. Open
Open
return Promise.resolve();
Avoid too many return
statements within this function. Open
Open
return Promise.reject({
message: "invalid answer for question nr " + question.question_order + " : image file exceeds the 10MB max size.",
status: 400,
code: 'invalid_request'
});
Avoid too many return
statements within this function. Open
Open
return Utils.checkUrlIsImage(responses['q' + question.question_order + '.value']);