stellar/stellar-wallet

View on GitHub

Showing 47 of 47 total issues

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

  wallet.createRecovery(id, authToken, changes)
    .then (function(wallet) {
      res.send({"status" : "success"});
    })
    .catch(errors.RecordNotFound, errors.Forbidden, failAndRecordLockout(req,res))
Severity: Major
Found in lib/controllers/wallets.js and 1 other location - About 5 hrs to fix
lib/controllers/wallets.js on lines 118..132

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

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

  wallet.update(id, authToken, changes)
    .then (function(wallet) { 
      res.send({"status" : "success"}); 
    })
    .catch(errors.RecordNotFound, errors.Forbidden, failAndRecordLockout(req,res))
Severity: Major
Found in lib/controllers/wallets.js and 1 other location - About 5 hrs to fix
lib/controllers/wallets.js on lines 181..195

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

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

exports.up = function(db, callback) {
  db.changeColumn('wallets', 'mainData', { type: type.TEXT, length:16777216 }, function(){
    db.changeColumn('wallets', 'keychainData', { type: type.TEXT, length:16777216 }, function(){
      db.changeColumn('wallets', 'recoveryData', { type: type.TEXT, length:16777216 }, callback);
    });
Severity: Major
Found in migrations/20140802203119-expand-text-columns.js and 1 other location - About 4 hrs to fix
migrations/20140802203119-expand-text-columns.js on lines 12..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 115.

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

exports.down = function(db, callback) {
  db.changeColumn('wallets', 'mainData', { type: type.TEXT, length:65535 }, function(){
    db.changeColumn('wallets', 'keychainData', { type: type.TEXT, length:65535 }, function(){
      db.changeColumn('wallets', 'recoveryData', { type: type.TEXT, length:65535 }, callback);
    });
Severity: Major
Found in migrations/20140802203119-expand-text-columns.js and 1 other location - About 4 hrs to fix
migrations/20140802203119-expand-text-columns.js on lines 4..10

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

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

      return db("wallets_v2")
        .where({id:id, lockVersion:lockVersion})
        .whereNull("deletedAt")
        .update(attrs)
        .then(function (changedRows) {
Severity: Major
Found in lib/models/wallet-v2.js and 1 other location - About 3 hrs to fix
lib/models/wallet-v2.js on lines 170..180

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

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

      return db("wallets_v2")
        .where({id:id, lockVersion:lockVersion})
        .whereNull("deletedAt")
        .update(updateAttrs)
        .then(function (changedRows) {
Severity: Major
Found in lib/models/wallet-v2.js and 1 other location - About 3 hrs to fix
lib/models/wallet-v2.js on lines 202..212

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

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

exports.down = function(db, callback) {
  db.changeColumn('wallets', 'mainData', { type: type.BLOB }, function(){
    db.changeColumn('wallets', 'keychainData', { type: type.BLOB }, function(){
      db.changeColumn('wallets', 'recoveryData', { type: type.BLOB }, callback);
    });
Severity: Major
Found in migrations/20140618000315-text-blobs.js and 1 other location - About 3 hrs to fix
migrations/20140618000315-text-blobs.js on lines 4..10

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

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

exports.up = function(db, callback) {
  db.changeColumn('wallets', 'mainData', { type: type.TEXT }, function(){
    db.changeColumn('wallets', 'keychainData', { type: type.TEXT }, function(){
      db.changeColumn('wallets', 'recoveryData', { type: type.TEXT }, callback);
    });
Severity: Major
Found in migrations/20140618000315-text-blobs.js and 1 other location - About 3 hrs to fix
migrations/20140618000315-text-blobs.js on lines 12..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 100.

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

exports.down = function(db, callback) {
  db.removeColumn('wallets_v2', 'recoveryData', { type: type.TEXT, length:16777216 }, function(err) {
    if(err) {
      callback(err);
      return;
Severity: Major
Found in migrations/20141022130100-add-recoveryData-to-wallets-v2.js and 1 other location - About 3 hrs to fix
migrations/20141022130100-add-recoveryData-to-wallets-v2.js on lines 4..12

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

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

exports.up = function(db, callback) {
  db.addColumn('wallets_v2', 'recoveryData', { type: type.TEXT, length:16777216 }, function(err) {
    if(err) {
      callback(err);
      return;
Severity: Major
Found in migrations/20141022130100-add-recoveryData-to-wallets-v2.js and 1 other location - About 3 hrs to fix
migrations/20141022130100-add-recoveryData-to-wallets-v2.js on lines 14..22

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

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

walletV2.create = function(attrs) {

  return Promise.resolve(attrs)
    .then(validate.present("username"))
    .then(validate.present("walletId"))
Severity: Minor
Found in lib/models/wallet-v2.js - About 1 hr to fix

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

    wallets.update = signedJson.action(function(req, res, next) {
      var body = req.verified.body;
      /*
       * This method handles two situations:
       *
    Severity: Minor
    Found in lib/controllers/v2/wallets.js - About 1 hr to fix

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

        function(req, res) {
          Promise.delay(lockout.SLEEP_TIME)
            .then(function() {
              res.status(404).send({ "status": "fail", "code": "not_found" });
            });
      Severity: Major
      Found in lib/controllers/wallets.js and 1 other location - About 1 hr to fix
      lib/controllers/wallets.js on lines 28..33

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

      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

        function(req, res) {
          Promise.delay(lockout.SLEEP_TIME)
            .then(function() {
              res.status(404).send({ "status": "fail", "code": "not_found" });
            });
      Severity: Major
      Found in lib/controllers/wallets.js and 1 other location - About 1 hr to fix
      lib/controllers/wallets.js on lines 16..21

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

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

      wallets.create = [rejectSpammedCreates, function(req, res, next) {
        var walletToSubmit = _.pick(req.body, [
          'id',
          'authToken',
          'mainData',
      Severity: Minor
      Found in lib/controllers/wallets.js - About 1 hr to fix

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

          return Promise.resolve(attrs)
            .then(validate.present("username"))
            .then(validate.present("walletId"))
            .then(validate.present("salt"))
            .then(validate.present("kdfParams"))
        Severity: Major
        Found in lib/models/wallet-v2.js and 1 other location - About 1 hr to fix
        lib/models/wallet.js on lines 162..178

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

        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

            return Promise.resolve(changes)
              .then(validate.present('recoveryId'))
              .then(validate.present('recoveryData'))
              .then(validate.hash('recoveryData'))
              .then(function(changes){
        Severity: Major
        Found in lib/models/wallet.js and 1 other location - About 1 hr to fix
        lib/models/wallet-v2.js on lines 109..113

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

        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

            return Promise.resolve(changes)
              .then(validate.hash('mainData',     {allowBlank: true}))
              .then(validate.hash('keychainData', {allowBlank: true}))
              .then(function(changes){
                changes = _.pick(changes, ['mainData', 'keychainData']);
        Severity: Major
        Found in lib/models/wallet.js and 1 other location - About 1 hr to fix
        lib/models/wallet-v2.js on lines 162..181

        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

          return Promise.resolve(attrs)
            .then(validate.hash('mainData',     {allowBlank: true}))
            .then(validate.hash('keychainData', {allowBlank: true}))
            .then(function(attrs) {
              var updateAttrs         =  _.omit(attrs, ['mainDataHash', 'keychainDataHash']);
        Severity: Major
        Found in lib/models/wallet-v2.js and 1 other location - About 1 hr to fix
        lib/models/wallet.js on lines 95..112

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

        totp.enable =  signedJson.action(function(req, res, next) {
          var body = req.verified.body;
        
          walletV2.getByWalletId(req.verified.username, req.verified.walletId)
            .then(function (wallet) {
        Severity: Minor
        Found in lib/controllers/v2/totp.js - About 1 hr to fix
          Severity
          Category
          Status
          Source
          Language