e-ucm/rage-analytics-backend

View on GitHub

Showing 590 of 590 total issues

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

        if (err) {
            console.error(err);
            if (err.errno && err.errno.indexOf('ECONNREFUSED') > -1) {
                console.error('Could not connect to MongoDB!');
                return process.exit(-1);
Severity: Major
Found in bin/setup-roles.js and 1 other location - About 3 hrs to fix
bin/setup-roles.js on lines 66..74

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

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

            if (err) {
                console.error(err);
                if (err.errno && err.errno.indexOf('ECONNREFUSED') > -1) {
                    console.error('Could not connect to MongoDB!');
                    return process.exit(-1);
Severity: Major
Found in bin/setup-roles.js and 1 other location - About 3 hrs to fix
bin/setup-roles.js on lines 43..51

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

            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

Function identifyExtensionsFromIndex has 77 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function* identifyExtensionsFromIndex(esClient, index) {

    let oldMapping = yield at(esClient.indices.getMapping({index: index.index}));
    let upgradeIndex = 'upgrade_' + index.index;
    let mapping = {};
Severity: Major
Found in bin/upgrade/transformers/elastic/transformToVersion2.js - About 3 hrs to fix

    Function upgradeGameIndex has 76 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function* upgradeGameIndex(esClient, gameIndex) {
    
        let totalSessionsVis = yield at(esClient.get({
            index: gameIndex.index,
            type: 'visualization',
    Severity: Major
    Found in bin/upgrade/transformers/elastic/transformToVersion2.js - About 3 hrs to fix

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

              destination: function (req, file, cb) {
                  var pathDir = './offlinetraceskahoot/' + req.params.activityId + '/';
                  mkdirp(pathDir, function (err) {
                      if (err) {
                          console.error(JSON.stringify(err));
      Severity: Major
      Found in lib/offlinetraces.js and 2 other locations - About 3 hrs to fix
      lib/analysis.js on lines 16..26
      lib/offlinetraces.js on lines 19..29

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

      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

              destination: function (req, file, cb) {
                  var pathDir = './uploads/' + req.params.versionId + '/';
                  mkdirp(pathDir, function (err) {
                      if (err) {
                          console.error(JSON.stringify(err));
      Severity: Major
      Found in lib/analysis.js and 2 other locations - About 3 hrs to fix
      lib/offlinetraces.js on lines 19..29
      lib/offlinetraces.js on lines 46..56

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

      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

                  db.collection('games').drop(function () {
                      db.collection('versions').drop(function () {
                          db.collection('classes').drop(function () {
                              db.collection('activities').drop(function () {
                                  db.collection('offlinetraces').drop(done);
      Severity: Major
      Found in test/tests/offlinetracesTest.js and 1 other location - About 3 hrs to fix
      test/tests/activitiesTest.js on lines 98..106

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

      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

              destination: function (req, file, cb) {
                  var pathDir = './offlinetraces/' + req.params.activityId + '/';
                  mkdirp(pathDir, function (err) {
                      if (err) {
                          console.error(JSON.stringify(err));
      Severity: Major
      Found in lib/offlinetraces.js and 2 other locations - About 3 hrs to fix
      lib/analysis.js on lines 16..26
      lib/offlinetraces.js on lines 46..56

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

      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

              afterEach(function (done) {
                  db.collection('games').drop(function () {
                      db.collection('versions').drop(function () {
                          db.collection('classes').drop(function () {
                              db.collection('activities').drop(done);
      Severity: Major
      Found in test/tests/activitiesTest.js and 1 other location - About 3 hrs to fix
      test/tests/offlinetracesTest.js on lines 124..132

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

      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 headerHTML = header.map(function (line, index, array) {
                  if (index === 0) {
                      return '<!--\n' +
                          '  -- ' + line;
                  }
      Severity: Major
      Found in Gruntfile.js and 1 other location - About 2 hrs to fix
      Gruntfile.js on lines 30..41

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

      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 headerJS = header.map(function (line, index, array) {
                  if (index === 0) {
                      return '/*\n' +
                          ' * ' + line;
                  }
      Severity: Major
      Found in Gruntfile.js and 1 other location - About 2 hrs to fix
      Gruntfile.js on lines 43..54

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

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

      var compareDocuments = function (doc1, doc2, ignoredFields) {
          if (ignoredFields === undefined || ignoredFields === null) {
              ignoredFields = ['uuidv4'];
          }
      
      
      Severity: Major
      Found in test/upgraderTests/upgraderTestUtils.js - About 2 hrs to fix

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

                    if (add) {
                        if (!update.$addToSet) {
                            update.$addToSet = {};
                        }
                        if (Array.isArray(value)) {
        Severity: Major
        Found in lib/utils.js and 1 other location - About 2 hrs to fix
        lib/utils.js on lines 50..61

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

        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

                    } else {
                        if (!update.$pull) {
                            update.$pull = {};
                        }
                        if (Array.isArray(value)) {
        Severity: Major
        Found in lib/utils.js and 1 other location - About 2 hrs to fix
        lib/utils.js on lines 39..50

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

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

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

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

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

        Refactorings

        Further Reading

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

            {
                id: 'vis_id1000',
                type: 'visualization',
                source: {
                    title: 'visualization_title',
        Severity: Major
        Found in test/upgraderTests/elastic/upgradeOutputs/gameIndexTo2OUT.js and 1 other location - About 2 hrs to fix
        test/upgraderTests/elastic/upgradeOutputs/gameIndexTo2OUT.js on lines 27..49

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

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

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

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

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

        Refactorings

        Further Reading

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

            {
                id: 'vis_id2000',
                type: 'visualization',
                source: {
                    title: 'visualization_title',
        Severity: Major
        Found in test/upgraderTests/elastic/upgradeOutputs/gameIndexTo2OUT.js and 1 other location - About 2 hrs to fix
        test/upgraderTests/elastic/upgradeOutputs/gameIndexTo2OUT.js on lines 4..26

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

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

        module.exports = function (grunt) {
        
            // Code adapted from http://stackoverflow.com/a/18402335/15472
            grunt.registerTask('default', function () {
        
        
        Severity: Major
        Found in Gruntfile.js - About 2 hrs to fix

          File activitiesTest.js has 286 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

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