e-ucm/rage-analytics-backend

View on GitHub

Showing 590 of 590 total issues

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

module.exports = function (grunt) {

    // Code adapted from http://stackoverflow.com/a/18402335/15472
    grunt.registerTask('default', function () {

Severity: Minor
Found in Gruntfile.js - About 1 hr 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 getEvent has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

var getEvent = function (statement, trace) {
    var verb = statement.verb;
    if (verb) {
        var verbId = verb.id;
        if (verbId) {
Severity: Minor
Found in lib/tracesConverter.js - About 1 hr 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

module.exports.deleteById = function (collection) {
    return function (req, res) {
        module.exports.processResponse(collection.removeById(req.params.id), res);
    };
};
Severity: Major
Found in routes/rest-utils.js and 1 other location - About 1 hr to fix
routes/rest-utils.js on lines 38..42

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

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

            for (var i = 0; i < query.$or.length; i++) {
                query.$or[i] = Object.assign(query.$or[i], otherfilters);
            }
Severity: Major
Found in lib/activities.js and 1 other location - About 1 hr to fix
lib/classes.js on lines 370..372

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

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: ObjectID('59565c67370740006dc1ab7c'),
            gameId: ObjectID('59289445370740006dc1a794'),
            versionId: ObjectID('59289445370740006dc1a795'),
            name: 'Automatic Class (g2c1s1)',
Severity: Major
Found in test/upgraderTests/mongo/upgradeOutputs/exampleTo2OUT.js and 1 other location - About 1 hr to fix
test/upgraderTests/mongo/upgradeOutputs/exampleTo2OUT.js on lines 132..150

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

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

module.exports.findById = function (collection) {
    return function (req, res) {
        module.exports.processResponse(collection.findById(req.params.id), res);
    };
};
Severity: Major
Found in routes/rest-utils.js and 1 other location - About 1 hr to fix
routes/rest-utils.js on lines 55..59

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

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: ObjectID('595bac18370740006dc1ab7d'),
            gameId: ObjectID('59289445370740006dc1a794'),
            versionId: ObjectID('59289445370740006dc1a795'),
            name: 'Automatic Class (g2c1s2)',
Severity: Major
Found in test/upgraderTests/mongo/upgradeOutputs/exampleTo2OUT.js and 1 other location - About 1 hr to fix
test/upgraderTests/mongo/upgradeOutputs/exampleTo2OUT.js on lines 113..131

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

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

            for (var i = 0; i < query.$or.length; i++) {
                query.$or[i] = Object.assign(query.$or[i], otherfilters);
            }
Severity: Major
Found in lib/classes.js and 1 other location - About 1 hr to fix
lib/activities.js on lines 316..318

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

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

AbstractController.prototype.refresh = function (callback) {
    this.nextTransformer = null;
    this.getModelVersion(this.appConfig, function (err, modelVersion) {
        if (err) {
            console.log('Cannot retrieve the model version', err);
Severity: Minor
Found in bin/upgrade/controllers/abstract-controller.js - About 1 hr to fix

    Function createKibanaIndices has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        kibana.createKibanaIndices = function (indexName, indexTemplateId, user, config, esClient) {
            var deferred = Q.defer();
    
            var dataIndices = [indexName, 'thomaskilmann-' + indexName];
    
    
    Severity: Minor
    Found in lib/kibana/kibana.js - About 1 hr to fix

      Function modifyCourse has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          courses.modifyCourse = function (id, username, body, add) {
              var validationObj = v.validate(body, courseSchema);
              validationObj = validationObj.errors.length > 0 ? v.validate(body, participantsCourseSchema): validationObj;
              if (validationObj.errors && validationObj.errors.length > 0) {
                  throw {
      Severity: Minor
      Found in lib/courses.js - About 1 hr to fix

        Function results has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            activities.results = function (activityId, username, esClient) {
                return activities.find(activities.toObjectID(activityId), true)
                    .then(function (activity) {
        
                        if (!activity) {
        Severity: Minor
        Found in lib/activities.js - About 1 hr to fix

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

                      request.post('/api/offlinetraces/' + idActivityOffline)
                          .expect(200)
                          .set('Accept', 'application/json')
                          .set('X-Gleaner-User', 'username')
                          .attach('offlinetraces', './test/resources/offlinetraces.csv')
          Severity: Major
          Found in test/tests/offlinetracesTest.js and 1 other location - About 1 hr to fix
          test/tests/analysisTest.js on lines 69..77

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

          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 (user === 'dev') {
                                  deferred.resolve(response.hits.hits[0]._source.visualizationsDev ? response.hits.hits[0]._source.visualizationsDev : []);
                              } else if ('tch') {
                                  deferred.resolve(response.hits.hits[0]._source.visualizationsTch ? response.hits.hits[0]._source.visualizationsTch : []);
                              } else if ('all') {
          Severity: Major
          Found in lib/kibana/kibana.js and 1 other location - About 1 hr to fix
          lib/kibana/kibana.js on lines 201..209

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

          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 ('tch') {
                                  deferred.resolve(response.hits.hits[0]._source.visualizationsTch ? response.hits.hits[0]._source.visualizationsTch : []);
                              } else if ('all') {
                                  var c = response.hits.hits[0]._source.visualizationsTch.concat(
                                      response.hits.hits[0]._source.visualizationsDev.filter(function (item) {
          Severity: Major
          Found in lib/kibana/kibana.js and 1 other location - About 1 hr to fix
          lib/kibana/kibana.js on lines 199..209

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

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

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

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

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

          Refactorings

          Further Reading

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

                      request.post('/api/analysis/' + idVersion)
                          .expect(400)
                          .set('Accept', 'application/json')
                          .set('X-Gleaner-User', 'username')
                          .attach('analysis', './test/resources/flux.yml')
          Severity: Major
          Found in test/tests/analysisTest.js and 1 other location - About 1 hr to fix
          test/tests/offlinetracesTest.js on lines 198..218

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

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

          function upgrade(config, callback) {
              co(function* () {
          
          
                  let esClient = config.elasticsearch.esClient;
          Severity: Minor
          Found in bin/upgrade/transformers/elastic/transformToVersion2.js - About 1 hr to fix

            Function addTraces has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    addTraces: function (playerId, versionId, gameplayId, activity, data, convertedData) {
                        if (!activity) {
                            return {
                                then: function (next) {
                                    return next(false);
            Severity: Minor
            Found in lib/consumers/kafka.js - About 1 hr to fix

              Function genYMLAndLaunch has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  var genYMLAndLaunch = function (src, ymlPath, stormJar, config) {
                      var deferred = Q.defer();
              
                      var configTemplate = Handlebars.compile(src);
                      Fs.writeFile(ymlPath, configTemplate(config), function (err) {
              Severity: Minor
              Found in lib/services/storm.js - About 1 hr to fix

                Function cloneVisualizationForId has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    kibana.cloneVisualizationForId = function (gameId, visualizationId, id, esClient) {
                        var deferred = Q.defer();
                
                        esClient.search({
                            index: '.games' + gameId,
                Severity: Minor
                Found in lib/kibana/kibana.js - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language