darkwallet/darkwallet

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

Summary

Maintainability
D
1 day
Test Coverage

Function prepare has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Transaction.prototype.prepare = function(pocketId, recipients, changeAddress, fee, reserveOutputs) {
    var newAddresses = [];
    var wallet = this.identity.wallet;
    var totalAmount = 0;
    if (fee < 0) {
Severity: Major
Found in src/js/model/tx.js - About 2 hrs to fix

    File tx.js has 253 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    'use strict';
    
    define(['util/stealth', 'bitcoinjs-lib', 'util/btc'],
    function(Stealth, Bitcoin, BtcUtils) {
    
    
    Severity: Minor
    Found in src/js/model/tx.js - About 2 hrs to fix

      Function undo has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      Transaction.prototype.undo = function(tx, row) {
          var wallet = this.identity.wallet;
          var txHash = tx.getId();
          tx.ins.forEach(function(anIn) {
              var index = Bitcoin.bufferutils.reverse(anIn.hash).toString('hex') + ':' + anIn.index;
      Severity: Minor
      Found in src/js/model/tx.js - About 1 hr to fix

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

        Transaction.prototype.process = function(serializedTx, height) {
            var wallet = this.identity.wallet;
            var tx = Bitcoin.Transaction.fromHex(serializedTx);
            var txHash = tx.getId();
        
        
        Severity: Minor
        Found in src/js/model/tx.js - About 1 hr to fix

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

          Transaction.prototype.signMyInputs = function(inputs, newTx, privKeys) {
              var wallet = this.identity.wallet;
              var signed = false;
              for(var i=0; i<newTx.ins.length; i++) {
                  var anIn = newTx.ins[i];
          Severity: Minor
          Found in src/js/model/tx.js - About 1 hr to fix

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

            Transaction.prototype.sign = function(newTx, txUtxo, password, callback) {
                var wallet = this.identity.wallet;
                var pending = [];
            
                var hash = newTx.getId();
            Severity: Minor
            Found in src/js/model/tx.js - About 1 hr to fix

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

              Transaction.prototype.prepare = function(pocketId, recipients, changeAddress, fee, reserveOutputs) {
              Severity: Minor
              Found in src/js/model/tx.js - About 35 mins to fix

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

                        var found = inputs.filter(function(myIn) {
                            return (myIn.hash.toString('hex') === anIn.hash.toString('hex')) && (parseInt(myIn.index) === parseInt(anIn.index));
                        });
                Severity: Major
                Found in src/js/model/tx.js and 1 other location - About 1 hr to fix
                src/js/util/coinjoin.js on lines 297..299

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

                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 (wallet.wallet.outputs[Bitcoin.bufferutils.reverse(anIn.hash).toString('hex')+":"+anIn.index]) {
                Severity: Minor
                Found in src/js/model/tx.js and 1 other location - About 40 mins to fix
                src/js/model/tx.js on lines 361..361

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

                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 o = wallet.wallet.outputs[Bitcoin.bufferutils.reverse(op.hash).toString('hex')+':'+op.index];
                Severity: Minor
                Found in src/js/model/tx.js and 1 other location - About 40 mins to fix
                src/js/model/tx.js on lines 227..227

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

                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

                        newTx.addInput(utxo.receive.split(":")[0], parseInt(utxo.receive.split(":")[1]));
                Severity: Minor
                Found in src/js/model/tx.js and 1 other location - About 40 mins to fix
                src/js/util/bip47.js on lines 84..84

                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

                    return {tx: newTx, utxo: txUtxo, total: totalAmount, fee: fee, change: change, myamount: outAmount, stealth: isStealth, recipients: recipients, created: newAddresses};
                Severity: Minor
                Found in src/js/model/tx.js and 1 other location - About 35 mins to fix
                src/vendors/bitcoinjs-lib/bitcoinjs.js on lines 3729..3739

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

                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