e-ucm/rage-analytics-backend

View on GitHub

Showing 590 of 590 total issues

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

module.exports = {
    backup: backup,
    upgrade: upgrade,
    check: check,
    clean: clean,
Severity: Major
Found in bin/upgrade/transformers/mongo/transformToVersion2.js and 2 other locations - About 1 hr to fix
bin/upgrade/transformers/mongo/transformToVersion3.js on lines 142..153
bin/upgrade/transformers/mongo/transformToVersion4.js on lines 352..363

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

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.get('/:id/groups', function (req, res) {
    restUtils.processResponse(groups.find({classId: new ObjectID(req.params.id)}), res);
});
Severity: Major
Found in routes/groups.js and 1 other location - About 1 hr to fix
routes/groupings.js on lines 35..37

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

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

            classes.find(query).then(function (classes) {
                deferred.resolve(classes);
            }).fail(function (err) {
                deferred.reject(err);
            });
Severity: Major
Found in lib/classes.js and 1 other location - About 1 hr to fix
lib/activities.js on lines 320..324

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

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

module.exports = {
    backup: backup,
    upgrade: upgrade,
    check: check,
    clean: clean,
Severity: Major
Found in bin/upgrade/transformers/mongo/transformToVersion4.js and 2 other locations - About 1 hr to fix
bin/upgrade/transformers/mongo/transformToVersion2.js on lines 131..142
bin/upgrade/transformers/mongo/transformToVersion3.js on lines 142..153

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

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.get('/:id/groupings', function (req, res) {
    restUtils.processResponse(groupings.find({classId: new ObjectID(req.params.id)}), res);
});
Severity: Major
Found in routes/groupings.js and 1 other location - About 1 hr to fix
routes/groups.js on lines 41..43

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

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

module.exports = {
    backup: backup,
    upgrade: upgrade,
    check: check,
    clean: clean,
Severity: Major
Found in bin/upgrade/transformers/mongo/transformToVersion3.js and 2 other locations - About 1 hr to fix
bin/upgrade/transformers/mongo/transformToVersion2.js on lines 131..142
bin/upgrade/transformers/mongo/transformToVersion4.js on lines 352..363

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

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

            activities.find(query).then(function (activities) {
                deferred.resolve(activities);
            }).fail(function (err) {
                deferred.reject(err);
            });
Severity: Major
Found in lib/activities.js and 1 other location - About 1 hr to fix
lib/classes.js on lines 374..378

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

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

    games.removeGame = function (username, gameId) {
        return games.findById(gameId)
            .then(function (game) {
                if (!game) {
                    throw {
Severity: Minor
Found in lib/games.js - About 1 hr to fix

    Function removeCourse has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        courses.removeCourse = function (id, username) {
            return courses.findById(id)
                .then(function (courseRes) {
                    if (!courseRes) {
                        throw {
    Severity: Minor
    Found in lib/courses.js - About 1 hr to fix

      Function generateDashboard has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          kibana.generateDashboard = function(id, panels, uiStates, extra) {
              console.log('Kibana -> generateDashboard');
      
              var timeFrom = 'now-1h';
              var refreshInterval = {
      Severity: Minor
      Found in lib/kibana/kibana.js - About 1 hr to fix

        Function updateResult has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

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

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

                  companyName: ['projectName', function (done) {
          
                      var promptOptions = {
                          default: defaultValues.companyName || 'e-UCM Research Group'
                      };
          Severity: Major
          Found in bin/setup.js and 2 other locations - About 1 hr to fix
          bin/setup.js on lines 90..97
          bin/setup.js on lines 110..117

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

          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 (!(yield at(esClient.indices.exists({index: to})))) {
                  yield at(esClient.indices.create({index: to}));
              }
          Severity: Major
          Found in bin/upgrade/transformers/elastic/transformToVersion2.js and 1 other location - About 1 hr to fix
          bin/upgrade/transformers/elastic/transformToVersion2.js on lines 558..560

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

          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

                  mongodbUrl: ['companyName', function (done) {
          
                      var promptOptions = {
                          default: defaultValues.mongodbUrl || 'mongodb://localhost:27017/analytics-backend'
                      };
          Severity: Major
          Found in bin/setup.js and 2 other locations - About 1 hr to fix
          bin/setup.js on lines 82..89
          bin/setup.js on lines 110..117

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

          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 (!(yield at(esClient.indices.exists({index: upgradeIndex})))) {
                  yield at(esClient.indices.create({index: upgradeIndex}));
              }
          Severity: Major
          Found in bin/upgrade/transformers/elastic/transformToVersion2.js and 1 other location - About 1 hr to fix
          bin/upgrade/transformers/elastic/transformToVersion2.js on lines 251..253

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

          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

                  apiPath: ['testMongo', function (done) {
          
                      var promptOptions = {
                          default: defaultValues.apiPath || '/api'
                      };
          Severity: Major
          Found in bin/setup.js and 2 other locations - About 1 hr to fix
          bin/setup.js on lines 82..89
          bin/setup.js on lines 90..97

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

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

          function check(config, callback) {
              config.mongodb.db.db.listCollections().toArray(function (err, collections) {
                  if (err) {
                      console.log('Unexpected error while checking collections names!', err);
                      return callback(err, config);
          Severity: Minor
          Found in bin/upgrade/transformers/mongo/transformToVersion4.js - About 1 hr to fix

            Function checkNeedsUpdateVisualization has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function checkNeedsUpdateVisualization(visualization) {
            
                let visState = JSON.parse(visualization._source.visState.replaceAll('\\\"', '"'));
            
                /*
            Severity: Minor
            Found in bin/upgrade/transformers/elastic/transformToVersion2.js - About 1 hr to fix

              Function getUserType has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  groupings.getUserType = function(groupingId, username, ignoreStudents, ignoreAssistants, ignoreTeachers) {
                      var type = 'unauthorized';
              
                      return groupings.findById(groupingId).then(function (grouping) {
                          if (grouping) {
              Severity: Minor
              Found in lib/groupings.js - About 1 hr to fix

                Function removeFolder has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    function removeFolder(location, next) {
                        fs.readdir(location, function (err, files) {
                            async.each(files, function (file, cb) {
                                file = location + '/' + file;
                                fs.stat(file, function (err, stat) {
                Severity: Minor
                Found in lib/analysis.js - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language