stellar/stellar-wallet

View on GitHub

Showing 47 of 47 total issues

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

wallets.create = function(req, res, next) {
  var attrs = _.pick(req.body, [
    "username",
    "walletId",
    "salt", 
Severity: Minor
Found in lib/controllers/v2/wallets.js - About 1 hr to fix

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

    wallet.create = function(params) {
      return Promise.resolve(params)
        .tap(function(p) {
          if(p.authToken === "success") {
            throw new errors.DuplicateRecord();
    Severity: Minor
    Found in lib/models/wallet.js - About 1 hr to fix

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

      signedJson.middleware = function(req, res, next) {
        var authHeader = req.headers.authorization;
      
        signedJson.parseAuthorizationHeader(authHeader)
          .bind({})
      Severity: Minor
      Found in lib/util/signed-json.js - About 1 hr to fix

        Function hash has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        validate.hash = function (prop, options) {
          if(!options) {
            options = {};
          }
        
        
        Severity: Minor
        Found in lib/util/validate.js - About 1 hr to fix

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

          wallet.update  = function(id, authToken, changes) {
          
            return wallet.get(id).then(function(w) {
          
              // if we couldn't find a wallet, fail
          Severity: Minor
          Found in lib/models/wallet.js - About 1 hr to fix

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

                if(!validLength) {
                  e = new validate.errors.InvalidUsername(prop + " is not 3-255 characters");
                  e.field = prop;
                  return Promise.reject(e);
                }
            Severity: Minor
            Found in lib/util/validate.js and 1 other location - About 55 mins to fix
            lib/util/validate.js on lines 106..110

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

            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

                if(!validEmail) {
                  e = new validate.errors.InvalidUsername(prop + " contains invalid characters");
                  e.field = prop;
                  return Promise.reject(e);
                }
            Severity: Minor
            Found in lib/util/validate.js and 1 other location - About 55 mins to fix
            lib/util/validate.js on lines 100..104

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

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

            wallet.replace = function(oldId, oldAuthToken, newId, newAuthToken) {
              return Promise.all([
                  wallet.get(oldId),
                  wallet.get(newId)
                ])
            Severity: Minor
            Found in lib/models/wallet.js - About 55 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

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

            exports.up = function(db, callback) {
              db.removeIndex('wallets_v2', 'walletId', function() {
                db.addIndex('wallets_v2', 'walletId_unique', ['walletId'], true, callback);
              });
            };
            Severity: Major
            Found in migrations/20140930183011-make-walletId-unique.js and 3 other locations - About 55 mins to fix
            migrations/20140930183011-make-walletId-unique.js on lines 10..14
            migrations/20141030233152-de-unique-wallet-ids.js on lines 4..8
            migrations/20141030233152-de-unique-wallet-ids.js on lines 10..14

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

            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 db("wallets_v2").insert(insertAttrs)
                    .then(function(wallet) {
                      attrs.wallet = wallet;
                      return Promise.resolve(attrs);
                    })
            Severity: Minor
            Found in lib/models/wallet-v2.js and 1 other location - About 55 mins to fix
            lib/models/wallet.js on lines 67..73

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

            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 db("wallets").insert(params).catch(function(e) {
                    if(e.errno === 1062) {
                      e = new errors.DuplicateRecord(e.message);
                    }
            
            
            Severity: Minor
            Found in lib/models/wallet.js and 1 other location - About 55 mins to fix
            lib/models/wallet-v2.js on lines 137..148

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

            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 4 locations. Consider refactoring.
            Open

            exports.down = function(db, callback) {
              db.removeIndex('wallets_v2', 'walletId', function() {
                db.addIndex('wallets_v2', 'walletId_unique', ['walletId'], true, callback);
              });
            };
            Severity: Major
            Found in migrations/20141030233152-de-unique-wallet-ids.js and 3 other locations - About 55 mins to fix
            migrations/20140930183011-make-walletId-unique.js on lines 4..8
            migrations/20140930183011-make-walletId-unique.js on lines 10..14
            migrations/20141030233152-de-unique-wallet-ids.js on lines 4..8

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

            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 4 locations. Consider refactoring.
            Open

            exports.down = function(db, callback) {
              db.removeIndex('wallets_v2', 'walletId_unique', function() {
                db.addIndex('wallets_v2', 'walletId', ['walletId'], false, callback);
              });
            };
            Severity: Major
            Found in migrations/20140930183011-make-walletId-unique.js and 3 other locations - About 55 mins to fix
            migrations/20140930183011-make-walletId-unique.js on lines 4..8
            migrations/20141030233152-de-unique-wallet-ids.js on lines 4..8
            migrations/20141030233152-de-unique-wallet-ids.js on lines 10..14

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

            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 4 locations. Consider refactoring.
            Open

            exports.up = function(db, callback) {
              db.removeIndex('wallets_v2', 'walletId_unique', function() {
                db.addIndex('wallets_v2', 'walletId', ['walletId'], false, callback);
              });
            };
            Severity: Major
            Found in migrations/20141030233152-de-unique-wallet-ids.js and 3 other locations - About 55 mins to fix
            migrations/20140930183011-make-walletId-unique.js on lines 4..8
            migrations/20140930183011-make-walletId-unique.js on lines 10..14
            migrations/20141030233152-de-unique-wallet-ids.js on lines 10..14

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

            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', 'recoveryId', { type: type.STRING, length: "255", notNull: false }, callback);
            };
            Severity: Minor
            Found in migrations/20140617214446-optional-recoveryId.js and 1 other location - About 50 mins to fix
            migrations/20140617214446-optional-recoveryId.js on lines 8..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 52.

            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', 'recoveryId', { type: type.STRING, length: "255", notNull: true }, callback);
            };
            Severity: Minor
            Found in migrations/20140617214446-optional-recoveryId.js and 1 other location - About 50 mins to fix
            migrations/20140617214446-optional-recoveryId.js on lines 4..6

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

            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

              if (_.isEmpty(id)) {
                res.status(400).send({
                  "status": "fail",
                  "field":  "id",
                  "code":   "missing"
            Severity: Minor
            Found in lib/controllers/wallets.js and 1 other location - About 50 mins to fix
            lib/controllers/wallets.js on lines 151..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 51.

            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

              if (_.isEmpty(recoveryId)) {
                res.status(400).send({
                  "status": "fail",
                  "field":  "recoveryId",
                  "code":   "missing"
            Severity: Minor
            Found in lib/controllers/wallets.js and 1 other location - About 50 mins to fix
            lib/controllers/wallets.js on lines 42..49

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

            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

                if(isEmpty) {
                  var e = new validate.errors.MissingField(prop + " is blank");
                  e.field = prop;
                  return Promise.reject(e);
                } else {
            Severity: Minor
            Found in lib/util/validate.js and 1 other location - About 40 mins to fix
            lib/util/validate.js on lines 78..82

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

            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

                } catch(err) {
                  var e = new validate.errors.NotJson(prop + " is not json");
                  e.field = prop;
                  return Promise.reject(e);
                }
            Severity: Minor
            Found in lib/util/validate.js and 1 other location - About 40 mins to fix
            lib/util/validate.js on lines 62..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 48.

            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