thi-ng/umbrella

View on GitHub

Showing 378 of 1,891 total issues

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

const __parse = (src: string, opts?: Partial<ContextOpts>) => {
    const ctx = defContext(src, opts);
    return { result: GRAMMAR!.rules.main(ctx), ctx };
};
Severity: Major
Found in packages/proctext/src/generate.ts and 1 other location - About 1 hr to fix
packages/hiccup-html-parse/src/index.ts on lines 131..134

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 69.

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 2 locations. Consider refactoring.
Open

export const parseRaw = (src: string, opts?: Partial<ContextOpts>) => {
    const ctx = defContext(src, opts);
    return { result: lang!.rules.main(ctx), ctx };
};
Severity: Major
Found in packages/hiccup-html-parse/src/index.ts and 1 other location - About 1 hr to fix
packages/proctext/src/generate.ts on lines 80..83

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 69.

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

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

    protected doQuery(
        p: K,
        r: number,
        max: number,
        acc: Heap<[number, NdQtNode<K, V>?]>,
Severity: Minor
Found in packages/geom-accel/src/nd-quadtree-map.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 setAttrib has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    setAttrib(el: HDOMNode, id: string, val: any, attribs?: any) {
        if (id.startsWith("__")) return;
        const isListener = id.indexOf("on") === 0;
        if (!isListener && typeof val === "function") {
            val = val(attribs);
Severity: Minor
Found in packages/hdom-mock/src/index.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 toPath has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

export const toPath = (path: Path): readonly NumOrString[] => {
    if (isArray(path)) {
        if (!path.every((x) => isString(x) || isNumber(x))) __illegal(path);
        return <any[]>path;
    } else {
Severity: Minor
Found in packages/paths/src/path.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 path has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

        path: ($: Path, p, out) => {
            let minD = Infinity;
            const $closestPSegment = (segments: PathSegment[]) => {
                for (let s of segments) {
                    if (!s.geo) continue;
Severity: Minor
Found in packages/geom/src/closest-point.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 computeCell has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    computeCell(
        { rule, kernel, weights, fn }: CAConfig1D,
        x: number,
        val: number
    ) {
Severity: Minor
Found in packages/cellular/src/1d.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 convexity has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Confirmed

export const convexity = (pts: ReadonlyVec[], eps = EPS) => {
    let n = pts.length;
    if (n < 3) {
        return n < 2 ? Convexity.ILLEGAL : Convexity.COLINEAR;
    }
Severity: Minor
Found in packages/geom-poly-utils/src/convexity.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 convolveOpen has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

export const convolveOpen = (
    pts: ReadonlyVec[],
    kernel: number[],
    t = 0.5,
    iter = 1
Severity: Minor
Found in packages/geom-poly-utils/src/convolve.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 __generateFields has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

const __generateFields = (
    gen: ICodeGen,
    parent: Struct | Union,
    coll: TypeColl,
    opts: CodeGenOpts,
Severity: Minor
Found in packages/wasm-api-bindgen/src/c11.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 traverse has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

export const traverse = (
    subs: ISubscribable<any>[],
    opts?: Partial<DotOpts>,
    state?: TraversalState
) => {
Severity: Minor
Found in packages/rstream-dot/src/index.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 __parseKey has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

const __parseKey = <T extends IObjectOf<any>>(
    specs: Args<T>,
    aliases: IObjectOf<string>,
    acc: any,
    a: string
Severity: Minor
Found in packages/args/src/parse.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 entries has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    *entries(key?: K, max = false): IterableIterator<Pair<K, V>> {
        if (key === undefined) {
            yield* this;
            return;
        }
Severity: Minor
Found in packages/sorted-map/src/sorted-map.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 bitWriter has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

export const bitWriter = (capacity = 16) => {
    let buf = new Uint8Array(capacity);
    let pos = 0;
    let bit = 8;

Severity: Minor
Found in packages/bitstream/src/simple.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 __compare2 has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

const __compare2 = (
    a1: NumOrString,
    a2: NumOrString,
    b1: NumOrString,
    b2: NumOrString
Severity: Minor
Found in packages/compare/src/string.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 authorLink has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

export const authorLink = (author: string | User) => {
    if (isString(author)) {
        const [name, a, b] = author.split(/\s*[<(]/);
        const href = b ? (b[b.length - 1] == ")" ? b : a) : a ? a : "";
        return href.length && href[href.length - 1] === ")"
Severity: Minor
Found in packages/transclude/src/tpl/pkg.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 tween has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

export function* tween<A, B, C>(opts: TweenOpts<A, B, C>): IterableIterator<C> {
    const { min, max, num, init, mix, stops } = opts;
    const easing = opts.easing || ((x: number) => x);
    let l = stops.length;
    if (l < 1) return;
Severity: Minor
Found in packages/transducers/src/tween.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 findSequence has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

export function findSequence(
    buf: any[] | TypedArray,
    needle: ArrayLike<any>,
    start = 0
) {
Severity: Minor
Found in packages/arrays/src/find-sequence.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 liangBarsky has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

export const liangBarsky: FnU8<number, Maybe<Tuple<number, 4>>> = (
    ax,
    ay,
    bx,
    by,
Severity: Minor
Found in packages/grid-iterators/src/clipping.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 diagonal2d has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

export function* diagonal2d(opts: GridIterOpts2D) {
    const { cols, rows, tx } = __opts(opts);
    const num = cols * rows - 1;
    for (let x = 0, y = 0, nx = 1, ny = 0, i = 0; i <= num; i++) {
        yield tx(x, y);
Severity: Minor
Found in packages/grid-iterators/src/diagonal.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

Severity
Category
Status
Source
Language