e-ucm/rage-analytics-backend

View on GitHub

Showing 590 of 590 total issues

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

        it('should GET classes', function (done) {
            request.get('/api/classes')
                .expect(200)
                .set('X-Gleaner-User', 'Teacher1')
                .end(function (err, res) {
Severity: Major
Found in test/tests/classesTest.js and 3 other locations - About 5 hrs to fix
test/tests/activitiesTest.js on lines 188..199
test/tests/classesTest.js on lines 214..225
test/tests/coursesTest.js on lines 72..83

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

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

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

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

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

Refactorings

Further Reading

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

        it('should GET my activities', function (done) {
            request.get('/api/activities/my')
                .expect(200)
                .set('X-Gleaner-User', 'Teacher1')
                .end(function (err, res) {
Severity: Major
Found in test/tests/activitiesTest.js and 3 other locations - About 5 hrs to fix
test/tests/classesTest.js on lines 201..212
test/tests/classesTest.js on lines 214..225
test/tests/coursesTest.js on lines 72..83

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

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

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

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

    module.exports = (function () {
        var Q = require('q');
        var authTokens = require('./auth-tokens');
        var players = require('./players');
        var dataSource = require('./traces');
    Severity: Major
    Found in lib/collector.js - About 5 hrs to fix

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

      module.exports = function (request, db, config) {
          config.mongodb.db = db;
      
          /**-------------------------------------------------------------**/
          /**-------------------------------------------------------------**/
      Severity: Major
      Found in test/upgraderTests/mongo/mongoTransformerTo3.js - About 5 hrs to fix

        Function createAnalysis has 122 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            analysis.createAnalysis = function (versionId, username, req, res) {
        
                versionId = analysis.toObjectID(versionId);
                return analysis.findById(versionId)
                    .then(function (analysisResult) {
        Severity: Major
        Found in lib/analysis.js - About 4 hrs to fix

          Function identifyExtensionsFromIndex has a Cognitive Complexity of 32 (exceeds 5 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: Minor
          Found in bin/upgrade/transformers/elastic/transformToVersion2.js - About 4 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 5 locations. Consider refactoring.
          Open

                          upgrader.upgrade(function(err, result) {
                              assert.equal(err, null, 'Error is not null!');
          
                              should(counts.controllerStates[0]).be.equal(normalStates.length);
                              should(counts.transformerStates[0]).be.equal(transformerStates.length);
          Severity: Major
          Found in test/upgraderTests/processController.js and 4 other locations - About 4 hrs to fix
          test/upgraderTests/processController.js on lines 103..110
          test/upgraderTests/processController.js on lines 137..144
          test/upgraderTests/processController.js on lines 171..178
          test/upgraderTests/processController.js on lines 205..212

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

          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 5 locations. Consider refactoring.
          Open

                          upgrader.upgrade(function(err, result) {
                              assert.notEqual(err, null, 'Error is null');
          
                              should(counts.controllerStates[0]).be.equal(normalStates.length);
                              should(counts.transformerStates[0]).be.equal(transformerStates.length);
          Severity: Major
          Found in test/upgraderTests/processController.js and 4 other locations - About 4 hrs to fix
          test/upgraderTests/processController.js on lines 103..110
          test/upgraderTests/processController.js on lines 137..144
          test/upgraderTests/processController.js on lines 171..178
          test/upgraderTests/processController.js on lines 239..246

          Duplicated Code

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

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

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

          Tuning

          This issue has a mass of 130.

          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 5 locations. Consider refactoring.
          Open

                          upgrader.upgrade(function(err, result) {
                              assert.equal(err, null, 'Error happened!');
          
                              should(counts.controllerStates[0]).be.equal(normalStates.length);
                              should(counts.transformerStates[0]).be.equal(transformerStates.length);
          Severity: Major
          Found in test/upgraderTests/processController.js and 4 other locations - About 4 hrs to fix
          test/upgraderTests/processController.js on lines 137..144
          test/upgraderTests/processController.js on lines 171..178
          test/upgraderTests/processController.js on lines 205..212
          test/upgraderTests/processController.js on lines 239..246

          Duplicated Code

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

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

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

          Tuning

          This issue has a mass of 130.

          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 5 locations. Consider refactoring.
          Open

                          upgrader.upgrade(function(err, result) {
                              assert.notEqual(err, null, 'Error is null');
          
                              should(counts.controllerStates[0]).be.equal(normalStates.length);
                              should(counts.transformerStates[0]).be.equal(transformerStates.length);
          Severity: Major
          Found in test/upgraderTests/processController.js and 4 other locations - About 4 hrs to fix
          test/upgraderTests/processController.js on lines 103..110
          test/upgraderTests/processController.js on lines 171..178
          test/upgraderTests/processController.js on lines 205..212
          test/upgraderTests/processController.js on lines 239..246

          Duplicated Code

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

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

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

          Tuning

          This issue has a mass of 130.

          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 5 locations. Consider refactoring.
          Open

                          upgrader.upgrade(function(err, result) {
                              assert.notEqual(err, null, 'Error is null');
          
                              should(counts.controllerStates[0]).be.equal(normalStates.length);
                              should(counts.transformerStates[0]).be.equal(transformerStates.length);
          Severity: Major
          Found in test/upgraderTests/processController.js and 4 other locations - About 4 hrs to fix
          test/upgraderTests/processController.js on lines 103..110
          test/upgraderTests/processController.js on lines 137..144
          test/upgraderTests/processController.js on lines 205..212
          test/upgraderTests/processController.js on lines 239..246

          Duplicated Code

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

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

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

          Tuning

          This issue has a mass of 130.

          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

                  return groups.findById(groupId).then(function (group) {
                      if (group) {
                          if (!ignoreTeachers && group.participants.teachers.indexOf(username) !== -1) {
                              return 'teacher';
                          }
          Severity: Major
          Found in lib/groups.js and 1 other location - About 4 hrs to fix
          lib/classes.js on lines 553..566

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

          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 getUserType = function(classRes, username, ignoreStudents, ignoreAssistants, ignoreTeachers) {
                  if (classRes) {
                      if (!ignoreTeachers && classRes.participants.teachers.indexOf(username) !== -1) {
                          return 'teacher';
                      }
          Severity: Major
          Found in lib/classes.js and 1 other location - About 4 hrs to fix
          lib/groups.js on lines 250..263

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

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

          module.exports = (function () {
              var Q = require('q');
              var Collection = require('easy-collections');
              var authTokens = new Collection(require('./db'), 'authtokens');
              var gameplays = require('./gameplays');
          Severity: Major
          Found in lib/auth-tokens.js - About 4 hrs to fix

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

                    it('should GET a course', function (done) {
                        request.get('/api/courses/' + idCourse.toString())
                            .expect(200)
                            .set('X-Gleaner-User', 'teacher')
                            .end(function (err, res) {
            Severity: Major
            Found in test/tests/coursesTest.js and 1 other location - About 4 hrs to fix
            test/tests/groupsTest.js on lines 114..124

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

            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 GET a group', function (done) {
                        request.get('/api/classes/groups/' + idGroup.toString())
                            .expect(200)
                            .set('X-Gleaner-User', 'teacher')
                            .end(function (err, res) {
            Severity: Major
            Found in test/tests/groupsTest.js and 1 other location - About 4 hrs to fix
            test/tests/coursesTest.js on lines 85..95

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

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

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

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

              module.exports = (function () {
              
                  var hasKey = function (object, key) {
                      var o = object;
                      var matches = 0;
              Severity: Minor
              Found in lib/utils.js - About 4 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 4 locations. Consider refactoring.
              Open

              function upgrade(config, callback) {
                  console.log('[TEST TRANSFORMER] upgrade');
                  testCallbacks.called('upgrade');
                  should(state).be.equal('UPGRADE');
              
              
              Severity: Major
              Found in test/upgraderTests/transformer-test.js and 3 other locations - About 4 hrs to fix
              test/upgraderTests/transformer-test.js on lines 23..38
              test/upgraderTests/transformer-test.js on lines 56..70
              test/upgraderTests/transformer-test.js on lines 72..86

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

              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