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}
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
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
Function up
has 75 lines of code (exceeds 25 allowed). Consider refactoring. Open
up: function(queryInterface, Sequelize) {
var promises = [];
promises.push(queryInterface.createTable('Users', {
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
Function up
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
up: function(queryInterface, Sequelize) {
var promises = [];
promises.push(queryInterface.createTable('userTutorials', {
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,
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,
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) {
- 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
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);
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;
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) {
- 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
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;
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++;
}
}
Avoid deeply nested control flow statements. Open
if ($scope.questions[questionUuid].answers[i].student.socketId == answerSocketId) {
$scope.questions[questionUuid].answers[i].selectedCount = selectedCounts[answerSocketId];
}
Avoid deeply nested control flow statements. Open
if (lobbyio.connected[socketId]) {
lobbyio.connected[socketId].leave (groupname);
}
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) {
- 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"