amcgee/remjs

View on GitHub

Showing 17 of 41 total issues

Function meRouter has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Authenticator.prototype.meRouter = function() {
    var meRouter = express.Router();

    meRouter.use( function(req, res, next) {
        if ( !req.rem.identity ) {
Severity: Minor
Found in lib/plugins/authentication.js - About 1 hr to fix

    Function REMResource has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    var REMResource = function(name, opt, parent) {
        this.router = express.Router();
        this.name = name;
        this.options = new REMOptions(this, opt, parent);
        this.permissions = new PermissionsManager(this);
    Severity: Minor
    Found in lib/resource.js - About 1 hr to fix

      Function handler has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      var handler = function(req, res) {
          if ( !_.isObject( req.body ) ) {
              res.status(400).send("Invalid request body.");
          }
          if ( !req.rem.db.findOne || !req.rem.db.update ) {
      Severity: Minor
      Found in lib/actions/patch.js - About 1 hr to fix

        Function handler has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        var handler = function(req, res) {
            if ( !_.isObject( req.body ) ) {
                res.status(400).send("Invalid request body.");
            }
            if ( !req.rem.db.findOne || !req.rem.db.update ) {
        Severity: Minor
        Found in lib/actions/post-one.js - About 1 hr to fix

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

          LoginHelper.prototype.create = function( login, password, misc, callback ) {
              return this.lookup( { login: login } )
              .bind(this)
              .then( function() {
                  throw new LoginAlreadyExistsError();
          Severity: Minor
          Found in lib/plugins/auth_helpers/login.js - About 1 hr to fix

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

            LoginHelper.prototype.lookup = function( candidate, with_sensitive, callback ) {
                var query = {};
                if ( candidate._id ) {
                    query._id = candidate._id;
                }
            Severity: Minor
            Found in lib/plugins/auth_helpers/login.js - About 1 hr to fix

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

              var handler = function(req, res) {
                  if ( !_.isObject( req.body ) ) {
                      res.status(400).send("Invalid request body.");
                  }
                  if ( !req.rem.db.insert ) {
              Severity: Minor
              Found in lib/actions/post-collection.js - About 1 hr to fix

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

                    function( login, old_password, new_password, misc, callback ) {
                    var identity = null;
                
                    return this.check( login, old_password )
                    .bind(this)
                Severity: Minor
                Found in lib/plugins/auth_helpers/login.js - About 1 hr to fix

                  Function parse has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  JWT.prototype.parse = function( token, callback ) {
                      return BPromise.try( function() {
                          return jwt.decode( token, this.secret );
                      }.bind(this) )
                      .bind(this)
                  Severity: Minor
                  Found in lib/plugins/auth_helpers/jwt.js - About 1 hr to fix

                    Function createRouter has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    REM.prototype.createRouter = function() {
                        var router = express.Router();
                    
                        router.use( function(req, res, next) {
                            req.rem = {};
                    Severity: Minor
                    Found in lib/core.js - About 1 hr to fix

                      Function parse has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                      JWT.prototype.parse = function( token, callback ) {
                          return BPromise.try( function() {
                              return jwt.decode( token, this.secret );
                          }.bind(this) )
                          .bind(this)
                      Severity: Minor
                      Found in lib/plugins/auth_helpers/jwt.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 apply has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                      PermissionsManager.prototype.apply = function(action, req, res, next) {
                          var anonymous = !req.rem.identity;
                          var permissions = ( anonymous )? this.anonymous_permissions : this.defaults;
                          if ( _.isArray(permissions) && _.contains( permissions, action ) ) {
                              return next();
                      Severity: Minor
                      Found in lib/plugins/permissions.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 check has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      LoginHelper.prototype.check = function( login, password, callback ) {
                          var identity = null;
                          return this.lookup( { login: login }, true )
                          .bind(this)
                          .catch( function( err ) {
                      Severity: Minor
                      Found in lib/plugins/auth_helpers/login.js - About 1 hr to fix

                        Function update has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            function( login, old_password, new_password, misc, callback ) {
                        Severity: Minor
                        Found in lib/plugins/auth_helpers/login.js - About 35 mins to fix

                          Function _create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                          NeDBEngine.prototype._create = function( name, file ) {
                              if ( !file && this.options.createCollection ) {
                                  return this.options.createCollection( name );
                              }
                              else {
                          Severity: Minor
                          Found in lib/engines/nedb.js - About 35 mins 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 REMResource has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                          var REMResource = function(name, opt, parent) {
                              this.router = express.Router();
                              this.name = name;
                              this.options = new REMOptions(this, opt, parent);
                              this.permissions = new PermissionsManager(this);
                          Severity: Minor
                          Found in lib/resource.js - About 35 mins 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 LoginHelper has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                          var LoginHelper = function(options, resources) {
                              this.authority = _.clone( options.login_authority || { resource: 'users' } );
                              if ( !this.authority.resource ) {
                                  throw new Error( "Bad login authority " + JSON.stringify( this.authority ) );
                              }
                          Severity: Minor
                          Found in lib/plugins/auth_helpers/login.js - About 25 mins 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

                          Severity
                          Category
                          Status
                          Source
                          Language