thi-ng/umbrella

View on GitHub
packages/intervals/src/index.ts

Summary

Maintainability
C
1 day
Test Coverage

Function classify has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Wontfix

export const classify = (a: Readonly<Interval>, b: Readonly<Interval>) =>
    a.equiv(b)
        ? Classifier.EQUIV
        : isBefore(a, b)
        ? Classifier.DISJOINT_LEFT
Severity: Minor
Found in packages/intervals/src/index.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

File index.ts has 266 lines of code (exceeds 250 allowed). Consider refactoring.
Wontfix

import type { Fn, Fn2, ICompare, IContains, ICopy, IEquiv } from "@thi.ng/api";
import { DEFAULT_EPS } from "@thi.ng/api/api";
import { isString } from "@thi.ng/checks/is-string";
import { and, or } from "@thi.ng/dlogic";
import { illegalArgs } from "@thi.ng/errors/illegal-arguments";
Severity: Minor
Found in packages/intervals/src/index.ts - About 2 hrs to fix

Function compare has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Wontfix

export const compare = (a: Readonly<Interval>, b: Readonly<Interval>) => {
    if (a === b) return 0;
    let c: number;
    return a.l < b.l
        ? -1
Severity: Minor
Found in packages/intervals/src/index.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 fold has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

export const fold = (i: Readonly<Interval>, x: number, eps = DEFAULT_EPS) => {
    do {
        if ((i.lopen && x <= i.l) || (!i.lopen && x < i.l)) {
            x = x - i.l + i.r - (i.ropen ? eps : 0);
        } else if ((i.ropen && x >= i.r) || (!i.ropen && x > i.r)) {
Severity: Minor
Found in packages/intervals/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 parse has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Wontfix

export const parse = (src: string) => {
    let l, r, c1, c2;
    const n = src.length - 1;
    const comma = src.indexOf(",") > 0;
    const dot = src.indexOf("..") > 0;
Severity: Minor
Found in packages/intervals/src/index.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

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

export const isBefore = (
    i: Readonly<Interval>,
    x: number | Readonly<Interval>
) =>
    x instanceof Interval
Severity: Major
Found in packages/intervals/src/index.ts and 1 other location - About 4 hrs to fix
packages/intervals/src/index.ts on lines 300..310

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

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 isAfter = (
    i: Readonly<Interval>,
    x: number | Readonly<Interval>
) =>
    x instanceof Interval
Severity: Major
Found in packages/intervals/src/index.ts and 1 other location - About 4 hrs to fix
packages/intervals/src/index.ts on lines 280..290

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

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 3 locations. Consider refactoring.
Invalid

export const suffix = (a: Readonly<Interval>, b: Readonly<Interval>) => {
    if (overlaps(a, b)) {
        const [l, lo] = $max(a.l, b.r, a.lopen, b.ropen, or);
        const [r, ro] = $max(a.r, b.r, a.ropen, b.ropen, or);
        return new Interval(l, r, lo, ro);
Severity: Major
Found in packages/intervals/src/index.ts and 2 other locations - About 4 hrs to fix
packages/intervals/src/index.ts on lines 465..471
packages/intervals/src/index.ts on lines 473..479

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

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 3 locations. Consider refactoring.
Invalid

export const prefix = (a: Readonly<Interval>, b: Readonly<Interval>) => {
    if (overlaps(a, b)) {
        const [l, lo] = $min(a.l, b.l, a.lopen, b.lopen, or);
        const [r, ro] = $min(a.r, b.l, a.ropen, b.lopen, or);
        return new Interval(l, r, lo, ro);
Severity: Major
Found in packages/intervals/src/index.ts and 2 other locations - About 4 hrs to fix
packages/intervals/src/index.ts on lines 465..471
packages/intervals/src/index.ts on lines 481..487

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

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 3 locations. Consider refactoring.
Invalid

export const intersection = (a: Readonly<Interval>, b: Readonly<Interval>) => {
    if (overlaps(a, b)) {
        const [l, lo] = $max(a.l, b.l, a.lopen, b.lopen, or);
        const [r, ro] = $min(a.r, b.r, a.ropen, b.ropen, or);
        return new Interval(l, r, lo, ro);
Severity: Major
Found in packages/intervals/src/index.ts and 2 other locations - About 4 hrs to fix
packages/intervals/src/index.ts on lines 473..479
packages/intervals/src/index.ts on lines 481..487

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

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

export const max = (i: Readonly<Interval>, x: number, eps = DEFAULT_EPS) =>
    i.lopen ? (x <= i.l ? i.l + eps : x) : x < i.l ? i.l : x;
Severity: Major
Found in packages/intervals/src/index.ts and 1 other location - About 2 hrs to fix
packages/intervals/src/index.ts on lines 498..499

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

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

export const min = (i: Readonly<Interval>, x: number, eps = DEFAULT_EPS) =>
    i.ropen ? (x >= i.r ? i.r - eps : x) : x > i.r ? i.r : x;
Severity: Major
Found in packages/intervals/src/index.ts and 1 other location - About 2 hrs to fix
packages/intervals/src/index.ts on lines 510..511

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

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

const $max = (
    a: number,
    b: number,
    ao: boolean,
    bo: boolean,
Severity: Major
Found in packages/intervals/src/index.ts and 1 other location - About 1 hr to fix
packages/intervals/src/index.ts on lines 549..555

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

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

const $min = (
    a: number,
    b: number,
    ao: boolean,
    bo: boolean,
Severity: Major
Found in packages/intervals/src/index.ts and 1 other location - About 1 hr to fix
packages/intervals/src/index.ts on lines 558..564

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

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

There are no issues that match your filters.

Category
Status