thi-ng/umbrella

View on GitHub
packages/hdom/src/dom.ts

Summary

Maintainability
B
6 hrs
Test Coverage

File dom.ts has 283 lines of code (exceeds 250 allowed). Consider refactoring.
Wontfix

import { implementsFunction } from "@thi.ng/checks/implements-function";
import { isArray } from "@thi.ng/checks/is-array";
import { isNotStringAndIterable } from "@thi.ng/checks/is-not-string-iterable";
import { isString } from "@thi.ng/checks/is-string";
import { ATTRIB_JOIN_DELIMS, SVG_TAGS } from "@thi.ng/hiccup/api";
Severity: Minor
Found in packages/hdom/src/dom.ts - About 2 hrs to fix

Function setAttrib has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

export const setAttrib = (el: Element, id: string, val: any, attribs?: any) => {
    implementsFunction(val, "deref") && (val = val.deref());
    if (id.startsWith("__")) return;
    const isListener = id[0] === "o" && id[1] === "n";
    if (isListener) {
Severity: Minor
Found in packages/hdom/src/dom.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 createTree has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

export const createTree = <T>(
    opts: Partial<HDOMOpts>,
    impl: HDOMImplementation<T>,
    parent: T,
    tree: any,
Severity: Minor
Found in packages/hdom/src/dom.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 hydrateTree has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

export const hydrateTree = <T>(
    opts: Partial<HDOMOpts>,
    impl: HDOMImplementation<any>,
    parent: T,
    tree: any,
Severity: Minor
Found in packages/hdom/src/dom.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 removeAttribs has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Wontfix

export const removeAttribs = (el: Element, attribs: string[], prev: any) => {
    for (let i = attribs.length; i-- > 0; ) {
        const a = attribs[i];
        if (a[0] === "o" && a[1] === "n") {
            removeListener(el, a.substring(2), prev[a]);
Severity: Minor
Found in packages/hdom/src/dom.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

Avoid too many return statements within this function.
Wontfix

        return parent;
Severity: Major
Found in packages/hdom/src/dom.ts - About 30 mins to fix

Avoid too many return statements within this function.
Wontfix

    return impl.createTextElement(parent, tree);
Severity: Major
Found in packages/hdom/src/dom.ts - About 30 mins to fix

There are no issues that match your filters.

Category
Status