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

function clean(config, callback) {
    console.log('[TEST TRANSFORMER] clean');
    testCallbacks.called('clean');
    should(state).be.equal('CLEAN');

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 40..54
test/upgraderTests/transformer-test.js on lines 56..70

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

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

function backup(config, callback) {
    console.log('[TEST TRANSFORMER] backup');
    testCallbacks.called('backup');
    should(state).be.equal('NONE');

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 40..54
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

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

function check(config, callback) {
    console.log('[TEST TRANSFORMER] check');
    testCallbacks.called('check');
    should(state).be.equal('CHECK');

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 40..54
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

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

                    request.put('/api/courses/' + idCourse)
                        .expect(200)
                        .set('X-Gleaner-User', 'teacher')
                        .send({
                            title: 'someCourseNameTest',
Severity: Major
Found in test/tests/coursesTest.js and 1 other location - About 4 hrs to fix
test/tests/coursesTest.js on lines 129..143

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

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/courses/' + idCourse)
                .expect(200)
                .set('X-Gleaner-User', 'teacher')
                .send({
                    teachers: ['st2'],
Severity: Major
Found in test/tests/coursesTest.js and 1 other location - About 4 hrs to fix
test/tests/coursesTest.js on lines 109..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 120.

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

module.exports = (function () {
    var Q = require('q');
    var tracesConverter = require('./tracesConverter');
    // Consumers interested in the incoming traces
    var consumers = [];
Severity: Major
Found in lib/traces.js - About 4 hrs to fix

    Function createOfflinetraces has 104 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        offlinetraces.createOfflinetraces = function (activityId, username, req, res, kahoot) {
            activityId = offlinetraces.toObjectID(activityId);
            var nofileMessage = '';
            var trackingCode = '';
            // 1 - Check if anactivity exists for the given activityId
    Severity: Major
    Found in lib/offlinetraces.js - About 4 hrs to fix

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

          {
              id: 'index_id1000',
              type: 'index-pattern',
              source: {
                  title: '58935a97e6806a006e3ae7bd',
      Severity: Major
      Found in test/upgraderTests/elastic/upgradeOutputs/gameIndexTo2OUT.js and 1 other location - About 4 hrs to fix
      test/upgraderTests/elastic/upgradeOutputs/gameIndexTo2OUT.js on lines 105..134

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

      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: 'index_id2000',
              type: 'index',
              source: {
                  title: '58935a97e6806a006e3ae7bd',
      Severity: Major
      Found in test/upgraderTests/elastic/upgradeOutputs/gameIndexTo2OUT.js and 1 other location - About 4 hrs to fix
      test/upgraderTests/elastic/upgradeOutputs/gameIndexTo2OUT.js on lines 75..104

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

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

      var getTarget = function (statement, trace) {
          var object = statement.object;
          if (object) {
              var objectId = object.id;
              var index;
      Severity: Minor
      Found in lib/tracesConverter.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

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

      module.exports = function (request, app, db) {
      
          var mongoController;
      
          /**-------------------------------------------------------------**/
      Severity: Major
      Found in test/upgraderTests/mongo/mongoController.js - About 4 hrs to fix

        File classesTest.js has 334 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/classesTest.js - About 4 hrs to fix

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

                  getParticipants(indexName)
                      .then(function (participants) {
                          kibana.auth(config, function (error, token) {
                              if (error) {
                                  return deferred.reject(error);
          Severity: Major
          Found in lib/kibana/kibana.js and 1 other location - About 4 hrs to fix
          lib/kibana/kibana.js on lines 682..695

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

          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

                                  getParticipants(id)
                                      .then(function (participants) {
                                          kibana.auth(config, function (error, token) {
                                              if (error) {
                                                  return deferred.reject(error);
          Severity: Major
          Found in lib/kibana/kibana.js and 1 other location - About 4 hrs to fix
          lib/kibana/kibana.js on lines 822..835

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

          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 27 (exceeds 5 allowed). Consider refactoring.
          Open

          module.exports = (function () {
              var Collection = require('easy-collections');
              var db = require('./db');
              var utils = require('./utils');
              var groups = require('./groups');
          Severity: Minor
          Found in lib/groupings.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 exports has a Cognitive Complexity of 27 (exceeds 5 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: Minor
          Found in lib/collector.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

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

          router.put('/external/:domain/:externalId', function (req, res) {
              var username = req.headers['x-gleaner-user'];
              restUtils.processResponse(classes.isAuthorizedForExternal(req.params.domain, req.params.externalId, username, 'put', '/classes/external/:domain/:externalId')
                  .then(function (classReq) {
                      return classes.modifyClass(classReq._id, username, req.body, true);
          Severity: Major
          Found in routes/classes.js and 1 other location - About 3 hrs to fix
          routes/classes.js on lines 342..348

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

          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

          router.put('/external/:domain/:externalId/remove', function (req, res) {
              var username = req.headers['x-gleaner-user'];
              restUtils.processResponse(classes.isAuthorizedForExternal(req.params.domain, req.params.externalId, username, 'put', '/classes/external/:domain/:externalId/remove')
                  .then(function (classReq) {
                      return classes.modifyClass(classReq._id, username, req.body, false);
          Severity: Major
          Found in routes/classes.js and 1 other location - About 3 hrs to fix
          routes/classes.js on lines 300..306

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

          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

                  if (objectId) {
                      if (endsWith(objectId, '/')) {
                          return buildReturnError('Object Id cannot end with / for statement, ' + statement);
                      }
                      index = objectId.lastIndexOf('/');
          Severity: Major
          Found in lib/tracesConverter.js and 1 other location - About 3 hrs to fix
          lib/tracesConverter.js on lines 33..45

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

          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

                      if (definitionType) {
                          if (endsWith(definitionType, '/')) {
                              return buildReturnError('Object definition type cannot end with / for statement, ' + statement);
                          }
                          index = definitionType.lastIndexOf('/');
          Severity: Major
          Found in lib/tracesConverter.js and 1 other location - About 3 hrs to fix
          lib/tracesConverter.js on lines 16..28

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

          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