client/app/pods/components/window-grid/component.js

Summary

Maintainability
F
3 days
Test Coverage

File component.js has 390 lines of code (exceeds 250 allowed). Consider refactoring.
Open

//
//   Copyright 2009-2014 Ilkka Oksanen <iao@iki.fi>
//
//   Licensed under the Apache License, Version 2.0 (the "License");
//   you may not use this file except in compliance with the License.
Severity: Minor
Found in client/app/pods/components/window-grid/component.js - About 5 hrs to fix

    Function _dragWindowEnd has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

      _dragWindowEnd(event) {
        const cursor = this.cursor;
    
        this.set('draggedWindow', false);
        this.movingWindow.$().removeClass('moving').css('z-index', '');
    Severity: Minor
    Found in client/app/pods/components/window-grid/component.js - About 4 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 _dragWindowEnd has 54 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      _dragWindowEnd(event) {
        const cursor = this.cursor;
    
        this.set('draggedWindow', false);
        this.movingWindow.$().removeClass('moving').css('z-index', '');
    Severity: Major
    Found in client/app/pods/components/window-grid/component.js - About 2 hrs to fix

      Function _drawCursor has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

        _drawCursor(cursor) {
          if (cursor.x === null) {
            $('#window-cursor').hide();
            return;
          }
      Severity: Minor
      Found in client/app/pods/components/window-grid/component.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 _markWindow has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        _markWindow(masWindow, x, y, cursor) {
          masWindow.cursor = 'none';
      
          const rowCount = this.dimensions.length;
          const columnCount = this.dimensions[y].length;
      Severity: Minor
      Found in client/app/pods/components/window-grid/component.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 _drawCursor has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        _drawCursor(cursor) {
          if (cursor.x === null) {
            $('#window-cursor').hide();
            return;
          }
      Severity: Minor
      Found in client/app/pods/components/window-grid/component.js - About 1 hr to fix

        Function _layoutWindows has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          _layoutWindows(animate) {
            const duration = animate ? 600 : 0;
            const windowComponents = this.windowComponents;
            const container = this._containerDimensions();
            const expandedWindow = windowComponents.findBy('expanded', true);
        Severity: Minor
        Found in client/app/pods/components/window-grid/component.js - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

              if (
                (y === 0 && cursor === 'top') ||
                (y === rows - 1 && cursor === 'bottom') ||
                (x === 0 && cursor === 'left') ||
                (x === columns - 1 && cursor === 'right')
          Severity: Critical
          Found in client/app/pods/components/window-grid/component.js - About 1 hr to fix

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

              _whichSection(windowDim, x, y) {
                // -----------------
                // |\      t      /|
                // | \           / |
                // |  -----------  |
            Severity: Minor
            Found in client/app/pods/components/window-grid/component.js - About 1 hr to fix

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

                _calculateCursorPosition(event) {
                  const outOfBoundsCursor = { x: null, y: null, section: null };
              
                  const x = event.clientX;
                  const y = event.clientY;
              Severity: Minor
              Found in client/app/pods/components/window-grid/component.js - About 1 hr to fix

                Consider simplifying this complex logical expression.
                Open

                        if (cursor.section === 'top' || cursor.section === 'bottom') {
                          deltaY = rowIndex > cursor.y || (rowIndex === cursor.y && cursor.section === 'top') ? 1 : 0;
                        } else {
                          deltaX =
                            rowIndex === cursor.y && (columnIndex > cursor.x || (columnIndex === cursor.x && cursor.section === 'left'))
                Severity: Major
                Found in client/app/pods/components/window-grid/component.js - About 1 hr to fix

                  Consider simplifying this complex logical expression.
                  Open

                      } else if (
                        cursor.y === y &&
                        ((section === 'right' && cursor.x === x) || (x < columnCount - 1 && cursor.x - 1 === x && section === 'left'))
                      ) {
                        masWindow.cursor = 'right';
                  Severity: Major
                  Found in client/app/pods/components/window-grid/component.js - About 40 mins to fix

                    Consider simplifying this complex logical expression.
                    Open

                        } else if (
                          cursor.y === y &&
                          ((section === 'left' && cursor.x === x) || (x > 0 && cursor.x === x - 1 && section === 'right'))
                        ) {
                          masWindow.cursor = 'left';
                    Severity: Major
                    Found in client/app/pods/components/window-grid/component.js - About 40 mins to fix

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

                        _whichSection(windowDim, x, y) {
                          // -----------------
                          // |\      t      /|
                          // | \           / |
                          // |  -----------  |
                      Severity: Minor
                      Found in client/app/pods/components/window-grid/component.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

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

                        _calculateSpaceForCursor(x, y, cursor) {
                          let width = Math.round(CURSORWIDTH / 2);
                          const rows = this.dimensions.length;
                          const columns = this.dimensions[y].length;
                      
                      
                      Severity: Minor
                      Found in client/app/pods/components/window-grid/component.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

                      Avoid too many return statements within this function.
                      Open

                            return 'left'; // l
                      Severity: Major
                      Found in client/app/pods/components/window-grid/component.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                            return null;
                        Severity: Major
                        Found in client/app/pods/components/window-grid/component.js - About 30 mins to fix

                          There are no issues that match your filters.

                          Category
                          Status