e-ucm/rage-analytics-backend

View on GitHub
lib/activities.js

Summary

Maintainability
F
1 wk
Test Coverage

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

module.exports = (function () {
    var Q = require('q');
    var Collection = require('easy-collections');
    var async = require('async');
    var db = require('./db');
Severity: Major
Found in lib/activities.js - About 3 days to fix

    Function exports has a Cognitive Complexity of 97 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports = (function () {
        var Q = require('q');
        var Collection = require('easy-collections');
        var async = require('async');
        var db = require('./db');
    Severity: Minor
    Found in lib/activities.js - About 1 day 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

    File activities.js has 642 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    'use strict';
    
    module.exports = (function () {
        var Q = require('q');
        var Collection = require('easy-collections');
    Severity: Major
    Found in lib/activities.js - About 1 day to fix

      Function getUserActivities has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          var getUserActivities = function (user, otherfilters) {
              otherfilters = otherfilters || {};
      
              var deferred = Q.defer();
              async.parallel({
      Severity: Minor
      Found in lib/activities.js - About 1 hr to fix

        Function isAuthorizedFor has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            activities.isAuthorizedFor = function(activityId, username, method, call) {
                var deferred = Q.defer();
        
                if (!minTypes[method] || !minTypes[method][call] || !minTypes[method][call].type) {
                    deferred.reject({
        Severity: Minor
        Found in lib/activities.js - About 1 hr to fix

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

              activities.modifyActivity = function (activityId, body, add) {
          
                  return activities.find(activities.toObjectID(activityId), true)
                      .then(function (activity) {
                          if (!activity) {
          Severity: Minor
          Found in lib/activities.js - About 1 hr to fix

            Function results has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                activities.results = function (activityId, username, esClient) {
                    return activities.find(activities.toObjectID(activityId), true)
                        .then(function (activity) {
            
                            if (!activity) {
            Severity: Minor
            Found in lib/activities.js - About 1 hr to fix

              Function updateResult has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  activities.updateResult = function (activityId, resultId, update, username, esClient) {
                      return activities.find(activities.toObjectID(activityId), true)
                          .then(function (activity) {
                              if (!activity) {
                                  throw {
              Severity: Minor
              Found in lib/activities.js - About 1 hr to fix

                Function getGameVersionAndClass has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    var getGameVersionAndClass = function (gameId, versionId, classId) {
                        return games.findById(gameId).then(function (game) {
                            if (!game) {
                                throw {
                                    message: 'Game does not exist',
                Severity: Minor
                Found in lib/activities.js - About 1 hr to fix

                  Function createActivity has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      activities.createActivity = function (gameId, versionId, classId, username, name, rootId, offline, allowAnonymous) {
                          return getGameVersionAndClass(gameId, versionId, classId).then(function (result) {
                              if (!name) {
                                  name = 'new Activity';
                              }
                  Severity: Minor
                  Found in lib/activities.js - About 1 hr to fix

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

                        activities.deleteUserData = function (defaultConfig, activityId, userData, esClient) {
                            return activities.findById(activityId, true).then(function(result) {
                                if (!result) {
                                    throw {
                                        message: 'Activity not found',
                    Severity: Minor
                    Found in lib/activities.js - About 1 hr to fix

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

                          activities.startActivity = function (activityId) {
                              return activities.findById(activityId).then(function (activity) {
                                  if (!activity) {
                                      throw {
                                          message: 'Activity does not exist',
                      Severity: Minor
                      Found in lib/activities.js - About 1 hr to fix

                        Function createActivity has 8 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            activities.createActivity = function (gameId, versionId, classId, username, name, rootId, offline, allowAnonymous) {
                        Severity: Major
                        Found in lib/activities.js - About 1 hr to fix

                          Function updateResult has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              activities.updateResult = function (activityId, resultId, update, username, esClient) {
                          Severity: Minor
                          Found in lib/activities.js - About 35 mins to fix

                            Identical blocks of code found in 2 locations. Consider refactoring.
                            Open

                                        g: function (callback) {
                                            var r = { groups: [], groupings: [] };
                                            return groups.getUserGroups(user)
                                                .then(function (groups) {
                                                    r.groups = groups.map(extractId);
                            Severity: Major
                            Found in lib/activities.js and 1 other location - About 6 hrs to fix
                            lib/classes.js on lines 341..355

                            Duplicated Code

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Tuning

                            This issue has a mass of 174.

                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                            Refactorings

                            Further Reading

                            Similar blocks of code found in 2 locations. Consider refactoring.
                            Open

                                activities.insert = function(object) {
                                    return Collection.prototype.insert.call(this, object).then(function(activity) {
                                        var set = {
                                            trackingCode: activity._id + token()
                                        };
                            Severity: Major
                            Found in lib/activities.js and 1 other location - About 2 hrs to fix
                            lib/versions.js on lines 71..79

                            Duplicated Code

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Tuning

                            This issue has a mass of 90.

                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                            Refactorings

                            Further Reading

                            Similar blocks of code found in 2 locations. Consider refactoring.
                            Open

                                    get: {
                                        '/activities/:activityId': {
                                            type: 'student',
                                            error: 'Not authorized to get this activity'
                                        },
                            Severity: Major
                            Found in lib/activities.js and 1 other location - About 2 hrs to fix
                            lib/classes.js on lines 165..186

                            Duplicated Code

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Tuning

                            This issue has a mass of 86.

                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                            Refactorings

                            Further Reading

                            Identical blocks of code found in 3 locations. Consider refactoring.
                            Open

                                function getBestType(type1, type2) {
                                    if (type1 === 'teacher' || type2 === 'teacher') {
                                        return 'teacher';
                                    }
                                    if (type1 === 'assistant' || type2 === 'assistant') {
                            Severity: Major
                            Found in lib/activities.js and 2 other locations - About 2 hrs to fix
                            lib/groupings.js on lines 239..250
                            lib/groups.js on lines 266..277

                            Duplicated Code

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Tuning

                            This issue has a mass of 79.

                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                            Refactorings

                            Further Reading

                            Similar blocks of code found in 2 locations. Consider refactoring.
                            Open

                                            var typeComp = function (type) {
                                                if (getBestType(minType, type) === type) {
                                                    deferred.resolve(activity);
                                                } else {
                                                    deferred.reject({
                            Severity: Major
                            Found in lib/activities.js and 1 other location - About 2 hrs to fix
                            lib/classes.js on lines 276..285

                            Duplicated Code

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Tuning

                            This issue has a mass of 78.

                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                            Refactorings

                            Further Reading

                            Similar blocks of code found in 2 locations. Consider refactoring.
                            Open

                                classes.preRemove(function(_id, next) {
                                    activities.remove({
                                        classId: _id
                                    }).then(function() {
                                        next();
                            Severity: Major
                            Found in lib/activities.js and 1 other location - About 1 hr to fix
                            lib/classes.js on lines 574..582

                            Duplicated Code

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Tuning

                            This issue has a mass of 72.

                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                            Refactorings

                            Further Reading

                            Identical blocks of code found in 2 locations. Consider refactoring.
                            Open

                                        for (var i = 0; i < query.$or.length; i++) {
                                            query.$or[i] = Object.assign(query.$or[i], otherfilters);
                                        }
                            Severity: Major
                            Found in lib/activities.js and 1 other location - About 1 hr to fix
                            lib/classes.js on lines 370..372

                            Duplicated Code

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Tuning

                            This issue has a mass of 63.

                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                            Refactorings

                            Further Reading

                            Similar blocks of code found in 2 locations. Consider refactoring.
                            Open

                                        activities.find(query).then(function (activities) {
                                            deferred.resolve(activities);
                                        }).fail(function (err) {
                                            deferred.reject(err);
                                        });
                            Severity: Major
                            Found in lib/activities.js and 1 other location - About 1 hr to fix
                            lib/classes.js on lines 374..378

                            Duplicated Code

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Tuning

                            This issue has a mass of 61.

                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                            Refactorings

                            Further Reading

                            Similar blocks of code found in 2 locations. Consider refactoring.
                            Open

                                    delete: {
                                        '/activities/:activityId': {
                                            type: 'teacher',
                                            error: 'Not authorized to delete this activity'
                                        },
                            Severity: Minor
                            Found in lib/activities.js and 1 other location - About 55 mins to fix
                            lib/activities.js on lines 95..108

                            Duplicated Code

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Tuning

                            This issue has a mass of 54.

                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                            Refactorings

                            Further Reading

                            Similar blocks of code found in 2 locations. Consider refactoring.
                            Open

                                    put: {
                                        '/activities/:activityId': {
                                            type: 'teacher',
                                            error: 'Not authorized to modify this activity'
                                        },
                            Severity: Minor
                            Found in lib/activities.js and 1 other location - About 55 mins to fix
                            lib/activities.js on lines 109..122

                            Duplicated Code

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Tuning

                            This issue has a mass of 54.

                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                            Refactorings

                            Further Reading

                            Similar blocks of code found in 4 locations. Consider refactoring.
                            Open

                                            if (activity.groups && activity.groups.length > 0) {
                                                return groups.getUserTypeForArray(activity.groups, username, ignoreStudents, ignoreAssistants).then(typeComp);
                                            }
                            Severity: Major
                            Found in lib/activities.js and 3 other locations - About 55 mins to fix
                            lib/activities.js on lines 177..179
                            lib/classes.js on lines 286..288
                            lib/classes.js on lines 289..291

                            Duplicated Code

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Tuning

                            This issue has a mass of 53.

                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                            Refactorings

                            Further Reading

                            Similar blocks of code found in 4 locations. Consider refactoring.
                            Open

                                            if (activity.groupings && activity.groupings.length > 0) {
                                                return groupings.getUserTypeForArray(activity.groupings, username, ignoreStudents, ignoreAssistants).then(typeComp);
                                            }
                            Severity: Major
                            Found in lib/activities.js and 3 other locations - About 55 mins to fix
                            lib/activities.js on lines 180..182
                            lib/classes.js on lines 286..288
                            lib/classes.js on lines 289..291

                            Duplicated Code

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Tuning

                            This issue has a mass of 53.

                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                            Refactorings

                            Further Reading

                            Similar blocks of code found in 8 locations. Consider refactoring.
                            Open

                                            if (validationObj.errors && validationObj.errors.length > 0) {
                                                throw {
                                                    message: 'Activity bad format: ' + validationObj.errors[0],
                                                    status: 400
                                                };
                            Severity: Major
                            Found in lib/activities.js and 7 other locations - About 55 mins to fix
                            lib/auth-tokens.js on lines 139..144
                            lib/auth-tokens.js on lines 174..179
                            lib/courses.js on lines 69..74
                            lib/courses.js on lines 81..86
                            lib/games.js on lines 118..123
                            lib/games.js on lines 129..134
                            lib/versions.js on lines 59..64

                            Duplicated Code

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Tuning

                            This issue has a mass of 53.

                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                            Refactorings

                            Further Reading

                            Similar blocks of code found in 2 locations. Consider refactoring.
                            Open

                                activities.getClassActivities = function (classId) {
                                    classId = activities.toObjectID(classId);
                                    return activities.find({classId: classId});
                                };
                            Severity: Minor
                            Found in lib/activities.js and 1 other location - About 40 mins to fix
                            lib/lti.js on lines 14..17

                            Duplicated Code

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Tuning

                            This issue has a mass of 48.

                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                            Refactorings

                            Further Reading

                            Similar blocks of code found in 2 locations. Consider refactoring.
                            Open

                                        }).then(function () {
                                            return activities.removeById(activityId).then(function (result, err) {
                                                if (!err) {
                                                    return {
                                                        message: 'Success.'
                            Severity: Minor
                            Found in lib/activities.js and 1 other location - About 40 mins to fix
                            lib/lti.js on lines 41..49

                            Duplicated Code

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Tuning

                            This issue has a mass of 48.

                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                            Refactorings

                            Further Reading

                            There are no issues that match your filters.

                            Category
                            Status