darkwallet/darkwallet

View on GitHub
src/js/model/wallet.js

Summary

Maintainability
D
1 day
Test Coverage

File wallet.js has 400 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

define(['util/stealth', 'bitcoinjs-lib', 'model/multisig', 'model/pockets', 'util/btc', 'model/output'],
function(Stealth, Bitcoin, MultisigFunds, Pockets, BtcUtils, Output) {
/**
Severity: Minor
Found in src/js/model/wallet.js - About 5 hrs to fix

    Function getUtxoToPay has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    Wallet.prototype.getUtxoToPay = function(value, pocketId, type) {
        var tmpWallet, dust=this.dust;
        if (pocketId === 'all') {
            tmpWallet = this.wallet;
        } else {
    Severity: Minor
    Found in src/js/model/wallet.js - About 1 hr to fix

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

      Wallet.prototype.getBalance = function(pocketId, type) {
          var confirmed = 0;
          var unconfirmed = 0;
          var current = 0;
      
      
      Severity: Minor
      Found in src/js/model/wallet.js - About 1 hr to fix

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

        Wallet.prototype.processOutput = function(walletAddress, txHash, index, value, height, spend, spendheight) {
            // Wallet wide
            var wallet = this.wallet;
            var outId = txHash+":"+index;
            var output = wallet.outputs[outId];
        Severity: Minor
        Found in src/js/model/wallet.js - About 1 hr to fix

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

          Wallet.prototype.loadPubKeys = function() {
              var self = this;
          
              Object.keys(this.pubKeys).forEach(function(index) {
                  var walletAddress = self.pubKeys[index];
          Severity: Minor
          Found in src/js/model/wallet.js - About 1 hr to fix

            Function processOutput has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            Wallet.prototype.processOutput = function(walletAddress, txHash, index, value, height, spend, spendheight) {
            Severity: Major
            Found in src/js/model/wallet.js - About 50 mins to fix

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

              Wallet.prototype.processStealthMatch = function(pocketIndex, ephemKey, pubKey, address, quirk) {
              Severity: Minor
              Found in src/js/model/wallet.js - About 35 mins to fix

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

                        case 'testnet':
                            this.versions.stealth = {address: Stealth.testnet, nonce: Stealth.nonceVersion, prefix: 'w'};
                            this.versions.pcode = {address: 47, prefix: 'P'};
                            break;
                Severity: Major
                Found in src/js/model/wallet.js and 1 other location - About 1 hr to fix
                src/js/model/wallet.js on lines 48..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 70.

                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

                        case 'bitcoin':
                            this.versions.stealth = {address: Stealth.version, nonce: Stealth.nonceVersion, prefix: 'v'};
                            this.versions.pcode = {address: 47, prefix: 'P'};
                            break;
                Severity: Major
                Found in src/js/model/wallet.js and 1 other location - About 1 hr to fix
                src/js/model/wallet.js on lines 52..55

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

                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

                There are no issues that match your filters.

                Category
                Status