e-ucm/rage-analytics-backend

View on GitHub

Showing 590 of 590 total issues

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

    groupings.removeGroupings = function (id, username) {
        return groupings.findById(id)
            .then(function (groupingRes) {
                if (!groupingRes) {
                    throw {
Severity: Minor
Found in lib/groupings.js - About 1 hr to fix

    Function check has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function check(config, callback) {
    
        config.mongodb.db.db.listCollections().toArray(function(err, collections) {
            if (err) {
                console.log('Unexpected error while checking collections names!', err);
    Severity: Minor
    Found in bin/upgrade/transformers/mongo/transformToVersion3.js - About 1 hr to fix

      Function processTraces has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          var processTraces = function (data, activityId, res) {
              return function (topologyError, topologyResult) {
                  if (topologyError) {
                      return res.status(400).json({
                          message: 'Error starting Storm Topology: ' +
      Severity: Minor
      Found in routes/activities.js - About 1 hr to fix

        Function transform has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        AbstractController.prototype.transform = function (callback) {
            var that = this;
            async.waterfall([function (newCallback) {
                    console.log('Starting executing transformer ' + JSON.stringify(that.nextTransformer.version, null, 4));
                    newCallback(null, that.appConfig);
        Severity: Minor
        Found in bin/upgrade/controllers/abstract-controller.js - About 1 hr to fix

          Function kafkaConsumer has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          var kafkaConsumer = function (kafkaConfig) {
              var kafka = require('../services/kafka')(kafkaConfig.uri);
          
              return {
                  addTraces: function (playerId, versionId, gameplayId, activity, data, convertedData) {
          Severity: Minor
          Found in lib/consumers/kafka.js - About 1 hr to fix

            Function modifyGroupings has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                groupings.modifyGroupings = function (id, username, body, add) {
                    var validationObj = v.validate(body, groupingSchema);
                    validationObj = validationObj.errors.length > 0 ? v.validate(body, participantsGroupingSchema): validationObj;
                    if (validationObj.errors && validationObj.errors.length > 0) {
                        throw {
            Severity: Minor
            Found in lib/groupings.js - About 1 hr to fix

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

              router.delete('/groupings/:id', function (req, res) {
                  var username = req.headers['x-gleaner-user'];
                  restUtils.processResponse(groupings.removeGroupings(req.params.id, username), res);
              });
              Severity: Major
              Found in routes/groupings.js and 2 other locations - About 1 hr to fix
              routes/courses.js on lines 156..159
              routes/groups.js on lines 191..194

              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 65.

              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 3 locations. Consider refactoring.
              Open

              router.delete('/:id', function (req, res) {
                  var username = req.headers['x-gleaner-user'];
                  restUtils.processResponse(courses.removeCourse(req.params.id, username), res);
              });
              Severity: Major
              Found in routes/courses.js and 2 other locations - About 1 hr to fix
              routes/groupings.js on lines 173..176
              routes/groups.js on lines 191..194

              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 65.

              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

                      {
                          _id: ObjectID('59565c67370740006dc1ab7c'),
                          gameId: ObjectID('59289445370740006dc1a794'),
                          versionId: ObjectID('59289445370740006dc1a795'),
                          classId: 'unknown',
              Severity: Major
              Found in test/upgraderTests/mongo/upgradeOutputs/exampleTo2OUT.js and 1 other location - About 1 hr to fix
              test/upgraderTests/mongo/upgradeOutputs/exampleTo2OUT.js on lines 230..246

              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 65.

              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 3 locations. Consider refactoring.
              Open

              router.delete('/groups/:id', function (req, res) {
                  var username = req.headers['x-gleaner-user'];
                  restUtils.processResponse(groups.removeGroups(req.params.id, username), res);
              });
              Severity: Major
              Found in routes/groups.js and 2 other locations - About 1 hr to fix
              routes/courses.js on lines 156..159
              routes/groupings.js on lines 173..176

              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 65.

              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

                      {
                          _id: ObjectID('595bac18370740006dc1ab7d'),
                          gameId: ObjectID('59289445370740006dc1a794'),
                          versionId: ObjectID('59289445370740006dc1a795'),
                          classId: 'unknown',
              Severity: Major
              Found in test/upgraderTests/mongo/upgradeOutputs/exampleTo2OUT.js and 1 other location - About 1 hr to fix
              test/upgraderTests/mongo/upgradeOutputs/exampleTo2OUT.js on lines 213..229

              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 65.

              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

                  router.post('/:activityId/kahoot', function (req, res) {
                      var username = req.headers['x-gleaner-user'];
                      restUtils.processResponse(offlinetraces.createOfflinetraces(req.params.activityId, username, req, res, true), res);
                  });
              Severity: Major
              Found in routes/offlinetraces.js and 1 other location - About 1 hr to fix
              routes/offlinetraces.js on lines 120..123

              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 65.

              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

                          request.put('/api/courses/' + idCourse + '/remove')
                              .expect(401)
                              .set('X-Gleaner-User', 'notAllowedUsername')
                              .send({
                                  teachers: ['st1'],
              Severity: Major
              Found in test/tests/coursesTest.js and 1 other location - About 1 hr to fix
              test/tests/coursesTest.js on lines 157..172

              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 65.

              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

                  router.post('/:activityId', function (req, res) {
                      var username = req.headers['x-gleaner-user'];
                      restUtils.processResponse(offlinetraces.createOfflinetraces(req.params.activityId, username, req, res, false), res);
                  });
              Severity: Major
              Found in routes/offlinetraces.js and 1 other location - About 1 hr to fix
              routes/offlinetraces.js on lines 87..90

              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 65.

              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

                                  request.put('/api/courses/' + idCourse + '/remove')
                                      .expect(200)
                                      .set('X-Gleaner-User', 'teacher')
                                      .send({
                                          teachers: ['st1'],
              Severity: Major
              Found in test/tests/coursesTest.js and 1 other location - About 1 hr to fix
              test/tests/coursesTest.js on lines 147..173

              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 65.

              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

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

                  authTokens.start = function (player, version, activity) {
                      var id = activity ? activity._id : version._id;
              
                      return gameplays.find(id, player)
                          .then(function (gameplay) {
              Severity: Minor
              Found in lib/auth-tokens.js - About 1 hr to fix

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

                            request.put('/api/courses/' + idCourse)
                                .expect(401)
                                .set('X-Gleaner-User', 'notAllowedUsername')
                                .send({
                                    title: 'someCourseNameTest',
                Severity: Major
                Found in test/tests/coursesTest.js and 1 other location - About 1 hr to fix
                test/tests/coursesTest.js on lines 109..124

                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 64.

                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

                Function getModelVersion has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                ElasticController.prototype.getModelVersion = function (config, callback) {
                    var esClient = config.elasticsearch.esClient;
                    var modelVersion = null;
                
                    esClient.get({
                Severity: Minor
                Found in bin/upgrade/controllers/upgrade-elastic-indices.js - About 1 hr to fix

                  Function updateGameplay has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      var updateGameplay = function(versionId, gameplaysCollection, gameplay, callback) {
                          playersCollection.findOneAndUpdate({ _id: gameplay.playerId }, { $addToSet: { versions: versionId }}).then(function(res) {
                              playersCollection.findOne({ _id: gameplay.playerId }).then(function(player) {
                                  gameplay.playerName = player.name;
                                  gameplay.playerType = player.type;
                  Severity: Minor
                  Found in bin/upgrade/transformers/mongo/transformToVersion4.js - About 1 hr to fix

                    Function buildXAPIProfile has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    var buildXAPIProfile = function (statement, trace) {
                        var eventError = getEvent(statement, trace);
                        if (eventError) {
                            return eventError;
                        }
                    Severity: Minor
                    Found in lib/tracesConverter.js - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language