tuelsch/ts-linked-list

View on GitHub
src/LinkedList.ts

Summary

Maintainability
B
6 hrs
Test Coverage
A
100%

LinkedList has 32 functions (exceeds 20 allowed). Consider refactoring.
Invalid

export default class LinkedList<NodeData = any> {

  /**
   * The length of the list
   */
Severity: Minor
Found in src/LinkedList.ts - About 4 hrs to fix

    File LinkedList.ts has 319 lines of code (exceeds 250 allowed). Consider refactoring.
    Wontfix

    import LinkedListNode from './LinkedListNode';
    
    export { LinkedListNode };
    
    /** Type used for filter and find methods, returning a boolean */
    Severity: Minor
    Found in src/LinkedList.ts - About 3 hrs to fix

      Function sort has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Confirmed

        public sort(compare: (a: NodeData, b: NodeData) => boolean): LinkedList<NodeData> {
          if (this.head === null || this.tail === null) { return this; }
          if (this.length < 2) { return this; }
      
          const quicksort = (
      Severity: Minor
      Found in src/LinkedList.ts - About 2 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 sort has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Confirmed

        public sort(compare: (a: NodeData, b: NodeData) => boolean): LinkedList<NodeData> {
          if (this.head === null || this.tail === null) { return this; }
          if (this.length < 2) { return this; }
      
          const quicksort = (
      Severity: Minor
      Found in src/LinkedList.ts - About 1 hr to fix

        Function quicksort has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Confirmed

            const quicksort = (
              start: LinkedListNode<NodeData>,
              end: LinkedListNode<NodeData>,
            ) => {
              if (start === end) {
        Severity: Minor
        Found in src/LinkedList.ts - About 1 hr to fix

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

            public reduce(
              f: (
                accumulator: any,
                currentNode: NodeData,
                index: number,
          Severity: Minor
          Found in src/LinkedList.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 getNode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            public getNode(index: number): LinkedListNode<NodeData> | undefined {
              if (this.head === null || index < 0 || index >= this.length) { return undefined; }
              const asc = index < this.length / 2;
              const stopAt = asc ? index : this.length - index - 1;
              const nextNode = asc ? 'next' : 'prev';
          Severity: Minor
          Found in src/LinkedList.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