darkwallet/darkwallet

View on GitHub
src/js/util/multiParty.js

Summary

Maintainability
D
1 day
Test Coverage

Function receiveMessage has 95 lines of code (exceeds 25 allowed). Consider refactoring.
Open

multiParty.receiveMessage = function(sender, myName, message) {
    try {
        message = JSON.parse(message);
    }
    catch(err) {
Severity: Major
Found in src/js/util/multiParty.js - About 3 hrs to fix

    File multiParty.js has 294 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    'use strict';
    
    define(['bitcoinjs-lib', 'util/djbec', 'crypto-js'], function(Bitcoin, Curve25519, CryptoJS) {
    
    var BigInteger = Bitcoin.BigInteger;
    Severity: Minor
    Found in src/js/util/multiParty.js - About 3 hrs to fix

      Function sendMessage has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      multiParty.sendMessage = function(message) {
          //Convert from UTF8
          message = CryptoJS.enc.Utf8.parse(message);
          // Add 64 bytes of padding
          message.concat(getRawBytes(64));
      Severity: Minor
      Found in src/js/util/multiParty.js - About 1 hr to fix

        Avoid deeply nested control flow statements.
        Open

                            if (typeof(message['text'][recipients[r]]) === 'object') {
                                var noMessage = typeof(message['text'][recipients[r]]['message']) !== 'string';
                                var noIV = typeof(message['text'][recipients[r]]['iv']) !== 'string';
                                var noHMAC = typeof(message['text'][recipients[r]]['hmac']) !== 'string';
                                if (noMessage || noIV || noHMAC) {
        Severity: Major
        Found in src/js/util/multiParty.js - About 45 mins to fix

          Avoid too many return statements within this function.
          Open

                          return false;
          Severity: Major
          Found in src/js/util/multiParty.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return false;
            Severity: Major
            Found in src/js/util/multiParty.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                              return false;
              Severity: Major
              Found in src/js/util/multiParty.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                                return false;
                Severity: Major
                Found in src/js/util/multiParty.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              return plaintext.toString(CryptoJS.enc.Utf8);
                  Severity: Major
                  Found in src/js/util/multiParty.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                    return false;
                    Severity: Major
                    Found in src/js/util/multiParty.js - About 30 mins to fix

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

                          sharedSecrets[user] = {
                              'message': CryptoJS.lib.WordArray.create(sharedSecret.words.slice(0, 8)),
                              'hmac': CryptoJS.lib.WordArray.create(sharedSecret.words.slice(8, 16))
                          };
                      Severity: Major
                      Found in src/js/util/multiParty.js and 1 other location - About 1 hr to fix
                      src/js/util/encryption.js on lines 136..139

                      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

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

                      multiParty.messageTag = function(message) {
                          for (var i = 0; i !== 8; i++) {
                              message = CryptoJS.SHA512(message);
                          }
                          return message.toString(CryptoJS.enc.Base64);
                      Severity: Major
                      Found in src/js/util/multiParty.js and 1 other location - About 1 hr to fix
                      src/js/util/encryption.js on lines 80..85

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

                      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