ethereum/mist

View on GitHub

Showing 443 of 443 total issues

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

Function renderDetails has 101 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  renderDetails() {
    const { tx, etherPriceUSD } = this.props;

    if (!this.state.showDetails) {
      return (
Severity: Major
Found in interface/components/TxHistory/TxRow.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 _sendRequest has 100 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        _sendRequest(isSync, event, payload, retry = false) {
          const ownerId = event.sender.id;
      
          log.trace('sendRequest', isSync ? 'sync' : 'async', ownerId, payload);
      
      
      Severity: Major
      Found in modules/ipc/ipcProviderBackend.js - About 4 hrs to fix

        Function confirmTx has 96 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function confirmTx(data) {
          return async (dispatch, getState) => {
            dispatch({ type: '[CLIENT]:CONFIRM_TX:START', payload: { data } });
        
            // reject if sending to itself
        Severity: Major
        Found in interface/actions.js - About 3 hrs to fix

          Function _getOrCreateConnection has 94 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            _getOrCreateConnection(event) {
              const owner = event.sender;
              const ownerId = owner.id;
          
              let socket;
          Severity: Major
          Found in modules/ipc/ipcProviderBackend.js - About 3 hrs to fix

            Function nodes has 93 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const nodes = (state = initialState, action) => {
              switch (action.type) {
                case '[MAIN]:LOCAL_NODE:SYNC_UPDATE':
                  return Object.assign({}, state, {
                    local: Object.assign({}, state.local, {
            Severity: Major
            Found in modules/core/nodes/reducer.js - About 3 hrs to fix

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

                  if (!this._events[evt]) (this._events[evt] = listener), this._eventsCount++;
                  else if (!this._events[evt].fn) this._events[evt].push(listener);
                  else this._events[evt] = [this._events[evt], listener];
              Severity: Major
              Found in modules/preloader/injected/EventEmitter3.js and 1 other location - About 3 hrs to fix
              modules/preloader/injected/EventEmitter3.js on lines 197..199

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

              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 (!this._events[evt]) (this._events[evt] = listener), this._eventsCount++;
                  else if (!this._events[evt].fn) this._events[evt].push(listener);
                  else this._events[evt] = [this._events[evt], listener];
              Severity: Major
              Found in modules/preloader/injected/EventEmitter3.js and 1 other location - About 3 hrs to fix
              modules/preloader/injected/EventEmitter3.js on lines 217..219

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

              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

                const filterId = str => {
                  const filteredStr = String(str);
                  let newStr = '';
                  if (filteredStr) {
                    for (let i = 0; i < filteredStr.length; i += 1) {
              Severity: Major
              Found in modules/preloader/include/mistAPI.js and 1 other location - About 3 hrs to fix
              modules/preloader/injected/mistAPI.js on lines 34..45

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

              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

                const filterId = function(str) {
                  const filteredStr = String(str);
                  let newStr = '';
                  if (filteredStr) {
                    for (let i = 0; i < filteredStr.length; i += 1) {
              Severity: Major
              Found in modules/preloader/injected/mistAPI.js and 1 other location - About 3 hrs to fix
              modules/preloader/include/mistAPI.js on lines 24..35

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

              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

              Function message has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
              Open

              window.addEventListener('message', function message(event) {
                let data;
                try {
                  data = JSON.parse(event.data);
                } catch (e) {
              Severity: Minor
              Found in modules/preloader/browser.js - About 3 hrs 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

              File main.js has 295 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              global._ = require('./modules/utils/underscore');
              
              const { app, dialog, ipcMain, shell, protocol } = require('electron');
              const windowStateKeeper = require('electron-window-state');
              const timesync = require('os-timesync');
              Severity: Minor
              Found in main.js - About 3 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

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

                          if (error.message.includes('Unable to connect to socket: timeout')) {
                            displayNotification('connectionTimeout', 5);
                          } else if (
                            error.message.includes('Insufficient funds for gas * price + value')
                          ) {
                  Severity: Major
                  Found in interface/actions.js and 1 other location - About 2 hrs to fix
                  interface/actions.js on lines 234..245

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

                  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

                          } else if (
                            error.message.includes('could not decrypt key with given passphrase')
                          ) {
                            displayNotification('wrongPassword', 3);
                          } else if (error.message.includes('multiple keys match address')) {
                  Severity: Major
                  Found in interface/actions.js and 1 other location - About 2 hrs to fix
                  interface/actions.js on lines 262..273

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

                  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

                  Function newTx has 73 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const newTx = (state = initialState, action) => {
                    switch (action.type) {
                      case '[CLIENT]:NEW_TX:START':
                        return Object.assign({}, initialState, action.payload);
                      case '[CLIENT]:DETERMINE_IF_CONTRACT:SUCCESS':
                  Severity: Major
                  Found in modules/core/newTx/reducer.js - About 2 hrs to fix

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

                        if (network.toLowerCase() === 'main' && etherPriceUSD) {
                          const standardFee = etherFee.times(etherPriceUSD);
                          const formattedFee = this.formatter.format(standardFee);
                          return `${formattedFee} USD (${etherFee} ETH)`;
                        } else {
                    Severity: Major
                    Found in interface/components/SendTx/FeeSelector.js and 1 other location - About 2 hrs to fix
                    interface/components/SendTx/FeeSelector.js on lines 64..70

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

                    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

                          if (network.toLowerCase() === 'main' && etherPriceUSD) {
                            const standardFee = etherFee.times(etherPriceUSD);
                            const formattedFee = this.formatter.format(standardFee);
                            return `${formattedFee} USD (${etherFee} ETH)`;
                          } else {
                    Severity: Major
                    Found in interface/components/SendTx/FeeSelector.js and 1 other location - About 2 hrs to fix
                    interface/components/SendTx/FeeSelector.js on lines 80..86

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

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language