Microsoft/fast-dna

View on GitHub
packages/web-components/fast-element/src/observation/arrays.ts

Summary

Maintainability
F
4 days
Test Coverage

File arrays.ts has 611 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { emptyArray } from "../platform.js";
import { Notifier, Subscriber, SubscriberSet } from "./notifier.js";
import { Observable } from "./observable.js";
import { Updates } from "./update-queue.js";

Severity: Major
Found in packages/web-components/fast-element/src/observation/arrays.ts - About 1 day to fix

    Function calc has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

    function calc(
        current: unknown[],
        currentStart: number,
        currentEnd: number,
        old: unknown[],
    Severity: Minor
    Found in packages/web-components/fast-element/src/observation/arrays.ts - 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 spliceOperationsFromEditDistances has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    function spliceOperationsFromEditDistances(distances: number[][]): number[] {
        let i = distances.length - 1;
        let j = distances[0].length - 1;
        let current = distances[i][j];
        const edits: number[] = [];
    Severity: Minor
    Found in packages/web-components/fast-element/src/observation/arrays.ts - 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 merge has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    function merge(splice: Splice, splices: Splice[]): void {
        let inserted = false;
        let insertionOffset = 0;
    
        for (let i = 0; i < splices.length; i++) {
    Severity: Minor
    Found in packages/web-components/fast-element/src/observation/arrays.ts - 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 calc has 71 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function calc(
        current: unknown[],
        currentStart: number,
        currentEnd: number,
        old: unknown[],
    Severity: Major
    Found in packages/web-components/fast-element/src/observation/arrays.ts - About 2 hrs to fix

      Function merge has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function merge(splice: Splice, splices: Splice[]): void {
          let inserted = false;
          let insertionOffset = 0;
      
          for (let i = 0; i < splices.length; i++) {
      Severity: Major
      Found in packages/web-components/fast-element/src/observation/arrays.ts - About 2 hrs to fix

        Function spliceOperationsFromEditDistances has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function spliceOperationsFromEditDistances(distances: number[][]): number[] {
            let i = distances.length - 1;
            let j = distances[0].length - 1;
            let current = distances[i][j];
            const edits: number[] = [];
        Severity: Minor
        Found in packages/web-components/fast-element/src/observation/arrays.ts - About 1 hr to fix

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

          function calcEditDistances(
              current: any[],
              currentStart: number,
              currentEnd: number,
              old: any[],
          Severity: Minor
          Found in packages/web-components/fast-element/src/observation/arrays.ts - 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 enable has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              enable(): void {
                  if (enabled) {
                      return;
                  }
          
          
          Severity: Minor
          Found in packages/web-components/fast-element/src/observation/arrays.ts - About 1 hr to fix

            Function calc has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                current: unknown[],
                currentStart: number,
                currentEnd: number,
                old: unknown[],
                oldStart: number,
            Severity: Minor
            Found in packages/web-components/fast-element/src/observation/arrays.ts - About 45 mins to fix

              Function calcEditDistances has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  current: any[],
                  currentStart: number,
                  currentEnd: number,
                  old: any[],
                  oldStart: number,
              Severity: Minor
              Found in packages/web-components/fast-element/src/observation/arrays.ts - About 45 mins to fix

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

                function project(array: unknown[], changes: Splice[]): Splice[] {
                    let splices: Splice[] = [];
                    const initialSplices: Splice[] = [];
                
                    for (let i = 0, ii = changes.length; i < ii; i++) {
                Severity: Minor
                Found in packages/web-components/fast-element/src/observation/arrays.ts - 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 intersect has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                function intersect(start1: number, end1: number, start2: number, end2: number): number {
                    // Disjoint
                    if (end1 < start2 || end2 < start1) {
                        return -1;
                    }
                Severity: Minor
                Found in packages/web-components/fast-element/src/observation/arrays.ts - 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 end2 - start1; // Overlap
                Severity: Major
                Found in packages/web-components/fast-element/src/observation/arrays.ts - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      return end1 - start1; // Contained
                  Severity: Major
                  Found in packages/web-components/fast-element/src/observation/arrays.ts - About 30 mins to fix

                    Similar blocks of code found in 5 locations. Consider refactoring.
                    Open

                        reverse(
                            array: any[],
                            observer: ArrayObserver,
                            reverse: typeof Array.prototype.reverse,
                            args: any[]
                    Severity: Major
                    Found in packages/web-components/fast-element/src/observation/arrays.ts and 4 other locations - About 40 mins to fix
                    packages/web-components/fast-element/src/observation/arrays.ts on lines 113..118
                    packages/web-components/fast-element/src/observation/arrays.ts on lines 127..132
                    packages/web-components/fast-element/src/observation/arrays.ts on lines 155..160
                    packages/web-components/fast-element/src/observation/arrays.ts on lines 183..188

                    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

                    Similar blocks of code found in 5 locations. Consider refactoring.
                    Open

                        shift(
                            array: any[],
                            observer: ArrayObserver,
                            shift: typeof Array.prototype.shift,
                            args: any[]
                    Severity: Major
                    Found in packages/web-components/fast-element/src/observation/arrays.ts and 4 other locations - About 40 mins to fix
                    packages/web-components/fast-element/src/observation/arrays.ts on lines 113..118
                    packages/web-components/fast-element/src/observation/arrays.ts on lines 127..132
                    packages/web-components/fast-element/src/observation/arrays.ts on lines 141..146
                    packages/web-components/fast-element/src/observation/arrays.ts on lines 183..188

                    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

                    Similar blocks of code found in 5 locations. Consider refactoring.
                    Open

                        push(
                            array: any[],
                            observer: ArrayObserver,
                            push: typeof Array.prototype.push,
                            args: any[]
                    Severity: Major
                    Found in packages/web-components/fast-element/src/observation/arrays.ts and 4 other locations - About 40 mins to fix
                    packages/web-components/fast-element/src/observation/arrays.ts on lines 113..118
                    packages/web-components/fast-element/src/observation/arrays.ts on lines 141..146
                    packages/web-components/fast-element/src/observation/arrays.ts on lines 155..160
                    packages/web-components/fast-element/src/observation/arrays.ts on lines 183..188

                    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

                    Similar blocks of code found in 5 locations. Consider refactoring.
                    Open

                        pop(
                            array: any[],
                            observer: ArrayObserver,
                            pop: typeof Array.prototype.pop,
                            args: any[]
                    Severity: Major
                    Found in packages/web-components/fast-element/src/observation/arrays.ts and 4 other locations - About 40 mins to fix
                    packages/web-components/fast-element/src/observation/arrays.ts on lines 127..132
                    packages/web-components/fast-element/src/observation/arrays.ts on lines 141..146
                    packages/web-components/fast-element/src/observation/arrays.ts on lines 155..160
                    packages/web-components/fast-element/src/observation/arrays.ts on lines 183..188

                    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

                    Similar blocks of code found in 5 locations. Consider refactoring.
                    Open

                        splice(
                            array: any[],
                            observer: ArrayObserver,
                            splice: typeof Array.prototype.splice,
                            args: any[]
                    Severity: Major
                    Found in packages/web-components/fast-element/src/observation/arrays.ts and 4 other locations - About 40 mins to fix
                    packages/web-components/fast-element/src/observation/arrays.ts on lines 113..118
                    packages/web-components/fast-element/src/observation/arrays.ts on lines 127..132
                    packages/web-components/fast-element/src/observation/arrays.ts on lines 141..146
                    packages/web-components/fast-element/src/observation/arrays.ts on lines 155..160

                    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