Showing 208 of 208 total issues

File routes.js has 1292 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: Major
Found in test/routes.js - About 3 days to fix

    File controllers.js has 694 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: Major
    Found in public/controllers/controllers.js - About 1 day to fix

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

          describe(GET + usersRoute, function () {
      
              it('should not GET users with an invalid_token', function (done) {
                  get(usersRoute, 'invalid_token', UNAUTHORIZED, done);
              });
      Severity: Major
      Found in test/routes.js and 1 other location - About 1 day to fix
      test/routes.js on lines 602..636

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

      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

          describe(GET + applicationsRoute, function () {
      
              it('should not GET applications with an invalid_token', function (done) {
                  get(applicationsRoute, 'invalid_token', UNAUTHORIZED, done);
              });
      Severity: Major
      Found in test/routes.js and 1 other location - About 1 day to fix
      test/routes.js on lines 841..876

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

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

      module.exports = function (jwtMiddleware) {
      
          var startsWith = function (source, str) {
              return source.slice(0, str.length) === str;
          };
      Severity: Minor
      Found in routes/proxy.js - About 1 day 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 255 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = function (jwtMiddleware) {
      
          var startsWith = function (source, str) {
              return source.slice(0, str.length) === str;
          };
      Severity: Major
      Found in routes/proxy.js - About 1 day to fix

        Function oauthSetup has 253 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function oauthSetup(app) {
        
            var getUrl = function(req){
                return req.protocol + '://' + req.get('host');
            };
        Severity: Major
        Found in loginPlugins/_beaconing.js - About 1 day to fix

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

                  it('should correctly POST role1', function (done) {
          
                      authPost(rolesRoute, admin.token, role1, SUCCESS, function (err, res) {
                          res = JSON.parse(res.text);
                          should(res).be.an.Array();
          Severity: Major
          Found in test/routes.js and 1 other location - About 1 day to fix
          test/routes.js on lines 1156..1170

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

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

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

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

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

          Refactorings

          Further Reading

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

                  it('should correctly POST role2', function (done) {
          
                      authPost(rolesRoute, admin.token, role2, SUCCESS, function (err, res) {
                          res = JSON.parse(res.text);
                          should(res).be.an.Array();
          Severity: Major
          Found in test/routes.js and 1 other location - About 1 day to fix
          test/routes.js on lines 1140..1154

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

          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

          File users.js has 529 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: Major
          Found in routes/users.js - About 1 day to fix

            Function ltiSetup has 182 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function ltiSetup(app) {
            
                var userSchema = new mongoose.Schema({
                    key: {
                        type: String,
            Severity: Major
            Found in loginPlugins/lti.js - About 7 hrs to fix

              Function samlSetup has 167 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function samlSetup(app) {
              
                  /**
                   * Define a new 'saml' passport Strategy
                   */
              Severity: Major
              Found in loginPlugins/_saml.js - About 6 hrs to fix

                Function oauthSetup has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
                Open

                function oauthSetup(app) {
                
                    var getUrl = function(req){
                        return req.protocol + '://' + req.get('host');
                    };
                Severity: Minor
                Found in loginPlugins/_beaconing.js - About 5 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

                File applications.js has 401 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 routes/applications.js - About 5 hrs to fix

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

                              $scope.changeEmail = function () {
                                  $http.put('/api/users/' + $scope.uId, $scope.newEmail, {
                                      headers: {
                                          Authorization: 'Bearer ' + $scope.$storage.user.token
                                      }
                  Severity: Major
                  Found in public/controllers/controllers.js and 1 other location - About 5 hrs to fix
                  public/controllers/controllers.js on lines 769..780

                  Duplicated Code

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

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

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

                  Tuning

                  This issue has a mass of 140.

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

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

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

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

                  Refactorings

                  Further Reading

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

                              $scope.changeName = function () {
                                  $http.put('/api/users/' + $scope.uId, $scope.newName, {
                                      headers: {
                                          Authorization: 'Bearer ' + $scope.$storage.user.token
                                      }
                  Severity: Major
                  Found in public/controllers/controllers.js and 1 other location - About 5 hrs to fix
                  public/controllers/controllers.js on lines 782..793

                  Duplicated Code

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

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

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

                  Tuning

                  This issue has a mass of 140.

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

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

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

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

                  Refactorings

                  Further Reading

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

                              get(validRoleRouteId, admin.token, SUCCESS, function (err, res) {
                                  res = JSON.parse(res.text);
                                  should(res).be.an.Object();
                                  role2.resources.forEach(function (resource) {
                                      should(res[resource.toString()]).be.an.Array();
                  Severity: Major
                  Found in test/routes.js and 1 other location - About 5 hrs to fix
                  test/routes.js on lines 1243..1251

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

                  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

                              authPost(validResourcesRoleId, admin.token, resource1, SUCCESS, function (err, res) {
                                  res = JSON.parse(res.text);
                                  should(res).be.an.Object();
                                  resource1.resources.forEach(function (resource) {
                                      should(res[resource.toString()]).be.an.Array();
                  Severity: Major
                  Found in test/routes.js and 1 other location - About 5 hrs to fix
                  test/routes.js on lines 1197..1205

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

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

                  var RedisBackend = function (options) {
                      var client = require('redis').createClient(options.port, options.host, {});
                  
                      client.select(options.dbNumber || 0);
                  
                  
                  Severity: Minor
                  Found in tokenStorage/redis-backend.js - About 4 hrs to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

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

                  router.get(userIdRoute, authentication.authenticated, function (req, res, next) {
                      async.auto({
                          checkAuth: function (done) {
                              checkAuthAndExec(req, res, done);
                          },
                  Severity: Major
                  Found in routes/users.js and 1 other location - About 4 hrs to fix
                  routes/users.js on lines 258..272

                  Duplicated Code

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

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

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

                  Tuning

                  This issue has a mass of 127.

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

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

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

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

                  Refactorings

                  Further Reading

                  Severity
                  Category
                  Status
                  Source
                  Language