FrenchYeti/dexcalibur

View on GitHub
inspectors/Saver/SaveManager.js

Summary

Maintainability
F
6 days
Test Coverage

Function import has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
Open

    import(pData){
        let index = null, o=null, hook=null, qflag=0;

        if(pData.classes.size > 0){
            index = this._db.getIndex("classes");
Severity: Minor
Found in inspectors/Saver/SaveManager.js - About 6 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 SaveManager.js has 336 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const _fs_ = require("fs");
const _path_ = require("path");

const Logger = require('../../src/Logger.js')(); 
const DB = require('../../connectors/inmemory/InMemoryDb.js');
Severity: Minor
Found in inspectors/Saver/SaveManager.js - About 4 hrs to fix

    Function export has 96 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        export(pExclude=null){
            let data={}, coll=null, pData=null;
            let self=this;
    
            data.methods = {data:{}, size:self._db.getIndex("methods").size()};
    Severity: Major
    Found in inspectors/Saver/SaveManager.js - About 3 hrs to fix

      Function import has 83 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          import(pData){
              let index = null, o=null, hook=null, qflag=0;
      
              if(pData.classes.size > 0){
                  index = this._db.getIndex("classes");
      Severity: Major
      Found in inspectors/Saver/SaveManager.js - About 3 hrs to fix

        Function export has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

            export(pExclude=null){
                let data={}, coll=null, pData=null;
                let self=this;
        
                data.methods = {data:{}, size:self._db.getIndex("methods").size()};
        Severity: Minor
        Found in inspectors/Saver/SaveManager.js - 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 removeFromQueue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            removeFromQueue(pType, pKey){
                let o={};
        
                if(this.queue[pType] !== undefined){
                    this.queueSize[pType] = 0;
        Severity: Minor
        Found in inspectors/Saver/SaveManager.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

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

                if(pData.methods.size > 0){
                    index = this._db.getIndex("methods");
                    for(let k in pData.methods.data){
                        o = this.context.find.get.method(k);
                        if(o != null){
        Severity: Major
        Found in inspectors/Saver/SaveManager.js and 2 other locations - About 5 hrs to fix
        inspectors/Saver/SaveManager.js on lines 167..180
        inspectors/Saver/SaveManager.js on lines 197..210

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

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

                if(pData.classes.size > 0){
                    index = this._db.getIndex("classes");
                    for(let k in pData.classes.data){
                        o = this.context.find.get.class(k);
                        if(o != null){
        Severity: Major
        Found in inspectors/Saver/SaveManager.js and 2 other locations - About 5 hrs to fix
        inspectors/Saver/SaveManager.js on lines 182..195
        inspectors/Saver/SaveManager.js on lines 197..210

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

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

                if(pData.fields.size > 0){
                    index = this._db.getIndex("fields");
                    for(let k in pData.fields.data){
                        o = this.context.find.get.field(k);
                        if(o != null){
        Severity: Major
        Found in inspectors/Saver/SaveManager.js and 2 other locations - About 5 hrs to fix
        inspectors/Saver/SaveManager.js on lines 167..180
        inspectors/Saver/SaveManager.js on lines 182..195

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

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

                if(data.methods.size > 0){
                    coll = self._db.getIndex("methods");
                    coll.map(function(ref,obj){
                        data.methods.data[ref] = {
                            type: SaveManager.T_METHOD,
        Severity: Major
        Found in inspectors/Saver/SaveManager.js and 2 other locations - About 2 hrs to fix
        inspectors/Saver/SaveManager.js on lines 332..340
        inspectors/Saver/SaveManager.js on lines 352..360

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

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

                if(data.fields.size > 0){
                    coll = self._db.getIndex("fields");
                    coll.map(function(ref,obj){
                        data.fields.data[ref] = {
                            type: SaveManager.T_FIELD,
        Severity: Major
        Found in inspectors/Saver/SaveManager.js and 2 other locations - About 2 hrs to fix
        inspectors/Saver/SaveManager.js on lines 342..350
        inspectors/Saver/SaveManager.js on lines 352..360

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

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

                if(data.classes.size > 0){
                    coll = self._db.getIndex("classes");
                    coll.map(function(ref,obj){
                        data.classes.data[ref] = {
                            type: SaveManager.T_CLASS,
        Severity: Major
        Found in inspectors/Saver/SaveManager.js and 2 other locations - About 2 hrs to fix
        inspectors/Saver/SaveManager.js on lines 332..340
        inspectors/Saver/SaveManager.js on lines 342..350

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

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

                if(this.queueSize.classes > 0){
                    for(let i in this.queue.classes){
                        data.classes.data[i] = {
                            type: SaveManager.T_CLASS,
                            alias: this.queue.classes[i].alias
        Severity: Major
        Found in inspectors/Saver/SaveManager.js and 2 other locations - About 1 hr to fix
        inspectors/Saver/SaveManager.js on lines 299..306
        inspectors/Saver/SaveManager.js on lines 315..322

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

                if(this.queueSize.methods > 0){
                    for(let i in this.queue.methods){
                        data.methods.data[i] = {
                            type: SaveManager.T_METHOD,
                            alias: this.queue.methods[i].alias
        Severity: Major
        Found in inspectors/Saver/SaveManager.js and 2 other locations - About 1 hr to fix
        inspectors/Saver/SaveManager.js on lines 307..314
        inspectors/Saver/SaveManager.js on lines 315..322

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

                if(this.queueSize.hooks > 0){
                    for(let i in this.queue.hooks){
                        data.hooks.data[i] = {
                            type: SaveManager.T_HOOK,
                            alias: this.queue.hooks[i].alias
        Severity: Major
        Found in inspectors/Saver/SaveManager.js and 2 other locations - About 1 hr to fix
        inspectors/Saver/SaveManager.js on lines 299..306
        inspectors/Saver/SaveManager.js on lines 307..314

        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

        There are no issues that match your filters.

        Category
        Status