cozy-labs/cozy-desktop

View on GitHub
gui/js/tray.window.js

Summary

Maintainability
D
2 days
Test Coverage

Function ipcEvents has 119 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  ipcEvents() {
    return {
      confirm: async (
        event /*: ElectronEvent */,
        {
Severity: Major
Found in gui/js/tray.window.js - About 4 hrs to fix

    File tray.window.js has 305 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* @flow */
    
    const electron = require('electron')
    const { dialog, shell } = electron
    const path = require('path')
    Severity: Minor
    Found in gui/js/tray.window.js - About 3 hrs to fix

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

        ipcEvents() {
          return {
            confirm: async (
              event /*: ElectronEvent */,
              {
      Severity: Minor
      Found in gui/js/tray.window.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 popoverBounds has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const popoverBounds = (
        wantedWidth,
        wantedHeight,
        trayposition,
        workArea,
      Severity: Minor
      Found in gui/js/tray.window.js - About 1 hr to fix

        Function popoverBounds has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        const popoverBounds = (
          wantedWidth,
          wantedHeight,
          trayposition,
          workArea,
        Severity: Minor
        Found in gui/js/tray.window.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 placeWithTray has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          placeWithTray(
            wantedWidth /*: number */,
            wantedHeight /*: number */,
            trayposition /*: Bounds */
          ) {
        Severity: Minor
        Found in gui/js/tray.window.js - About 1 hr to fix

          Function openPath has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            async openPath(pathToOpen /*: string */, showInWeb /*: boolean */ = false) {
              const { desktop } = this
          
              pathToOpen = path.join(desktop.config.syncPath, pathToOpen)
          
          
          Severity: Minor
          Found in gui/js/tray.window.js - About 55 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

            } else if (workArea.height < display.height && workArea.y === 0) {
              // bottom bar -> place window on bottom right
              newBounds.x = workArea.x + workArea.width - actualWidth
              newBounds.y = workArea.y + workArea.height - actualHeight
            } else {
          Severity: Major
          Found in gui/js/tray.window.js and 1 other location - About 1 hr to fix
          gui/js/tray.window.js on lines 78..94

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

          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 (workArea.width < display.width && workArea.x === 0) {
              // right bar -> place window on bottom right
              newBounds.x = workArea.x + workArea.width - actualWidth
              newBounds.y = workArea.y + workArea.height - actualHeight
            } else if (workArea.width < display.width) {
          Severity: Major
          Found in gui/js/tray.window.js and 1 other location - About 1 hr to fix
          gui/js/tray.window.js on lines 86..94

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

          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

            hide() {
              if (this.win) {
                this.log.debug('hide')
                this.win.hide()
              }
          Severity: Minor
          Found in gui/js/tray.window.js and 1 other location - About 40 mins to fix
          gui/js/window_manager.js on lines 125..130

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

          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

          There are no issues that match your filters.

          Category
          Status