cozy-labs/cozy-desktop

View on GitHub
gui/main.js

Summary

Maintainability
D
2 days
Test Coverage

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

'use strict'

require('../core/globals')

// Initialize `remote` module so that renderer processes can use it.
Severity: Major
Found in gui/main.js - About 1 day to fix

    Function updateState has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    const updateState = async ({ newState, data }) => {
      const { status, filename, userAlerts, errors } = data || {}
    
      if (newState === 'sync-state') {
        if (status === 'uptodate') tray.setStatus('online')
    Severity: Minor
    Found in gui/main.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

    Function setupDesktop has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    const setupDesktop = async () => {
      try {
        // TODO: allow setting desktop up without running migrations (when opening
        // a cozy-note)?
        await desktop.setup()
    Severity: Minor
    Found in gui/main.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 showWindow has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    const showWindow = async bounds => {
      if (
        notificationsState.revokedAlertShown ||
        notificationsState.syncDirUnlinkedShown
      )
    Severity: Minor
    Found in gui/main.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 setupDesktop has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const setupDesktop = async () => {
      try {
        // TODO: allow setting desktop up without running migrations (when opening
        // a cozy-note)?
        await desktop.setup()
    Severity: Minor
    Found in gui/main.js - About 1 hr to fix

      Function showRevokedCozyError has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const showRevokedCozyError = async () => {
        // prevent the alert from appearing twice
        if (notificationsState.revokedAlertShown) return
        notificationsState.revokedAlertShown = true
      
      
      Severity: Minor
      Found in gui/main.js - About 1 hr to fix

        Function startSync has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const startSync = async () => {
          enqueueStateUpdate('syncing')
          desktop.events.on('sync-state', state => {
            enqueueStateUpdate('sync-state', state)
          })
        Severity: Minor
        Found in gui/main.js - About 1 hr to fix

          Function showWindow has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const showWindow = async bounds => {
            if (
              notificationsState.revokedAlertShown ||
              notificationsState.syncDirUnlinkedShown
            )
          Severity: Minor
          Found in gui/main.js - About 1 hr to fix

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

            const sendErrorToMainWindow = async ({ msg, code }) => {
              if (code === COZY_CLIENT_REVOKED_CODE) {
                return showRevokedCozyError()
              } else if (msg === SYNC_DIR_UNLINKED_MESSAGE) {
                if (notificationsState.syncDirUnlinkedShown) return
            Severity: Minor
            Found in gui/main.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

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

            const showRevokedCozyError = async () => {
              // prevent the alert from appearing twice
              if (notificationsState.revokedAlertShown) return
              notificationsState.revokedAlertShown = true
            
            
            Severity: Minor
            Found in gui/main.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

            There are no issues that match your filters.

            Category
            Status