e-ucm/rage-analytics-backend

View on GitHub
test/tests/collectorTest.js

Summary

Maintainability
F
1 wk
Test Coverage

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

module.exports = function (request, db, config) {

    /**-------------------------------------------------------------**/
    /**-------------------------------------------------------------**/
    /**                   Test Tracker                              **/
Severity: Major
Found in test/tests/collectorTest.js - About 3 days to fix

    File collectorTest.js has 766 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: Major
    Found in test/tests/collectorTest.js - About 1 day 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 startNewSession has 62 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              var startNewSession = function (expectedSession, playerIdentifier, checkAnimalName, type) {
                  request.post('/api/collector/start/' + trackingCode)
                      .expect(200)
                      .expect('Content-Type', /json/)
                      .send({
      Severity: Major
      Found in test/tests/collectorTest.js - About 2 hrs to fix

        Function startNewIdentifiedSession has 55 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                var startNewIdentifiedSession = function (expectedSession, playerIdentifier) {
                    request.post('/api/collector/start/' + trackingCode)
                        .expect(200)
                        .expect('Content-Type', /json/)
                        .set('x-gleaner-user', playerIdentifier)
        Severity: Major
        Found in test/tests/collectorTest.js - About 2 hrs to fix

          Function checkConsumerData has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  var checkConsumerData = function(playerId, versionId, gameplayId, activity, data, convertedTraces) {
                      for (var i = 0; i < data.length; ++i) {
                          var extensions = data[i].object.definition.extensions;
                          should(data[i].actor.name).not.eql(playerId);
                          should(data[i].actor.account.name).not.eql(playerId);
          Severity: Minor
          Found in test/tests/collectorTest.js - About 1 hr to fix

            Function addTraces has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                            addTraces: function (playerId, versionId, gameplayId, activity, data, convertedTraces) {
            Severity: Minor
            Found in test/tests/collectorTest.js - About 45 mins to fix

              Function addTraces has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                                      addTraces: function (playerId, versionId, gameplayId, activity, data, convertedTraces) {
              Severity: Minor
              Found in test/tests/collectorTest.js - About 45 mins to fix

                Function addTraces has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                                addTraces: function (playerId, versionId, gameplayId, activity, data, convertedTraces) {
                Severity: Minor
                Found in test/tests/collectorTest.js - About 45 mins to fix

                  Function addTraces has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                                  addTraces: function (playerId, versionId, gameplayId, activity, data, convertedTraces) {
                  Severity: Minor
                  Found in test/tests/collectorTest.js - About 45 mins to fix

                    Function addTraces has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                                    addTraces: function (playerId, versionId, gameplayId, activity, data, convertedTraces) {
                    Severity: Minor
                    Found in test/tests/collectorTest.js - About 45 mins to fix

                      Function addTraces has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                                      addTraces: function (playerId, versionId, gameplayId, activity, data, convertedTraces) {
                      Severity: Minor
                      Found in test/tests/collectorTest.js - About 45 mins to fix

                        Function checkConsumerData has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                                var checkConsumerData = function(playerId, versionId, gameplayId, activity, data, convertedTraces) {
                        Severity: Minor
                        Found in test/tests/collectorTest.js - About 45 mins to fix

                          Function addTraces has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                                                  addTraces: function (playerId, versionId, gameplayId, activity, data, convertedTraces) {
                          Severity: Minor
                          Found in test/tests/collectorTest.js - About 45 mins to fix

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

                                                        request.post('/api/collector/track')
                                                            .expect(400)
                                                            .expect('Content-Type', /json/)
                                                            .set('Authorization', authToken)
                                                            .send([noVerbIdStatement])
                            Severity: Major
                            Found in test/tests/collectorTest.js and 1 other location - About 1 day to fix
                            test/tests/collectorTest.js on lines 538..584

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

                            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.post('/api/collector/track')
                                                    .expect(400)
                                                    .expect('Content-Type', /json/)
                                                    .set('Authorization', authToken)
                                                    .send([noObjectIdStatement])
                            Severity: Major
                            Found in test/tests/collectorTest.js and 1 other location - About 1 day to fix
                            test/tests/collectorTest.js on lines 442..487

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

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

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

                                        dataSource.addConsumer({
                                            addTraces: function (playerId, versionId, gameplayId, activity, data, convertedTraces) {
                                                checkConsumerData(playerId, versionId, gameplayId, activity, data, convertedTraces);
                                                var deferred = Q.defer();
                                                setTimeout(function () {
                            Severity: Major
                            Found in test/tests/collectorTest.js and 1 other location - About 3 hrs to fix
                            test/tests/collectorTest.js on lines 614..625

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

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

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

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

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

                            Refactorings

                            Further Reading

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

                                        var secondConsumer = {
                                            addTraces: function (playerId, versionId, gameplayId, activity, data, convertedTraces) {
                                                checkConsumerData(playerId, versionId, gameplayId, activity, data, convertedTraces);
                                                var deferred = Q.defer();
                                                setTimeout(function () {
                            Severity: Major
                            Found in test/tests/collectorTest.js and 1 other location - About 3 hrs to fix
                            test/tests/collectorTest.js on lines 287..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 97.

                            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

                                                        {
                                                            _id: idActivity,
                                                            trackingCode: trackingCode,
                                                            classId: idClass,
                                                            gameId: idGame,
                            Severity: Major
                            Found in test/tests/collectorTest.js and 2 other locations - About 55 mins to fix
                            test/tests/attemptsTest.js on lines 62..73
                            test/tests/collectorTest.js on lines 77..88

                            Duplicated Code

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

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

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

                            Tuning

                            This issue has a mass of 54.

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

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

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

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

                            Refactorings

                            Further Reading

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

                                                            {
                                                                _id: idActivity2,
                                                                trackingCode: trackingCode2,
                                                                classId: idClass,
                                                                gameId: idGame,
                            Severity: Major
                            Found in test/tests/collectorTest.js and 2 other locations - About 55 mins to fix
                            test/tests/attemptsTest.js on lines 62..73
                            test/tests/collectorTest.js on lines 65..76

                            Duplicated Code

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

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

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

                            Tuning

                            This issue has a mass of 54.

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

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

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

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

                            Refactorings

                            Further Reading

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

                                        request.post('/api/collector/start/' + trackingCode)
                                            .expect(200)
                                            .expect('Content-Type', /json/)
                                            .send({
                                                anonymous: playerIdentifier
                            Severity: Minor
                            Found in test/tests/collectorTest.js and 1 other location - About 40 mins to fix
                            test/tests/collectorTest.js on lines 831..844

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

                            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.post('/api/collector/start/' + trackingCode)
                                            .expect(404)
                                            .expect('Content-Type', /json/)
                                            .send({
                                                anonymous: nonExistantAnonymousPlayerId
                            Severity: Minor
                            Found in test/tests/collectorTest.js and 1 other location - About 40 mins to fix
                            test/tests/collectorTest.js on lines 646..710

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

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

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

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

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

                            Refactorings

                            Further Reading

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

                                        request.post('/api/collector/start/' + trackingCode2)
                                            .expect(401)
                                            .expect('Content-Type', /json/)
                                            .set('x-gleaner-user', 'AnyUser')
                                            .set('Authorization', 'Bearer 1234')
                            Severity: Minor
                            Found in test/tests/collectorTest.js and 2 other locations - About 40 mins to fix
                            test/tests/collectorTest.js on lines 848..855
                            test/tests/offlinetracesTest.js on lines 207..217

                            Duplicated Code

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

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

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

                            Tuning

                            This issue has a mass of 48.

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

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

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

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

                            Refactorings

                            Further Reading

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

                                        request.post('/api/activities/' + idActivity + '/event/end')
                                            .expect(200)
                                            .set('X-Gleaner-User', 'Teacher1')
                                            .end(function (err, res) {
                                                should.not.exist(err);
                            Severity: Minor
                            Found in test/tests/collectorTest.js and 2 other locations - About 40 mins to fix
                            test/tests/collectorTest.js on lines 817..826
                            test/tests/offlinetracesTest.js on lines 207..217

                            Duplicated Code

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

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

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

                            Tuning

                            This issue has a mass of 48.

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

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

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

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

                            Refactorings

                            Further Reading

                            There are no issues that match your filters.

                            Category
                            Status