thi-ng/umbrella

View on GitHub
packages/oquery/src/query.ts

Summary

Maintainability
A
2 hrs
Test Coverage

File query.ts has 415 lines of code (exceeds 250 allowed). Consider refactoring.
Wontfix

import type { Fn2, Nullable, Predicate } from "@thi.ng/api";
import { isArray } from "@thi.ng/checks/is-array";
import { isFunction } from "@thi.ng/checks/is-function";
import { isSet } from "@thi.ng/checks/is-set";
import { compare } from "@thi.ng/compare/compare";
Severity: Minor
Found in packages/oquery/src/query.ts - About 5 hrs to fix

Function ffn has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Wontfix

    ffn: (res, db: any, s, p, _, opts) => {
        if (opts.partial) {
            for (let $s in db) {
                if ((<FTerm>s)($s)) {
                    const sval = db[$s];
Severity: Minor
Found in packages/oquery/src/query.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 querySP has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Wontfix

const querySP: QueryImpl = (res, sval: any, s, p, _, opts) => {
    if (opts.partial) {
        for (let q in sval) {
            if ((<FTerm>p)(q)) {
                const val = sval[q];
Severity: Minor
Found in packages/oquery/src/query.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 query has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

export const query = <T extends QueryObj = QueryObj>(
    db: T[],
    terms: Nullable<QueryTerm<T>>[],
    opts: Partial<MultiQueryOpts<T>> = {}
) => {
Severity: Minor
Found in packages/oquery/src/query.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 collectSO has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Wontfix

const collectSO = (
    res: QueryObj,
    sval: any,
    s: SPTerm,
    o: any,
Severity: Minor
Found in packages/oquery/src/query.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 collectSP has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Wontfix

const collectSP = (
    res: QueryObj,
    sval: any,
    s: SPTerm,
    p: SPTerm,
Severity: Minor
Found in packages/oquery/src/query.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 coerce has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

const coerce = (x: any, isec = false) =>
    isArray(x)
        ? isec
            ? intersect(x)
            : (y: any) => x.includes(y)
Severity: Minor
Found in packages/oquery/src/query.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 deeply nested control flow statements.
Open

                        if ((<FTerm>p)($p)) {
                            collectFull(res, $s, sval);
                            break;
                        }
Severity: Major
Found in packages/oquery/src/query.ts - About 45 mins to fix

Function coerceStr has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Wontfix

const coerceStr = (x: any) =>
    isArray(x)
        ? coerce(x.map((y) => String(y)))
        : isSet(x)
        ? coerce(new Set([...x].map((y) => String(y))))
Severity: Minor
Found in packages/oquery/src/query.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 collect has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Wontfix

const collect = (
    acc: any,
    s: any,
    p: any,
    o: any,
Severity: Minor
Found in packages/oquery/src/query.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 match has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Wontfix

const match = (o: any, val: any, opts: QueryOpts) => {
    if (val != null) {
        const pred = <Predicate<any>>(
            (isFunction(o) ? o : ($: any) => opts.equiv(o, $))
        );
Severity: Minor
Found in packages/oquery/src/query.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 queryFL has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Wontfix

const queryFL: QueryImpl = (res, db: any, s, p, o, opts) => {
    if (opts.partial) {
        for (let $s in db) {
            (<FTerm>s)($s) && collect(res, $s, p, o, db[$s]?.[<string>p], opts);
        }
Severity: Minor
Found in packages/oquery/src/query.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 nln has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Wontfix

    nln: (res, db: any, _, p, __, opts) => {
        if (opts.partial) {
            for (let s in db) {
                const val = db[s][<string>p];
                val != null && addTriple(res, s, p, val);
Severity: Minor
Found in packages/oquery/src/query.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 queryNL has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Wontfix

const queryNL: QueryImpl = (res, db: any, _, p, o, opts) => {
    if (opts.partial) {
        for (let s in db) {
            collect(res, s, p, o, db[s][<string>p], opts);
        }
Severity: Minor
Found in packages/oquery/src/query.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