ethereum/mist

View on GitHub
modules/menuItems.js

Summary

Maintainability
F
1 wk
Test Coverage

Function menuTempl has 589 lines of code (exceeds 25 allowed). Consider refactoring.
Open

let menuTempl = function(webviews) {
  const menu = [];
  webviews = webviews || [];

  // APP
Severity: Major
Found in modules/menuItems.js - About 2 days to fix

    File menuItems.js has 685 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    const {
      app,
      BrowserWindow,
      ipcMain: ipc,
      Menu,
    Severity: Major
    Found in modules/menuItems.js - About 1 day to fix

      Function menuTempl has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring.
      Open

      let menuTempl = function(webviews) {
        const menu = [];
        webviews = webviews || [];
      
        // APP
      Severity: Minor
      Found in modules/menuItems.js - About 1 day 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 click has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              click() {
                const focusedWindow = BrowserWindow.getFocusedWindow();
                const paths = dialog.showOpenDialog(focusedWindow, {
                  properties: ['openFile', 'openDirectory']
                });
      Severity: Minor
      Found in modules/menuItems.js - About 1 hr to fix

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

        const startMining = webviews => {
          ethereumNode
            .send('miner_start', [1])
            .then(ret => {
              log.info('miner_start', ret.result);
        Severity: Major
        Found in modules/menuItems.js and 1 other location - About 4 hrs to fix
        modules/menuItems.js on lines 102..116

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

        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

        const stopMining = webviews => {
          ethereumNode
            .send('miner_stop', [1])
            .then(ret => {
              log.info('miner_stop', ret.result);
        Severity: Major
        Found in modules/menuItems.js and 1 other location - About 4 hrs to fix
        modules/menuItems.js on lines 86..100

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

        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

              {
                label: i18n.t('mist.applicationMenu.develop.syncModeLight'),
                enabled: ethereumNode.isOwnNode && !ethereumNode.isDevNetwork,
                checked: store.getState().nodes.local.syncMode === 'light',
                type: 'checkbox',
        Severity: Major
        Found in modules/menuItems.js and 2 other locations - About 2 hrs to fix
        modules/menuItems.js on lines 621..629
        modules/menuItems.js on lines 639..647

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

        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

              {
                label: i18n.t('mist.applicationMenu.develop.syncModeNoSync'),
                enabled: ethereumNode.isOwnNode && !ethereumNode.isDevNetwork,
                checked: store.getState().nodes.local.syncMode === 'nosync',
                type: 'checkbox',
        Severity: Major
        Found in modules/menuItems.js and 2 other locations - About 2 hrs to fix
        modules/menuItems.js on lines 612..620
        modules/menuItems.js on lines 621..629

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

        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

              {
                label: i18n.t('mist.applicationMenu.develop.syncModeFast'),
                enabled: ethereumNode.isOwnNode && !ethereumNode.isDevNetwork,
                checked: store.getState().nodes.local.syncMode === 'fast',
                type: 'checkbox',
        Severity: Major
        Found in modules/menuItems.js and 2 other locations - About 2 hrs to fix
        modules/menuItems.js on lines 612..620
        modules/menuItems.js on lines 639..647

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

        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

              {
                label: 'Rinkeby - Test network',
                accelerator: 'CommandOrControl+Alt+3',
                checked: store.getState().nodes.network === 'rinkeby',
                enabled: store.getState().nodes.network !== 'private',
        Severity: Major
        Found in modules/menuItems.js and 1 other location - About 2 hrs to fix
        modules/menuItems.js on lines 575..584

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

        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

              {
                label: 'Ropsten - Test network',
                accelerator: 'CommandOrControl+Alt+2',
                checked: store.getState().nodes.network === 'ropsten',
                enabled: store.getState().nodes.network !== 'private',
        Severity: Major
        Found in modules/menuItems.js and 1 other location - About 2 hrs to fix
        modules/menuItems.js on lines 585..594

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

        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

              {
                label: i18n.t('mist.applicationMenu.develop.devToolsMistUI'),
                accelerator: 'Alt+CommandOrControl+I',
                click() {
                  curWindow = BrowserWindow.getFocusedWindow();
        Severity: Major
        Found in modules/menuItems.js and 1 other location - About 1 hr to fix
        modules/menuItems.js on lines 464..473

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

        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

              {
                label: i18n.t('mist.applicationMenu.develop.devToolsWalletUI'),
                accelerator: 'Alt+CommandOrControl+I',
                click() {
                  curWindow = BrowserWindow.getFocusedWindow();
        Severity: Major
        Found in modules/menuItems.js and 1 other location - About 1 hr to fix
        modules/menuItems.js on lines 431..440

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

        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 (ethereumNode.isEth) {
                        if (process.platform === 'win32') {
                          userPath = `${Settings.appDataPath}\\Web3\\keys`;
                        } else {
                          userPath += '/.web3/keys';
        Severity: Major
        Found in modules/menuItems.js and 1 other location - About 1 hr to fix
        modules/ipcCommunicator.js on lines 155..175

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

        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

              {
                label: i18n.t('mist.applicationMenu.app.about', {
                  app: Settings.appName
                }),
                click() {
        Severity: Minor
        Found in modules/menuItems.js and 1 other location - About 45 mins to fix
        modules/menuItems.js on lines 129..136

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

        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

              {
                label: i18n.t('mist.applicationMenu.app.about', {
                  app: Settings.appName
                }),
                click() {
        Severity: Minor
        Found in modules/menuItems.js and 1 other location - About 45 mins to fix
        modules/menuItems.js on lines 738..745

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

        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/menuItems.js by eslint

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

        There are no issues that match your filters.

        Category
        Status