e-ucm/rage-analytics-backend

View on GitHub

Showing 590 of 590 total issues

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

            request.get('/api/games/my')
                .expect(200)
                .set('X-Gleaner-User', 'DummyUsername')
                .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 187..196
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

                    request.get('/api/games/my')
                        .expect(200)
                        .set('X-Gleaner-User', 'DummyUsername')
                        .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 187..196
test/tests/gamesTest.js on lines 216..225

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

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 .game indices', function (done) {
            var fileIn = './upgradeInputs/gameIndexTo2IN.js';
            var fileOut = './upgradeOutputs/gameIndexTo2OUT.js';
            var searchObj = {
                index: '.games1234'
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 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

Function kafkaService has 83 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var kafkaService = function (clientUri) {
    var cl;
    var pr;
    var co;

Severity: Major
Found in lib/services/kafka.js - About 3 hrs to fix

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

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

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

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

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

    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 transformToVersion4.js has 304 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 bin/upgrade/transformers/mongo/transformToVersion4.js - About 3 hrs to fix

      Function upgradeAttempts has 82 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function upgradeAttempts(config, callback) {
          // Transformers
          var playersCollection = config.mongodb.db.collection('players');
          var authTokensCollection = config.mongodb.db.collection('authtokens');
      
      
      Severity: Major
      Found in bin/upgrade/transformers/mongo/transformToVersion4.js - About 3 hrs to fix

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

        module.exports = function (request, db, config) {
        
            /**-------------------------------------------------------------**/
            /**-------------------------------------------------------------**/
            /**                   Test Tracker                              **/
        Severity: Minor
        Found in test/tests/collectorTest.js - About 3 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

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

        module.exports = (function () {
            var Q = require('q');
            var tracesConverter = require('./tracesConverter');
            // Consumers interested in the incoming traces
            var consumers = [];
        Severity: Minor
        Found in lib/traces.js - About 3 hrs 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

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

                                        session[0].teachers.forEach(function (tea) {
                                            if (!mgetObj.permissions[tea]) {
                                                mgetObj.permissions[tea] = ['5.0.0', 'default-kibana-index'];
                                            }
                                            documentObj[visID].forEach(function(resourceName) {
        Severity: Major
        Found in bin/permissions-recover.js and 2 other locations - About 3 hrs to fix
        bin/permissions-recover.js on lines 121..128
        bin/permissions-recover.js on lines 154..161

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

        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

                                    game[0].developers.forEach(function (dev) {
                                        if (!mgetObj.permissions[dev]) {
                                            mgetObj.permissions[dev] = ['5.0.0', 'default-kibana-index'];
                                        }
                                        documentObj[visID].forEach(function (resourceName) {
        Severity: Major
        Found in bin/permissions-recover.js and 2 other locations - About 3 hrs to fix
        bin/permissions-recover.js on lines 121..128
        bin/permissions-recover.js on lines 142..149

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

        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

                                session[0].teachers.forEach(function (tea) {
                                    if (!mgetObj.permissions[tea]) {
                                        mgetObj.permissions[tea] = ['5.0.0', 'default-kibana-index'];
                                    }
                                    documentObj[visID].forEach(function(resourceName) {
        Severity: Major
        Found in bin/permissions-recover.js and 2 other locations - About 3 hrs to fix
        bin/permissions-recover.js on lines 142..149
        bin/permissions-recover.js on lines 154..161

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

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

        module.exports = function(request, db) {
        
            /**-------------------------------------------------------------**/
            /**-------------------------------------------------------------**/
            /**                   Test Versions API                         **/
        Severity: Major
        Found in test/tests/versionsTest.js - About 3 hrs to fix

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

                  bodyIn.forEach(function(doc) {
                      // Action description
                      bulkBody.body.push({ index:  {
                          _index: index ? index : doc.index,
                          _type: doc.type,
          Severity: Major
          Found in test/upgraderTests/elastic/elasticController.js and 1 other location - About 3 hrs to fix
          test/upgraderTests/elastic/elasticTransformerTo2.js on lines 219..230

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

          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

                  bodyIn.forEach(function (doc) {
                      // Action description
                      bulkBody.body.push({
                          index: {
                              _index: index ? index : doc.index,
          Severity: Major
          Found in test/upgraderTests/elastic/elasticTransformerTo2.js and 1 other location - About 3 hrs to fix
          test/upgraderTests/elastic/elasticController.js on lines 175..184

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

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

          module.exports = (function() {
              var Collection = require('easy-collections');
              var _ = require('underscore');
              var db = require('./db');
              var versions = new Collection(db, 'versions');
          Severity: Major
          Found in lib/versions.js - About 3 hrs to fix

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

                        participants: {
                            type: 'object',
                            properties: {
                                students: {
                                    type: 'array',
            Severity: Major
            Found in lib/classes.js and 1 other location - About 3 hrs to fix
            lib/groups.js on lines 21..40

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

            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

                        participants: {
                            type: 'object',
                            properties: {
                                students: {
                                    type: 'array',
            Severity: Major
            Found in lib/groups.js and 1 other location - About 3 hrs to fix
            lib/classes.js on lines 40..59

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

            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