binary-search-tree/red-black-tree

View on GitHub

Showing 10 of 24 total issues

Function unlink has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    unlink(node) {
        assert(node instanceof Node);
        if (node.left !== null) {
            // Swap node with its predecessor
            const pred = predecessor(node);
Severity: Minor
Found in src/types/RedBlackTree.js - 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 unlink has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    unlink(node) {
        assert(node instanceof Node);
        if (node.left !== null) {
            // Swap node with its predecessor
            const pred = predecessor(node);
Severity: Major
Found in src/types/RedBlackTree.js - About 2 hrs to fix

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

    export default function* rangetraversal(compare, root, left, right) {
        if (compare(root.key, left) < 0) {
            // If the root lies to the left of the interval, we can discard the
            // entire left subtree.
            if (root.right !== null) {
    Severity: Minor
    Found in src/traversal/rangetraversal.js - 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 insert has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    const insert = (compare, A, B) => {
        while (true) {
            if (compare(B.key, A.key) < 0) {
                const node = A.left;
    
    
    Severity: Minor
    Found in src/insertion/insert.js - 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 leftOpenRangeTraversal has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function* leftOpenRangeTraversal(compare, root, right) {
        if (compare(root.key, right) >= 0) {
            // If the root lies to the right of the interval, we can discard the
            // entire right subtree.
            if (root.left !== null) {
    Severity: Minor
    Found in src/traversal/leftOpenRangeTraversal.js - 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 rightOpenRangeTraversal has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function* rightOpenRangeTraversal(compare, root, left) {
        if (compare(root.key, left) < 0) {
            // If the root lies to the left of the interval, we can discard the
            // entire left subtree.
            if (root.right !== null) {
    Severity: Minor
    Found in src/traversal/rightOpenRangeTraversal.js - 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 delete_case4 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    const delete_case4 = (n) => {
        assert(n instanceof Node);
        assert(n._color === BLACK);
        assert(n.parent !== null);
        const s = sibling(n);
    Severity: Minor
    Found in src/deletion/delete_case4.js - 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 search has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    const search = (compare, root, key) => {
        assert(root instanceof Node);
        while (true) {
            const d = compare(key, root.key);
    
    
    Severity: Minor
    Found in src/search/search.js - 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 delete_case3 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    const delete_case3 = (n) => {
        assert(n instanceof Node);
        assert(n._color === BLACK);
        assert(n.parent !== null);
        const s = sibling(n);
    Severity: Minor
    Found in src/deletion/delete_case3.js - 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 swap_non_adjacent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    const swap_non_adjacent = (A, B) => {
        assert(A instanceof Node);
        assert(B instanceof Node);
        const p = A.parent;
        const u = A.left;
    Severity: Minor
    Found in src/swap/swap_non_adjacent.js - 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

    Severity
    Category
    Status
    Source
    Language