e-ucm/rage-analytics-backend

View on GitHub

Showing 590 of 590 total issues

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

    groupings.getUserTypeForArray = function(groupingIds, username, ignoreStudents, ignoreAssistants, ignoreTeachers) {
        if (groupingIds.length > 0) {
            groupingIds = groupingIds.slice(0);
            var groupingId = groupingIds.shift();
            return groupings.getUserType(groupingId, username, ignoreStudents, ignoreAssistants, ignoreTeachers)
Severity: Major
Found in lib/groupings.js and 1 other location - About 1 day to fix
lib/groups.js on lines 279..310

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

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 a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = (function () {
    var Q = require('q');
    var request = require('request');
    var kibana = {};
    var async = require('async');
Severity: Minor
Found in lib/kibana/kibana.js - About 1 day to fix

Cognitive Complexity

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

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

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

Further reading

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

        it('should not POST an empty zip file with a missing realtime.jar',
            function (done) {
                // Creating archives
                var zip = new AdmZip();

Severity: Major
Found in test/tests/analysisTest.js and 1 other location - About 7 hrs to fix
test/tests/analysisTest.js on lines 128..151

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

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

        it('should not POST an empty zip file with a missing flux.yml',
            function (done) {
                // Creating archives
                var zip = new AdmZip();

Severity: Major
Found in test/tests/analysisTest.js and 1 other location - About 7 hrs to fix
test/tests/analysisTest.js on lines 103..126

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

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

module.exports = function (request, db) {

    /**-------------------------------------------------------------**/
    /**-------------------------------------------------------------**/
    /**                   Test Groups  API                          **/
Severity: Major
Found in test/tests/groupsTest.js - About 7 hrs to fix

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

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

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

      module.exports = (function () {
          var Q = require('q');
          var Collection = require('easy-collections');
          var async = require('async');
          var db = require('./db');
      Severity: Minor
      Found in lib/classes.js - About 7 hrs to fix

      Cognitive Complexity

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

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

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

      Further reading

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

              beforeEach(function (done) {
                  db.collection('games').remove({}, function (err, removed) {
                      should.equal(err, null);
                      db.collection('versions').remove({}, function (err, removed) {
                          should.equal(err, null);
      Severity: Major
      Found in test/upgraderTests/mongo/mongoTransformerTo3.js and 2 other locations - About 7 hrs to fix
      test/upgraderTests/mongo/mongoTransformerTo2.js on lines 88..102
      test/upgraderTests/mongo/mongoTransformerTo3.js on lines 91..105

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

      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

              afterEach(function (done) {
                  db.collection('games').remove({}, function (err, removed) {
                      should.equal(err, null);
                      db.collection('versions').remove({}, function (err, removed) {
                          should.equal(err, null);
      Severity: Major
      Found in test/upgraderTests/mongo/mongoTransformerTo3.js and 2 other locations - About 7 hrs to fix
      test/upgraderTests/mongo/mongoTransformerTo2.js on lines 88..102
      test/upgraderTests/mongo/mongoTransformerTo3.js on lines 75..89

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

      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

              afterEach(function (done) {
                  db.collection('games').remove({}, function (err, removed) {
                      should.equal(err, null);
                      db.collection('versions').remove({}, function (err, removed) {
                          should.equal(err, null);
      Severity: Major
      Found in test/upgraderTests/mongo/mongoTransformerTo2.js and 2 other locations - About 7 hrs to fix
      test/upgraderTests/mongo/mongoTransformerTo3.js on lines 75..89
      test/upgraderTests/mongo/mongoTransformerTo3.js on lines 91..105

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

      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 a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
      Open

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

      Cognitive Complexity

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

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

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

      Further reading

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

              it('should detect version 1 with a version 1 .template index', function (done) {
                  var fileIn = './upgradeInputs/templateIndexTo2IN.js';
      
                  bulkFunction(fileIn, '.template', function(error) {
                      should.not.exist(error);
      Severity: Major
      Found in test/upgraderTests/elastic/elasticController.js and 2 other locations - About 7 hrs to fix
      test/upgraderTests/elastic/elasticController.js on lines 98..121
      test/upgraderTests/elastic/elasticController.js on lines 123..146

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

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

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

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

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

      Refactorings

      Further Reading

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

              it('should detect version 1 with a .template index but no defaultIndex id', function (done) {
                  var fileIn = './upgradeInputs/kibanaIndexTo2IN.js';
      
                  bulkFunction(fileIn, '.kibana', function(error) {
                      should.not.exist(error);
      Severity: Major
      Found in test/upgraderTests/elastic/elasticController.js and 2 other locations - About 7 hrs to fix
      test/upgraderTests/elastic/elasticController.js on lines 73..96
      test/upgraderTests/elastic/elasticController.js on lines 98..121

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

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

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

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

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

      Refactorings

      Further Reading

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

              it('should detect version 1 with no .template index but other indices', function (done) {
                  var fileIn = './upgradeInputs/kibanaIndexTo2IN.js';
      
                  bulkFunction(fileIn, '.kibana', function(error) {
                      should.not.exist(error);
      Severity: Major
      Found in test/upgraderTests/elastic/elasticController.js and 2 other locations - About 7 hrs to fix
      test/upgraderTests/elastic/elasticController.js on lines 73..96
      test/upgraderTests/elastic/elasticController.js on lines 123..146

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

      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

                  g: function (callback) {
                      var r = {groups: [], groupings: []};
                      return groups.getUserGroups(user)
                          .then(function (groups) {
                              r.groups = groups.map(extractId);
      Severity: Major
      Found in lib/classes.js and 1 other location - About 6 hrs to fix
      lib/activities.js on lines 289..303

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

      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

                  g: function (callback) {
                      var r = { groups: [], groupings: [] };
                      return groups.getUserGroups(user)
                          .then(function (groups) {
                              r.groups = groups.map(extractId);
      Severity: Major
      Found in lib/activities.js and 1 other location - About 6 hrs to fix
      lib/classes.js on lines 341..355

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

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

      module.exports = function (request, app, db) {
      
      
          /**-------------------------------------------------------------**/
          /**-------------------------------------------------------------**/
      Severity: Major
      Found in test/upgraderTests/processController.js - About 6 hrs to fix

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

        module.exports = function () {
        
            var collector = require('./collector');
            var csvToXapi = require('./csvToXAPI');
            var Q = require('q');
        Severity: Minor
        Found in lib/offlinetraces.js - About 6 hrs to fix

        Cognitive Complexity

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

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

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

        Further reading

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

                            request.put('/api/classes/' + idClass + '/remove')
                                .expect(200)
                                .set('X-Gleaner-User', 'Teacher1')
                                .send({
                                    participants: {
        Severity: Major
        Found in test/tests/classesTest.js and 1 other location - About 6 hrs to fix
        test/tests/groupsTest.js on lines 197..214

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

        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/classes/groups/' + idGroup + '/remove')
                                .expect(200)
                                .set('X-Gleaner-User', 'teacher')
                                .send({
                                    participants: {
        Severity: Major
        Found in test/tests/groupsTest.js and 1 other location - About 6 hrs to fix
        test/tests/classesTest.js on lines 351..368

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

        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