thi-ng/umbrella

View on GitHub
packages/hiccup/src/serialize.ts

Summary

Maintainability
A
35 mins
Test Coverage

Function _serialize has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Wontfix

const _serialize = (tree: any, opts: SerializeOpts, path: any[]): string =>
    tree == null
        ? ""
        : Array.isArray(tree)
        ? serializeElement(tree, opts, path)
Severity: Minor
Found in packages/hiccup/src/serialize.ts - About 5 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 serializeElement has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Wontfix

const serializeElement = (tree: any[], opts: SerializeOpts, path: any[]) => {
    let tag = tree[0];
    return !tree.length
        ? ""
        : isFunction(tag)
Severity: Minor
Found in packages/hiccup/src/serialize.ts - About 4 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 serializeAttrib has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Wontfix

const serializeAttrib = (
    attribs: any,
    a: string,
    v: any,
    opts: SerializeOpts
Severity: Minor
Found in packages/hiccup/src/serialize.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 attribPair has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Wontfix

const attribPair = (a: string, v: any, opts: SerializeOpts) => {
    v =
        a === "style" && isPlainObject(v)
            ? css(v)
            : a === "prefix" && isPlainObject(v)
Severity: Minor
Found in packages/hiccup/src/serialize.ts - About 55 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 serializeTag has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const serializeTag = (tree: any[], opts: SerializeOpts, path: any[]) => {
    tree = normalize(tree);
    const attribs = tree[1];
    if (attribs.__skip || attribs.__serialize === false) return "";
    opts.keys && attribs.key === undefined && (attribs.key = path.join("-"));
Severity: Minor
Found in packages/hiccup/src/serialize.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

There are no issues that match your filters.

Category
Status