opf/openproject

View on GitHub
frontend/src/app/shared/helpers/drag-and-drop/reorder-delta-builder.ts

Summary

Maintainability
C
1 day
Test Coverage

File reorder-delta-builder.ts has 259 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { debugLog } from 'core-app/shared/helpers/debug_output';
import { QueryOrder } from 'core-app/core/apiv3/endpoints/queries/apiv3-query-order';

// min allowed position
export const MIN_ORDER = -2147483647;

    Function buildInsertPosition has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function buildInsertPosition(
      order:string[],
      positions:QueryOrder,
      wpId:string,
      index:number,

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

      function isAscendingOrder(
        order:string[],
        positions:QueryOrder,
        index:number,
      ):boolean {
      Severity: Minor
      Found in frontend/src/app/shared/helpers/drag-and-drop/reorder-delta-builder.ts - 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 positionSwap has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        delta:QueryOrder,
        order:string[],
        positions:QueryOrder,
        index:number,
        fromIndex:number|null,
      Severity: Minor
      Found in frontend/src/app/shared/helpers/drag-and-drop/reorder-delta-builder.ts - About 45 mins to fix

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

        function buildInsertPosition(
          order:string[],
          positions:QueryOrder,
          wpId:string,
          index:number,
        Severity: Minor
        Found in frontend/src/app/shared/helpers/drag-and-drop/reorder-delta-builder.ts - 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 buildDelta has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          order:string[],
          positions:QueryOrder,
          wpId:string,
          index:number,
          fromIndex:number|null,
        Severity: Minor
        Found in frontend/src/app/shared/helpers/drag-and-drop/reorder-delta-builder.ts - About 35 mins to fix

          Function insertAsFirst has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            delta:QueryOrder,
            order:string[],
            positions:QueryOrder,
            index:number,
            wpId:string,
          Severity: Minor
          Found in frontend/src/app/shared/helpers/drag-and-drop/reorder-delta-builder.ts - About 35 mins to fix

            Function buildInsertPosition has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              order:string[],
              positions:QueryOrder,
              wpId:string,
              index:number,
              fromIndex:number|null,
            Severity: Minor
            Found in frontend/src/app/shared/helpers/drag-and-drop/reorder-delta-builder.ts - About 35 mins to fix

              Avoid too many return statements within this function.
              Open

                return {
                  ...rebuiltDelta,
                  [wpId]: predecessorPosition + distance,
                };
              Severity: Major
              Found in frontend/src/app/shared/helpers/drag-and-drop/reorder-delta-builder.ts - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                    return {
                      ...rebuiltDelta,
                      [wpId]: predecessorPosition + (ORDER_DISTANCE / 2),
                    };
                Severity: Major
                Found in frontend/src/app/shared/helpers/drag-and-drop/reorder-delta-builder.ts - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      return reorderedInsert(rebuiltDelta, order, positions);
                  Severity: Major
                  Found in frontend/src/app/shared/helpers/drag-and-drop/reorder-delta-builder.ts - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                        return reorderedInsert(rebuiltDelta, order, positions);
                    Severity: Major
                    Found in frontend/src/app/shared/helpers/drag-and-drop/reorder-delta-builder.ts - About 30 mins to fix

                      Function redistribute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function redistribute(
                        delta:QueryOrder,
                        order:string[],
                        minIndex:number,
                        maxIndex:number,
                      Severity: Minor
                      Found in frontend/src/app/shared/helpers/drag-and-drop/reorder-delta-builder.ts - About 25 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