stellar/stellar-wallet

View on GitHub

Showing 13 of 47 total issues

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

      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

        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

          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

                    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

                    Avoid too many return statements within this function.
                    Open

                          return db('wallets')
                            .where('id', oldWallet.id)
                            .del();
                    Severity: Major
                    Found in lib/models/wallet.js - About 30 mins to fix

                      Function update has a Cognitive Complexity of 6 (exceeds 5 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 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

                      Function showRecovery has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                      wallets.showRecovery = [lockoutByIP, function(req, res, next) {
                        return fail(res, {"code": "maintenance"});
                      
                        return walletV2.get(req.body.username)
                          .then(function checkRecoveryId(wallet) {
                      Severity: Minor
                      Found in lib/controllers/v2/wallets.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