nus-mtp/attack-on-tutor

View on GitHub

Showing 17 of 111 total issues

File lobby.js has 434 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * Server side code for the lobby, manages socket events and communication between clients within the lobby page.
 *
 * @module model/lobby
 * @type {*|exports|module.exports}
Severity: Minor
Found in source/model/lobby.js - About 6 hrs to fix

    Function forceSyncIVLE has 97 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    var forceSyncIVLE = function (uid) {
        return new Promise(function (fulfill, reject) {
            User.findOne( {
                where: {
                    id: uid
    Severity: Major
    Found in source/model/Tutorial.js - About 3 hrs to fix

      Function forceSyncIVLE has 96 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      var forceSyncIVLE = function (uid) {
          return new Promise(function (fulfill, reject) {
              User.findOne( {
                  where: {
                      id: uid
      Severity: Major
      Found in source/controller/ivle.js - About 3 hrs to fix

        Function up has 75 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            up: function(queryInterface, Sequelize) {
        
                var promises = [];
        
                promises.push(queryInterface.createTable('Users', {
        Severity: Major
        Found in migrations/migration-1.js - About 3 hrs to fix

          Function callback has 58 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          var callback = function (req, res, next) {
              var ivleToken = req.query.token;
              var apikey = app.get ('api-key');
          
              //view profile
          Severity: Major
          Found in source/controller/login.js - About 2 hrs to fix

            Function up has 58 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                up: function(queryInterface, Sequelize) {
            
                    var promises = [];
            
                    promises.push(queryInterface.createTable('userTutorials', {
            Severity: Major
            Found in migrations/migration-3.js - About 2 hrs to fix

              Function exports has 52 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              module.exports = function (sequelize, DataTypes) {
                  var Tutorial = sequelize.define ('Tutorial', {
                      id: {
                          type: DataTypes.UUID,
                          defaultValue: DataTypes.UUIDV4,
              Severity: Major
              Found in models/tutorial.js - About 2 hrs to fix

                Function exports has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                module.exports = function(sequelize, DataTypes) {
                
                    var User = sequelize.define('User', {
                        id: {
                            type: DataTypes.STRING,
                Severity: Minor
                Found in models/user.js - About 2 hrs to fix

                  Function removeGroup has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                  Lobby.prototype.removeGroup = function (group) {
                      if (this.groups[group]) {
                          var groupname = this.namespace + '/' + group;
                          var socketsInRoom = lobbyio.adapter.rooms[groupname];
                          if (socketsInRoom) {
                  Severity: Minor
                  Found in source/model/lobby.js - About 1 hr to fix

                  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

                  Function checkAddQuestion has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          var checkAddQuestion = function (socket) {
                              socket.on ('add question', function (data) {
                                  questionUUID = data.question.uuid;
                  
                                  chatUser1.username.should.equal (data.username);
                  Severity: Minor
                  Found in source/test/lobby-lobby-quiz-test.js - About 1 hr to fix

                    Function enterLobby has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    var enterLobby = function (req, res, next) {
                    
                        var user = req.body.auth.decoded;
                        var userId = user.id;
                        var coursecode = req.params.moduleId;
                    Severity: Minor
                    Found in source/controller/lobby.js - About 1 hr to fix

                      Function getUsersInRoom has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                      Lobby.prototype.getUsersInRoom = function (roomName) {
                          var roomName = this.getRoomName (roomName);
                          var userSockets = [];
                          var socketsInRoom = lobbyio.adapter.rooms[roomName];
                          if (socketsInRoom) {
                      Severity: Minor
                      Found in source/model/lobby.js - About 1 hr to fix

                      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

                      Function processUserInfo has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      var processUserInfo = function (result) {
                          var user = result.rows[0].dataValues;
                          var returnObject = {}
                          returnObject.name = user.name;
                          returnObject.avatarId = user.avatarId;
                      Severity: Minor
                      Found in source/controller/dashboard.js - About 1 hr to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                    if (lobby.questions[questionUuid].selectedAnswers.hasOwnProperty (selectedAnswerSocketId)) {
                                                        if (lobby.questions[questionUuid].selectedAnswers[selectedAnswerSocketId] == answerSocketId) {
                                                            lobby.questions[questionUuid].answers[answerSocketId].selectedCount++;
                                                        }
                                                    }
                        Severity: Major
                        Found in source/model/lobby.js - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  if ($scope.questions[questionUuid].answers[i].student.socketId == answerSocketId) {
                                                      $scope.questions[questionUuid].answers[i].selectedCount = selectedCounts[answerSocketId];
                                                  }
                          Severity: Major
                          Found in public/javascripts/Lobby/lobby-angular-student-controller.js - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                if (lobbyio.connected[socketId]) {
                                                    lobbyio.connected[socketId].leave (groupname);
                                                }
                            Severity: Major
                            Found in source/model/lobby.js - About 45 mins to fix

                              Function splitArrayIntoThrees has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

                              var splitArrayIntoThrees = function (array) {
                                  var result = [];
                                  var row = [];
                                  for (index in array) {
                                      if (index % 3 == 0) {
                              Severity: Minor
                              Found in public/javascripts/dashboard/dashboard-avatar-controller.js - About 25 mins to fix

                              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

                              Severity
                              Category
                              Status
                              Source
                              Language