darkwallet/darkwallet

View on GitHub
src/js/backend/channels/catchan.js

Summary

Maintainability
D
2 days
Test Coverage

File catchan.js has 364 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

define(['bitcoinjs-lib', 'util/djbec', 'util/encryption', 'util/protocol', 'backend/channels/peer', 'backend/channels/utils', 'backend/port'],
function (Bitcoin, Curve25519, Encryption, Protocol, Peer, ChannelUtils, Port) {

Severity: Minor
Found in src/js/backend/channels/catchan.js - About 4 hrs to fix

    Function onReceiveBeacon has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      Channel.prototype.onReceiveBeacon = function(decoded) {
          var self = this;
          // Find out which contact this is
          var enqueue = false;
          var accepted = false;
    Severity: Minor
    Found in src/js/backend/channels/catchan.js - About 1 hr to fix

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

        function Channel(transport, name) {
            var self = this;
            var client = transport.getClient();
            this.callbacks = {};
            this.chatLog = [];
      Severity: Minor
      Found in src/js/backend/channels/catchan.js - About 1 hr to fix

        Avoid deeply nested control flow statements.
        Open

                                   if (contact.trust.trust >= 0) {
                                       self.acceptBeacon(decoded);
                                   }
        Severity: Major
        Found in src/js/backend/channels/catchan.js - About 45 mins to fix

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

                if (enqueue) {
                    var found = this.peerRequests.some(function(request){return request.body.pub===decoded.body.pub;});
                    if (!found) {
                        this.peerRequests.push(decoded);
                    }
          Severity: Major
          Found in src/js/backend/channels/catchan.js and 1 other location - About 2 hrs to fix
          src/js/backend/channels/catchan.js on lines 401..406

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

          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

            Channel.prototype.onPairMessage = function(data) {
                var found = this.peerRequests.some(function(request){return request.body.pub===data.body.pub;});
                if (!found) {
                    this.peerRequests.push(data);
                }
          Severity: Major
          Found in src/js/backend/channels/catchan.js and 1 other location - About 2 hrs to fix
          src/js/backend/channels/catchan.js on lines 511..516

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

          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

            Channel.prototype.post = function(data, callback) {
                var client = this.transport.getClient();
                if (client.connected) {
                    client.chan_post("b", this.channelHash, data, callback);
                }
          Severity: Major
          Found in src/js/backend/channels/catchan.js and 1 other location - About 1 hr to fix
          src/js/backend/channels/catchan.js on lines 212..217

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

          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

            Channel.prototype.channelUnsubscribe = function(callback, update_cb) {
                var client = this.transport.getClient();
                if (client.connected) {
                    client.chan_unsubscribe("b", this.channelHash, callback, update_cb);
                }
          Severity: Major
          Found in src/js/backend/channels/catchan.js and 1 other location - About 1 hr to fix
          src/js/backend/channels/catchan.js on lines 220..225

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

          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

            Channel.prototype.channelSubscribe = function(callback, update_cb) {
                var client = this.transport.getClient();
                client.chan_subscribe("b", this.channelHash, callback, update_cb);
            };
          Severity: Major
          Found in src/js/backend/channels/catchan.js and 1 other location - About 1 hr to fix
          src/js/backend/channels/btcchan.js on lines 47..50

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

          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

                this.transport.crypto.post(msg, function(err, encrypted) {
                    if (!err) {
                        self.post(encrypted, callback);
                    }
                });
          Severity: Minor
          Found in src/js/backend/channels/catchan.js and 1 other location - About 40 mins to fix
          src/js/backend/channels/catchan.js on lines 244..248

          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

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

                this.transport.crypto.post(msg, function(err, encrypted) {
                    if (!err) {
                        self.post(encrypted, callback);
                    }
                });
          Severity: Minor
          Found in src/js/backend/channels/catchan.js and 1 other location - About 40 mins to fix
          src/js/backend/channels/catchan.js on lines 266..270

          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

          There are no issues that match your filters.

          Category
          Status