e-ucm/rage-analytics-backend

View on GitHub

Showing 590 of 590 total issues

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

        properties: {
            name: { type: 'string'},
            classId: { type: 'ID'},
            teachers: {
                type: 'array',
Severity: Major
Found in lib/groupings.js and 1 other location - About 1 hr to fix
lib/groupings.js on lines 18..29

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

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

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

    Function upgrade has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function upgrade(config, callback) {
        // Transformers
        var gamesCollection = config.mongodb.db.collection('games');
        var classesCollection = config.mongodb.db.collection('classes');
        var activitiesCollection = config.mongodb.db.collection('activities');
    Severity: Minor
    Found in bin/upgrade/transformers/mongo/transformToVersion4.js - About 1 hr to fix

      Function updateVisualizationMapping has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      var updateVisualizationMapping = function() {
          esClient.indices.putMapping({
              index: '.kibana',
              type: 'visualization',
              body: {
      Severity: Minor
      Found in bin/setup-kibana-templates.js - About 1 hr to fix

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

                            request.put('/api/classes/groupings/' + idGrouping)
                                .expect(200)
                                .set('X-Gleaner-User', 'teacher')
                                .send({
                                    name: 'groupingNewName',
        Severity: Major
        Found in test/tests/groupingsTest.js and 1 other location - About 1 hr to fix
        test/tests/groupingsTest.js on lines 134..160

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

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

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

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

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

        Refactorings

        Further Reading

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

                    request.put('/api/classes/groups/' + idGroup + '/remove')
                        .expect(401)
                        .set('X-Gleaner-User', 'notAllowedUsername')
                        .send({
                            participants: {
        Severity: Major
        Found in test/tests/groupsTest.js and 1 other location - About 1 hr to fix
        test/tests/groupsTest.js on lines 197..214

        Duplicated Code

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

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

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

        Tuning

        This issue has a mass of 71.

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

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

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

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

        Refactorings

        Further Reading

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

                    request.put('/api/classes/groupings/' + idGrouping)
                        .expect(401)
                        .set('X-Gleaner-User', 'notAllowedUsername')
                        .send({
                            name: 'groupingNewName',
        Severity: Major
        Found in test/tests/groupingsTest.js and 1 other location - About 1 hr to fix
        test/tests/groupingsTest.js on lines 144..159

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

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

            var getUserActivities = function (user, otherfilters) {
                otherfilters = otherfilters || {};
        
                var deferred = Q.defer();
                async.parallel({
        Severity: Minor
        Found in lib/activities.js - About 1 hr to fix

          Function createVisualizationsAndDashboard has 44 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              kibana.createVisualizationsAndDashboard = function(config, id, gameId, visualizations, user, esClient, extra) {
                  var deferred = Q.defer();
          
                  console.log('kibana.createVisualizationsAndDashboard() -> Started');
          
          
          Severity: Minor
          Found in lib/kibana/kibana.js - About 1 hr to fix

            Function compareDocuments has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

            var compareDocuments = function (doc1, doc2, ignoredFields) {
                if (ignoredFields === undefined || ignoredFields === null) {
                    ignoredFields = ['uuidv4'];
                }
            
            
            Severity: Minor
            Found in test/upgraderTests/upgraderTestUtils.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

                        request.put('/api/classes/groups/' + idGroup)
                            .expect(401)
                            .set('X-Gleaner-User', 'notAllowedUsername')
                            .send({
                                name: 'someGroupNameTest',
            Severity: Major
            Found in test/tests/groupsTest.js and 1 other location - About 1 hr to fix
            test/tests/groupsTest.js on lines 140..158

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

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

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

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

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

            Refactorings

            Further Reading

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

                                request.put('/api/classes/groups/' + idGroup)
                                    .expect(200)
                                    .set('X-Gleaner-User', 'teacher')
                                    .send({
                                        name: 'someGroupNameTest',
            Severity: Major
            Found in test/tests/groupsTest.js and 1 other location - About 1 hr to fix
            test/tests/groupsTest.js on lines 128..159

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

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

                var isAuthorizedForCommon = function(query, username, method, call) {
                    var deferred = Q.defer();
            
                    if (!minTypes[method] || !minTypes[method][call] || !minTypes[method][call].type) {
                        console.log('unauthorized');
            Severity: Minor
            Found in lib/classes.js - About 1 hr to fix

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

                      {
                          _id: ObjectID('595badbe370740006dc1ab81'),
                          gameId: ObjectID('59315d0d370740006dc1a7b6'),
                          versionId: ObjectID('59315d0d370740006dc1a7b7'),
                          classId: 'unknown',
              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 153..173

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

              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

                      for (let j = 0; j < defaultTraceAttributes.length; ++j) {
                          let defaultAttribute = defaultTraceAttributes[j];
              
                          if (fieldName === defaultAttribute ||
                              fieldName === defaultAttribute + '.keyword') {
              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 685..693

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

              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

                      for (let j = 0; j < defaultTraceAttributes.length; ++j) {
                          let defaultAttribute = defaultTraceAttributes[j];
              
                          if (field === defaultAttribute ||
                              field === defaultAttribute + '.keyword') {
              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 794..802

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

              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('595badad370740006dc1ab80'),
                          gameId: ObjectID('59315d0d370740006dc1a7b6'),
                          versionId: ObjectID('59315d0d370740006dc1a7b7'),
                          classId: 'unknown',
              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 174..194

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

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

              function clean(config, callback) {
                  co(function* () {
              
                      let esClient = config.elasticsearch.esClient;
                      yield at(esClient.indices.refresh({index: '_all'}));
              Severity: Minor
              Found in bin/upgrade/transformers/elastic/transformToVersion2.js - About 1 hr to fix

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

                                    request.put('/api/activities/' + idActivity)
                                        .expect(200)
                                        .set('X-Gleaner-User', 'Teacher1')
                                        .send({
                                            name: 'someSessionName',
                Severity: Major
                Found in test/tests/activitiesTest.js and 1 other location - About 1 hr to fix
                test/tests/activitiesTest.js on lines 252..269

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

                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('595badad370740006dc1ab80'),
                            gameId: ObjectID('59315d0d370740006dc1a7b6'),
                            versionId: ObjectID('59315d0d370740006dc1a7b7'),
                            name: 'Automatic Class (g1c1s1)',
                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 69..92

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

                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