e-ucm/rage-analytics-backend

View on GitHub

Showing 590 of 590 total issues

Function guessModelVersion has 71 lines of code (exceeds 25 allowed). Consider refactoring.
Open

MongoController.prototype.guessModelVersion = function(db, callback) {

    console.log('Starting to guess mongo model version!');
    var minVersion = '1';
    db.db.collections(function (error, collections) {
Severity: Major
Found in bin/upgrade/controllers/upgrade-mongo-collections.js - About 2 hrs to fix

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

            }, function (error, response) {
                if (!error && response.hits && response.hits.hits && response.hits.hits.length > 0) {
                    indexObject = response.hits.hits[0]._source;
                }
                deferred.resolve(indexObject);
    Severity: Major
    Found in lib/kibana/kibana.js and 1 other location - About 2 hrs to fix
    lib/kibana/kibana.js on lines 782..788

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

    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

                        }, function (error, response) {
                            if (!error && response.hits && response.hits.hits && response.hits.hits.length > 0) {
                                indexObject = response.hits.hits[0]._source;
                            }
    
    
    Severity: Major
    Found in lib/kibana/kibana.js and 1 other location - About 2 hrs to fix
    lib/kibana/kibana.js on lines 742..747

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

    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

                request.put('/api/games/' + idGame)
                    .expect(200)
                    .set('Accept', 'application/json')
                    .set('X-Gleaner-User', 'DummyUsername')
                    .expect('Content-Type', /json/)
    Severity: Major
    Found in test/tests/gamesTest.js and 1 other location - About 2 hrs to fix
    test/tests/gamesTest.js on lines 87..101

    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

                request.put('/api/games/' + idGame)
                    .expect(200)
                    .set('Accept', 'application/json')
                    .set('X-Gleaner-User', 'DummyUsername')
                    .expect('Content-Type', /json/)
    Severity: Major
    Found in test/tests/gamesTest.js and 1 other location - About 2 hrs to fix
    test/tests/gamesTest.js on lines 105..118

    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

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

    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

    Function checkGameplay has 66 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        var checkGameplay = function(gameplay, callback) {
            // Check new player fields
            var err = null;
            if (!gameplay.playerName) {
                err = 'A gameplay does not contain its player name.';
    Severity: Major
    Found in bin/upgrade/transformers/mongo/transformToVersion4.js - About 2 hrs to fix

      Function roll has 65 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function roll(callback) {
      
          var refreshes = {};
          for (var key in controllers) {
              var controller = controllers[key];
      Severity: Major
      Found in bin/upgrade/upgrader.js - About 2 hrs to fix

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

        module.exports = (function () {
            var Q = require('q');
            var Collection = require('easy-collections');
            var db = require('./db');
            var games = new Collection(db, 'games');
        Severity: Minor
        Found in lib/games.js - About 2 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 buildXAPIProfile has a Cognitive Complexity of 19 (exceeds 5 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 2 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

        File groups.js has 274 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        'use strict';
        
        module.exports = (function () {
            var Collection = require('easy-collections');
            var db = require('./db');
        Severity: Minor
        Found in lib/groups.js - About 2 hrs to fix

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

                  start: function (body, trackingCode, authorization, username) {
                      // First we look for the activity
                      return activities.find({
                          trackingCode: trackingCode
                      }, true).then(function (activity) {
          Severity: Major
          Found in lib/collector.js - About 2 hrs to fix

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

                    post: {
                        '/classes/': {
                            type: 'teacher',
                            error: 'Not authorized create a new class'
                        },
            Severity: Major
            Found in lib/classes.js and 1 other location - About 2 hrs to fix
            lib/activities.js on lines 123..144

            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

            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

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

                let xAPIVerbsActivity = yield at(esClient.get({
                    index: gameIndex.index,
                    type: 'visualization',
                    id: 'xAPIVerbsActivity'
                })).catch(function (notFound) {
            Severity: Major
            Found in bin/upgrade/transformers/elastic/transformToVersion2.js and 1 other location - About 2 hrs to fix
            bin/upgrade/transformers/elastic/transformToVersion2.js on lines 391..399

            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

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

                let totalSessionsVis = yield at(esClient.get({
                    index: gameIndex.index,
                    type: 'visualization',
                    id: 'TotalSessionPlayers-Cmn'
                })).catch(function (notFound) {
            Severity: Major
            Found in bin/upgrade/transformers/elastic/transformToVersion2.js and 1 other location - About 2 hrs to fix
            bin/upgrade/transformers/elastic/transformToVersion2.js on lines 428..436

            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

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

                    {
                        _id: ObjectID('5a16f3a3bfc960008bc5e083'),
                        playerId: ObjectID('5a16f3a3bfc960008bc5e082'),
                        playerName: 'rixp',
                        playerType: 'identified',
            Severity: Major
            Found in test/upgraderTests/mongo/upgradeOutputs/exampleTo4OUT.js and 3 other locations - About 2 hrs to fix
            test/upgraderTests/mongo/upgradeOutputs/exampleTo4OUT.js on lines 509..525
            test/upgraderTests/mongo/upgradeOutputs/exampleTo4OUT.js on lines 526..542
            test/upgraderTests/mongo/upgradeOutputs/exampleTo4OUT.js on lines 704..720

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

            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

                    {
                        _id: ObjectID('5a16cf03bfc960008bc5e07d'),
                        playerId: ObjectID('5a16cf03bfc960008bc5e07c'),
                        playerName: 'sbgg',
                        playerType: 'identified',
            Severity: Major
            Found in test/upgraderTests/mongo/upgradeOutputs/exampleTo4OUT.js and 3 other locations - About 2 hrs to fix
            test/upgraderTests/mongo/upgradeOutputs/exampleTo4OUT.js on lines 526..542
            test/upgraderTests/mongo/upgradeOutputs/exampleTo4OUT.js on lines 543..559
            test/upgraderTests/mongo/upgradeOutputs/exampleTo4OUT.js on lines 704..720

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

            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

                    {
                        _id: ObjectID('5a16f39fbfc960008bc5e080'),
                        playerId: ObjectID('5a16f39fbfc960008bc5e07f'),
                        playerName: 'zwtp',
                        playerType: 'identified',
            Severity: Major
            Found in test/upgraderTests/mongo/upgradeOutputs/exampleTo4OUT.js and 3 other locations - About 2 hrs to fix
            test/upgraderTests/mongo/upgradeOutputs/exampleTo4OUT.js on lines 509..525
            test/upgraderTests/mongo/upgradeOutputs/exampleTo4OUT.js on lines 543..559
            test/upgraderTests/mongo/upgradeOutputs/exampleTo4OUT.js on lines 704..720

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

            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