ethereum/mist

View on GitHub
modules/windows.js

Summary

Maintainability
F
5 days
Test Coverage

File windows.js has 542 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const { app, BrowserWindow, ipcMain: ipc } = require('electron');
const Settings = require('./settings');
const log = require('./utils/logger').create('Windows');
const EventEmitter = require('events').EventEmitter;
import {
Severity: Major
Found in modules/windows.js - About 1 day to fix

    Function getDefaultOptionsForType has 153 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      getDefaultOptionsForType(type) {
        const mainWebPreferences = {
          mist: {
            nodeIntegration: true /* necessary for webviews;
                        require will be removed through preloader */,
    Severity: Major
    Found in modules/windows.js - About 6 hrs to fix

      Function constructor has 74 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        constructor(mgr, type, opts) {
          super();
      
          opts = opts || {};
      
      
      Severity: Major
      Found in modules/windows.js - About 2 hrs to fix

        Function createPopup has 65 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          createPopup(type, options, callback) {
            const defaultPopupOpts = {
              url: `${global.interfacePopupsUrl}#${type}`,
              show: true,
              ownerId: null,
        Severity: Major
        Found in modules/windows.js - About 2 hrs to fix

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

            reuse(type, options, callback) {
              this.isAvailable = false;
              this.actingType = type;
              if (callback) {
                this.callback = callback;
          Severity: Minor
          Found in modules/windows.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 constructor has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            constructor(mgr) {
              super();
          
              this._mgr = mgr;
              this._log = log.create('generic');
          Severity: Minor
          Found in modules/windows.js - About 1 hr to fix

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

              create(type, opts, callback) {
                store.dispatch({
                  type: '[MAIN]:WINDOW:CREATE_START',
                  payload: { type }
                });
            Severity: Minor
            Found in modules/windows.js - About 1 hr to fix

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

                reuse(type, options, callback) {
                  this.isAvailable = false;
                  this.actingType = type;
                  if (callback) {
                    this.callback = callback;
              Severity: Minor
              Found in modules/windows.js - About 1 hr to fix

                Function createPopup has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                  createPopup(type, options, callback) {
                    const defaultPopupOpts = {
                      url: `${global.interfacePopupsUrl}#${type}`,
                      show: true,
                      ownerId: null,
                Severity: Minor
                Found in modules/windows.js - About 45 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

                    if (options.sendData) {
                      if (_.isString(options.sendData)) {
                        this.send(options.sendData);
                      } else if (_.isObject(options.sendData)) {
                        for (const key in options.sendData) {
                Severity: Major
                Found in modules/windows.js and 1 other location - About 4 hrs to fix
                modules/windows.js on lines 173..183

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

                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 (opts.sendData) {
                        if (_.isString(opts.sendData)) {
                          this.send(opts.sendData);
                        } else if (_.isObject(opts.sendData)) {
                          for (const key in opts.sendData) {
                Severity: Major
                Found in modules/windows.js and 1 other location - About 4 hrs to fix
                modules/windows.js on lines 102..112

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

                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

                  getById(id) {
                    log.trace('Get by id', id);
                
                    return _.find(this._windows, w => {
                      return w.id === id;
                Severity: Major
                Found in modules/windows.js and 1 other location - About 1 hr to fix
                modules/windows.js on lines 612..618

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

                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

                  getByType(type) {
                    log.trace('Get by type', type);
                
                    return _.find(this._windows, w => {
                      return w.type === type;
                Severity: Major
                Found in modules/windows.js and 1 other location - About 1 hr to fix
                modules/windows.js on lines 620..626

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

                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 3 locations. Consider refactoring.
                Open

                    this.window.once('closed', () => {
                      this._log.debug('Closed');
                      this.emit('closed');
                    });
                Severity: Major
                Found in modules/windows.js and 2 other locations - About 50 mins to fix
                modules/sockets/web3Ipc.js on lines 38..42
                modules/sockets/web3Ipc.js on lines 50..54

                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

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

                      case 'clientUpdateAvailable':
                        return {
                          useWeb3: false,
                          electronOptions: {
                            width: 600,
                Severity: Minor
                Found in modules/windows.js and 1 other location - About 40 mins to fix
                modules/windows.js on lines 486..496

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

                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 'updateAvailable':
                        return {
                          useWeb3: false,
                          electronOptions: {
                            width: 580,
                Severity: Minor
                Found in modules/windows.js and 1 other location - About 40 mins to fix
                modules/windows.js on lines 497..507

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

                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 {
                Severity: Minor
                Found in modules/windows.js by eslint

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

                There are no issues that match your filters.

                Category
                Status