ethereum/mist

View on GitHub
modules/ethereumNode.js

Summary

Maintainability
F
3 days
Test Coverage

File ethereumNode.js has 549 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const _ = require('./utils/underscore.js');
const fs = require('fs');
const Q = require('bluebird');
const spawn = require('child_process').spawn;
const { dialog } = require('electron');
Severity: Major
Found in modules/ethereumNode.js - About 1 day to fix

    Function __startProcess has 116 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      __startProcess(nodeType, network, binPath, _syncMode) {
        let syncMode = _syncMode;
        if (nodeType === 'geth' && !syncMode) {
          syncMode = DEFAULT_SYNCMODE;
        }
    Severity: Major
    Found in modules/ethereumNode.js - About 4 hrs to fix

      EthereumNode has 32 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class EthereumNode extends EventEmitter {
        constructor() {
          super();
      
          if (!instance) {
      Severity: Minor
      Found in modules/ethereumNode.js - About 4 hrs to fix

        Function _start has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          _start(nodeType, network, syncMode) {
            ethereumNodeLog.info(`Start node: ${nodeType} ${network} ${syncMode}`);
        
            if (network === 'test' || network === 'ropsten') {
              ethereumNodeLog.debug('Node will connect to the test network');
        Severity: Minor
        Found in modules/ethereumNode.js - About 1 hr to fix

          Function _logNodeData has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

            _logNodeData(data) {
              const cleanData = data.toString().replace(/[\r\n]+/, '');
              const nodeType = (this.type || 'node').toUpperCase();
          
              ethereumNodeLog.trace(`${nodeType}: ${cleanData}`);
          Severity: Minor
          Found in modules/ethereumNode.js - About 1 hr 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 stop has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            stop() {
              if (!this._stopPromise) {
                return new Q(resolve => {
                  if (!this._node) {
                    return resolve();
          Severity: Minor
          Found in modules/ethereumNode.js - About 1 hr to fix

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

              _loadDefaults() {
                ethereumNodeLog.trace('Load defaults');
            
                this.defaultNodeType =
                  Settings.nodeType || Settings.loadUserData('node') || DEFAULT_NODE_TYPE;
            Severity: Minor
            Found in modules/ethereumNode.js - About 1 hr to fix

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

                init() {
                  return this._socket
                    .connect(Settings.rpcConnectConfig)
                    .then(() => {
                      this.isExternalNode = true;
              Severity: Minor
              Found in modules/ethereumNode.js - About 1 hr to fix

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

                  __startNode(nodeType, network, syncMode) {
                    this.state = STATES.STARTING;
                
                    this._network = network;
                    this._type = nodeType;
                Severity: Minor
                Found in modules/ethereumNode.js - About 1 hr to fix

                  Function _checkSync has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                    _checkSync() {
                      // Reset
                      if (this.syncInterval) {
                        clearInterval(this.syncInterval);
                      }
                  Severity: Minor
                  Found in modules/ethereumNode.js - About 35 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

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

                          case 'rinkeby':
                            args = [
                              '--rinkeby',
                              '--cache',
                              process.arch === 'x64' ? '1024' : '512',
                  Severity: Major
                  Found in modules/ethereumNode.js and 1 other location - About 2 hrs to fix
                  modules/ethereumNode.js on lines 450..463

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

                  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 'test':
                            args = [
                              '--testnet',
                              '--cache',
                              process.arch === 'x64' ? '1024' : '512',
                  Severity: Major
                  Found in modules/ethereumNode.js and 1 other location - About 2 hrs to fix
                  modules/ethereumNode.js on lines 466..479

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

                  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

                  Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
                  Open

                  import Settings from './settings';
                  Severity: Minor
                  Found in modules/ethereumNode.js by eslint

                  For more information visit Source: http://eslint.org/docs/rules/

                  There are no issues that match your filters.

                  Category
                  Status