amcgee/remjs

View on GitHub

Showing 41 of 41 total issues

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

var skipHandler = function( req ) {
    if ( req.method !== 'GET' || !req.query.skip ) {
        return null;
    }

Severity: Major
Found in lib/modifiers/skip.js and 1 other location - About 4 hrs to fix
lib/modifiers/limit.js on lines 1..18

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

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

var limitHandler = function( req ) {
    if ( req.method !== 'GET' || !req.query.limit ) {
        return null;
    }

Severity: Major
Found in lib/modifiers/limit.js and 1 other location - About 4 hrs to fix
lib/modifiers/skip.js on lines 1..18

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

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

        return req.rem.db.update({ _id: doc._id }, { $set: obj }, {})
        .then(function(numReplaced) {
            if ( numReplaced === 0 ) {
                res.status(404).send("Resource update failed.");
            }
Severity: Major
Found in lib/actions/patch.js and 1 other location - About 2 hrs to fix
lib/actions/post-one.js on lines 27..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 81.

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

        return req.rem.db.update({ _id: doc._id }, obj, {})
        .then(function(numReplaced) {
            if ( numReplaced === 0 ) {
                res.status(404).send("Resource update failed.");
            }
Severity: Major
Found in lib/actions/post-one.js and 1 other location - About 2 hrs to fix
lib/actions/patch.js on lines 27..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 81.

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

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

    MongoEngine.prototype.collection = function(name) {
        if ( !this.collections[name] ) {
            this.collections[name] = new MongoCollection(this, name);
        }
        return this.collections[name];
    Severity: Major
    Found in lib/engines/mongodb.js and 1 other location - About 1 hr to fix
    lib/engines/sql.js on lines 65..70

    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

        _.forEach( this.filter, function( v, i ) {
            if ( _.isFunction(v) ) {
                query[i] = v(resource,req);
            } else {
                query[i] = v;
    Severity: Major
    Found in lib/options.js and 1 other location - About 1 hr to fix
    lib/options.js on lines 60..66

    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

    SQLEngine.prototype.collection = function(name) {
        if ( !this.collections[name] ) {
            this.collections[name] = new SQLCollection(this, name);
        }
        return this.collections[name];
    Severity: Major
    Found in lib/engines/sql.js and 1 other location - About 1 hr to fix
    lib/engines/mongodb.js on lines 136..141

    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

        _.forEach( this.defaults, function( v, i ) {
            if ( _.isFunction(v) ) {
                obj[i] = v(resource,req);
            } else {
                obj[i] = v;
    Severity: Major
    Found in lib/options.js and 1 other location - About 1 hr to fix
    lib/options.js on lines 45..51

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

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

              options.filter[parent.options.makeForeignKey(parent.name)] = function(resource, req) {
                  return req.rem.bound_id[parent.name];
              }.bind(this);
          Severity: Major
          Found in lib/options.js and 1 other location - About 1 hr to fix
          lib/options.js on lines 33..35

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

          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

              options.defaults[parent.options.makeForeignKey(parent.name)] = function(resource, req) {
                  return req.rem.bound_id[parent.name];
              }.bind(this);
          Severity: Major
          Found in lib/options.js and 1 other location - About 1 hr to fix
          lib/options.js on lines 29..31

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

          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 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
                      Severity
                      Category
                      Status
                      Source
                      Language