aureooms/js-memory

View on GitHub

Showing 8 of 8 total issues

Function heap has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

export function heap ( Buffer ) {

    /**
     * The *s* prefix in members and methods stands for size.
     * The *a* prefix in members and methods stands for address.
Severity: Minor
Found in src/heap.js - 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 heap has 89 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function heap ( Buffer ) {

    /**
     * The *s* prefix in members and methods stands for size.
     * The *a* prefix in members and methods stands for address.
Severity: Major
Found in src/heap.js - About 3 hrs to fix

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

                for (k = this.slo; k < j; ++k) {
                    this.size[k] = this.size[k+1];
                    this.smap[k] = this.smap[k+1];
                }
    Severity: Major
    Found in src/heap.js and 1 other location - About 2 hrs to fix
    src/heap.js on lines 112..115

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

    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

            for (k = this.ahi; k > j; --k) {
                this.addr[k] = this.addr[k-1];
                this.amap[k] = this.amap[k-1];
            }
    Severity: Major
    Found in src/heap.js and 1 other location - About 2 hrs to fix
    src/heap.js on lines 51..54

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

    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 free has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        Heap.prototype.free = function(i, n) {
            var j, k, tmp, joinleft, joinright;
            j = this.asearch(i, this.alo, this.ahi);
    
            joinleft = this.addr[j-1] + this.size[this.amap[j-1]] === i;
    Severity: Minor
    Found in src/heap.js - About 1 hr to fix

      Function smove has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          Heap.prototype.smove = function(i, j) {
              var tmp, m, n, k;
              n = i - j;
              m = this.shi - this.slo - n;
      
      
      Severity: Minor
      Found in src/heap.js - About 1 hr to fix

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

                    for (k = i; k > j; --k) {
                        this.smap[k] = this.smap[k-1];
                    }
        Severity: Minor
        Found in src/heap.js and 1 other location - About 40 mins to fix
        src/heap.js on lines 65..67

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

        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

                    for (k = i; k > j; --k) {
                        this.size[k] = this.size[k-1];
                    }
        Severity: Minor
        Found in src/heap.js and 1 other location - About 40 mins to fix
        src/heap.js on lines 71..73

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

        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

        Severity
        Category
        Status
        Source
        Language