e-ucm/rage-analytics-backend

View on GitHub

Showing 590 of 590 total issues

Function resolvePermissions has 94 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var resolvePermissions = function () {

    var documentObj = {};
    var look = [];
    var mgetObj = {
Severity: Major
Found in bin/permissions-recover.js - About 3 hrs to fix

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

                    if (activityObj) {
                        console.log('kibana.updateActivityPermissions -> Activity Found');
                        resolveParticipants(activityObj.groups, activityObj.groupings, activityObj.classId)
                            .then(function (participants) {
                                var users = participants.students.concat(participants.assistants.concat(participants.teachers));
    Severity: Major
    Found in lib/kibana/kibana.js and 1 other location - About 3 hrs to fix
    lib/kibana/kibana.js on lines 80..110

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

    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

                                if (classObj) {
                                    console.log('kibana.updateActivityPermissions -> Class Found');
                                    resolveParticipants(classObj.groups, classObj.groupings, classObj._id)
                                        .then(function (participants) {
                                            var users = participants.students.concat(participants.assistants.concat(participants.teachers));
    Severity: Major
    Found in lib/kibana/kibana.js and 1 other location - About 3 hrs to fix
    lib/kibana/kibana.js on lines 68..112

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

    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.put('/:activityId', function (req, res) {
            var username = req.headers['x-gleaner-user'];
            restUtils.processResponse(activities.isAuthorizedFor(req.params.activityId, username, 'put', '/activities/:activityId')
                .then(function (activity) {
                    return activities.modifyActivity(req.params.activityId, req.body, true);
    Severity: Major
    Found in routes/activities.js and 1 other location - About 3 hrs to fix
    routes/activities.js on lines 353..359

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

    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.put('/:activityId/remove', function (req, res) {
            var username = req.headers['x-gleaner-user'];
            restUtils.processResponse(activities.isAuthorizedFor(req.params.activityId, username, 'put', '/activities/:activityId/remove')
                .then(function (activity) {
                    return activities.modifyActivity(req.params.activityId, req.body, false);
    Severity: Major
    Found in routes/activities.js and 1 other location - About 3 hrs to fix
    routes/activities.js on lines 310..316

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

    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 kahootToCSV has 91 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function kahootToCSV(file) {
            try {
                var buf = fs.readFileSync(file);
                var wb = XLSX.read(buf, {type: 'buffer'});
                var sheets = wb.SheetNames;
    Severity: Major
    Found in lib/offlinetraces.js - About 3 hrs to fix

      Function modifyClass has 91 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          classes.modifyClass = function (classId, username, body, add) {
              var participants = {};
              if (!body.participants && body.students) {
                  participants.students = body.students;
                  delete body.students;
      Severity: Major
      Found in lib/classes.js - About 3 hrs to fix

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

        router.put('/:classId', function (req, res) {
            var username = req.headers['x-gleaner-user'];
            restUtils.processResponse(classes.isAuthorizedFor(req.params.classId, username, 'put', '/classes/:classId')
                .then(function (classReq) {
                    return classes.modifyClass(req.params.classId, username, req.body, true);
        Severity: Major
        Found in routes/classes.js and 1 other location - About 3 hrs to fix
        routes/classes.js on lines 334..340

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

        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.put('/:classId/remove', function (req, res) {
            var username = req.headers['x-gleaner-user'];
            restUtils.processResponse(classes.isAuthorizedFor(req.params.classId, username, 'put', '/classes/:classId/remove')
                .then(function (classReq) {
                    return classes.modifyClass(req.params.classId, username, req.body, false);
        Severity: Major
        Found in routes/classes.js and 1 other location - About 3 hrs to fix
        routes/classes.js on lines 292..298

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

        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.get('/api/classes/' + idClass)
                        .expect(200)
                        .set('X-Gleaner-User', 'Teacher1')
                        .end(function (err, res) {
                            should.not.exist(err);
        Severity: Major
        Found in test/tests/classesTest.js and 1 other location - About 3 hrs to fix
        test/tests/activitiesTest.js on lines 233..241

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

        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.get('/api/activities/' + idActivity)
                                .expect(200)
                                .set('X-Gleaner-User', 'Teacher1')
                                .end(function (err, res) {
                                    should.not.exist(err);
        Severity: Major
        Found in test/tests/activitiesTest.js and 1 other location - About 3 hrs to fix
        test/tests/classesTest.js on lines 228..236

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

        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

        File offlinetraces.js has 311 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        'use strict';
        
        module.exports = function () {
        
            var collector = require('./collector');
        Severity: Minor
        Found in lib/offlinetraces.js - About 3 hrs to fix

          File elasticTransformerTo2.js has 310 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          /*
           * Copyright 2016 e-UCM (http://www.e-ucm.es/)
           *
           * Licensed under the Apache License, Version 2.0 (the "License");
           * you may not use this file except in compliance with the License.
          Severity: Minor
          Found in test/upgraderTests/elastic/elasticTransformerTo2.js - About 3 hrs to fix

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

                                var checkSessionCount = {
                                    addTraces: function (playerId, versionId, gameplayId, activity, data, convertedTraces) {
                                        checkConsumerData(playerId, versionId, gameplayId, activity, data, convertedTraces);
            
                                        should(convertedTraces[0].session).eql(expectedSession);
            Severity: Major
            Found in test/tests/collectorTest.js and 1 other location - About 3 hrs to fix
            test/tests/collectorTest.js on lines 766..777

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

            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

                                var checkSessionCount = {
                                    addTraces: function (playerId, versionId, gameplayId, activity, data, convertedTraces) {
                                        checkConsumerData(playerId, versionId, gameplayId, activity, data, convertedTraces);
            
                                        should(convertedTraces[0].session).eql(expectedSession);
            Severity: Major
            Found in test/tests/collectorTest.js and 1 other location - About 3 hrs to fix
            test/tests/collectorTest.js on lines 682..694

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

            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 storm has 84 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            var storm = function (stormConfig, zookeeperUrl, kafkaUrl) {
            
                var genYMLAndLaunch = function (src, ymlPath, stormJar, config) {
                    var deferred = Q.defer();
            
            
            Severity: Major
            Found in lib/services/storm.js - About 3 hrs to fix

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

                                                          request.get('/api/games/my')
                                                              .expect(200)
                                                              .set('X-Gleaner-User', 'username6')
                                                              .set('Accept', 'application/json')
                                                              .expect('Content-Type', /json/)
              Severity: Major
              Found in test/tests/gamesTest.js and 2 other locations - About 3 hrs to fix
              test/tests/gamesTest.js on lines 216..225
              test/tests/gamesTest.js on lines 237..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 102.

              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

                      it('should transform correctly .kibana index', function (done) {
                          var fileIn = './upgradeInputs/kibanaIndexTo2IN.js';
                          var fileOut = './upgradeOutputs/kibanaIndexTo2OUT.js';
                          var searchObj = {
                              index: '.kibana'
              Severity: Major
              Found in test/upgraderTests/elastic/elasticTransformerTo2.js and 2 other locations - About 3 hrs to fix
              test/upgraderTests/elastic/elasticTransformerTo2.js on lines 101..120
              test/upgraderTests/elastic/elasticTransformerTo2.js on lines 122..141

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

              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

                      it('should transform correctly .template index', function (done) {
                          var fileIn = './upgradeInputs/templateIndexTo2IN.js';
                          var fileOut = './upgradeOutputs/templateIndexTo2OUT.js';
                          var searchObj = {
                              index: '.template'
              Severity: Major
              Found in test/upgraderTests/elastic/elasticTransformerTo2.js and 2 other locations - About 3 hrs to fix
              test/upgraderTests/elastic/elasticTransformerTo2.js on lines 80..99
              test/upgraderTests/elastic/elasticTransformerTo2.js on lines 101..120

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

              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.delete('/:activityId', function (req, res) {
                      var username = req.headers['x-gleaner-user'];
                      restUtils.processResponse(activities.isAuthorizedFor(req.params.activityId, username, 'delete', '/activities/:activityId')
                          .then(function (activity) {
                              return activities.removeActivity(req.params.activityId);
              Severity: Major
              Found in routes/activities.js and 1 other location - About 3 hrs to fix
              routes/activities.js on lines 583..589

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

              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

              Severity
              Category
              Status
              Source
              Language