Microsoft/fast-dna

View on GitHub

Showing 494 of 3,420 total issues

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

    public addBehavior(behavior: HostBehavior<TElement>) {
        const targetBehaviors = this.behaviors ?? (this.behaviors = new Map());
        const count = targetBehaviors.get(behavior) ?? 0;

        if (count === 0) {

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 tunnel has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private async tunnel(phase: NavigationPhase) {
        const route = this.childRoute;
        const contributor = this.childCommandContributor;

        if (route && contributor) {
Severity: Minor
Found in packages/web-components/fast-router/src/router.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

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

    public static create<TSource = any, TParent = any>(
        strings: string[],
        values: TemplateValue<TSource, TParent>[],
        policy?: DOMPolicy
    ): ViewTemplate<TSource, TParent> {
Severity: Minor
Found in packages/web-components/fast-element/src/templating/template.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

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

    public appendTo(state: AnyState<T>): StaticState<T> {
        const {
            value,
            value: { length },
        } = this;
Severity: Minor
Found in packages/web-components/fast-router/src/recognizer.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

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

    private addTargetDescriptor(
        parentId: string,
        targetId: string,
        targetIndex: number
    ): void {
Severity: Minor
Found in packages/web-components/fast-element/src/templating/compiler.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

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

export function labToXYZ(lab: ColorLAB): ColorXYZ {
    const fy: number = (lab.l + 16) / 116;
    const fx: number = fy + lab.a / 500;
    const fz: number = fy - lab.b / 200;

Severity: Minor
Found in packages/utilities/fast-colors/src/color-converters.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

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

    public insertBefore(node: Node): void {
        if (this.fragment.hasChildNodes()) {
            node.parentNode!.insertBefore(this.fragment, node);
        } else {
            const end = this.lastChild!;
Severity: Minor
Found in packages/web-components/fast-element/src/templating/view.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

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

    public disconnect() {
        if (this.parent === null) {
            if (this.navigationQueue !== null) {
                this.navigationQueue.disconnect();
                this.navigationQueue = null;
Severity: Minor
Found in packages/web-components/fast-router/src/router.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

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

export function hsvToRGB(hsv: ColorHSV, alpha: number = 1): ColorRGBA64 {
    const c: number = hsv.s * hsv.v;
    const x: number = c * (1 - Math.abs(((hsv.h / 60) % 2) - 1));
    const m: number = hsv.v - c;

Severity: Minor
Found in packages/utilities/fast-colors/src/color-converters.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

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

export function insertIntoSortedList(
    list: PixelBox[],
    newItem: PixelBox,
    sortPriority: (box: PixelBox) => number
): void {
Severity: Minor
Found in packages/utilities/fast-colors/src/pixel-box.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

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

export function hslToRGB(hsl: ColorHSL, alpha: number = 1): ColorRGBA64 {
    const c: number = (1 - Math.abs(2 * hsl.l - 1)) * hsl.s;
    const x: number = c * (1 - Math.abs(((hsl.h / 60) % 2) - 1));
    const m: number = hsl.l - c / 2;

Severity: Minor
Found in packages/utilities/fast-colors/src/color-converters.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

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

    public static normalize(
        styles: ComposableStyles | ComposableStyles[] | undefined
    ): ElementStyles | undefined {
        return styles === void 0
            ? void 0
Severity: Minor
Found in packages/web-components/fast-element/src/styles/element-styles.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

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

    update(increment: boolean) {
        if (increment) {
            this.value = this.value === 10 ? 0 : this.value + 1;
        } else {
            this.value = this.value < 2 ? 2 : 0;
Severity: Minor
Found in packages/utilities/fast-benchmarks/benchmarks/fast-element/when/index.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

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

    update(increment: boolean) {
        if (increment) {
            this.value = this.value === 10 ? 0 : this.value + 1;
        } else {
            this.value = this.value < 2 ? 2 : 0;

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

Severity
Category
Status
Source
Language