Emapic/emapic

View on GitHub

Showing 122 of 2,019 total issues

Function findPublicSurveysByUserLogin has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    Survey.findPublicSurveysByUserLogin = function(login, status, query, tag, order, pageSize, pageNr) {
Severity: Major
Found in models/survey.js - About 50 mins to fix

    Function findPublicSurveys has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        Survey.findPublicSurveys = function(userId, status, query, tag, order, pageSize, pageNr) {
    Severity: Major
    Found in models/survey.js - About 50 mins to fix

      Function getScopes has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          Survey.getScopes = function(userId, onlyPublic, status, query, tag, order) {
      Severity: Minor
      Found in models/survey.js - About 45 mins to fix

        Function transformImage has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                transformImage: function(input, width, height, upscale, format, outputFile) {
        Severity: Minor
        Found in utils.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if (!qstnFound) {
                                      continue;
                                  }
          Severity: Major
          Found in models/survey.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                        if (!/^[A-Za-z0-9_.\-~]+$/.test(req.body.login)) {
                            req.session.error = 'username_invalid_error_msg';
                            Utils.copyAttributes({
                                userFormData: req.body
                            }, res.locals);
            Severity: Major
            Found in routes/auth/index.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if (!(('option_' + i + '_other') in req.body) || req.body['option_' + i + '_other'].trim() === '') {
                                          break;
                                      }
              Severity: Major
              Found in models/question.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                            if (ansId === questions[l].Answers[m].sortorder) {
                                                ans = questions[l].Answers[m].answer;
                                            }
                Severity: Major
                Found in routes/utils_api.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                              if (questions[j].Answers[l].sortorder === -1) {
                                                  otherAns = questions[j].Answers[l];
                                                  break;
                                              }
                  Severity: Major
                  Found in routes/utils_api.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            for (var i = 0, iLen = questions.length; i<iLen; i++) {
                                                if (questions[i].legend_question && questions[i].question_order === q) {
                                                    qstnFound = true;
                                                    break;
                                                }
                    Severity: Major
                    Found in models/survey.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if (answerImg === null && oldAnswers !== null) {
                                                  // If not and we have old answers, we recycle the image previously used for this answer
                                                  if (!isNaN(req.body['id_' + i + '_' + j])) {
                                                      var originalId = parseInt(req.body['id_' + i + '_' + j], 10);
                                                      images:
                      Severity: Major
                      Found in models/question.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                                if (answers[i].sortorder === -1) {
                                                                    otherAnswer = answers[i];
                                                                    continue;
                                                                }
                        Severity: Major
                        Found in models/question.js - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  if (!(Utils.isImage(fs.readFileSync(req.files['img_' + i + '_' + j].path)))) {
                                                      return Promise.reject({
                                                          message: "invalid image for question nr " + i + " answer nr " + j + ": selected file is not an image.",
                                                          code: 'answer_img_invalid'
                                                      });
                          Severity: Major
                          Found in models/question.js - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                    if (!(('option_' + i + '_other') in req.body) || req.body['option_' + i + '_other'].trim() === '') {
                                                        break;
                                                    }
                            Severity: Major
                            Found in models/question.js - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              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);
                              Severity: Major
                              Found in routes/auth/index.js - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                        if ('q' + questions[q].question_order === l) {
                                                            question = questions[q];
                                                            break;
                                                        }
                                Severity: Major
                                Found in routes/utils_api.js - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                          if (question !== null) {
                                                              var answer = null;
                                                              for (var n = 0, nLen = answers[question.question_order].length; n<nLen; n++) {
                                                                  if (answers[question.question_order][n].sortorder === orderedVotes[l][m].name.split('_')[1]) {
                                                                      answer = answers[question.question_order][n];
                                  Severity: Major
                                  Found in routes/utils_api.js - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                                if (ansId === questions[j].Answers[l].sortorder) {
                                                                    ans = questions[j].Answers[l].answer;
                                                                }
                                    Severity: Major
                                    Found in routes/utils_api.js - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                              } else if (req.body.preferences) {
                                                  // Other preferences update
                                                  req.user.accept_info_email = req.body.accept_info_email = 'accept_info_email' in req.body
                                                  req.user.save().then(function(user) {
                                                      req.session.success = 'update_preferences_success_msg';
                                      Severity: Major
                                      Found in routes/auth/index.js - About 45 mins to fix

                                        Avoid deeply nested control flow statements.
                                        Open

                                                                    if (answers[questions[j].question_order][k].sortorder === parseInt(results[i]['q' + questions[j].question_order + '.id'], 10)) {
                                                                        answer = answers[questions[j].question_order][k];
                                                                        break;
                                                                    }
                                        Severity: Major
                                        Found in routes/utils_api.js - About 45 mins to fix
                                          Severity
                                          Category
                                          Status
                                          Source
                                          Language