FrenchYeti/dexcalibur

View on GitHub
src/Finder.js

Summary

Maintainability
F
1 wk
Test Coverage

File Finder.js has 781 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var ut = require("./Utils.js");
const CLASS = require("./CoreClass.js");
const FILE = require("./File.js");
const Logger = require("./Logger.js")();
var CONST = require("./CoreConst.js");
Severity: Major
Found in src/Finder.js - About 1 day to fix

    Function SearchAPI has 153 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function SearchAPI(data){
        
        // AnalyzerDatabase (specialize InMemoryDb)
        var _db = this._db = data;
        this._queryCache = [];
    Severity: Major
    Found in src/Finder.js - About 6 hrs to fix

      Function __checkDeepField has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
      Open

          __checkDeepField(object,search, offset=0){
              let ref=object, i=offset;
      
              if(object == null) return false;
      
      
      Severity: Minor
      Found in src/Finder.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 _getTestFn has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          _getTestFn(dataModel, pattern, caseSensitive, lazy=false){
              
              //if(lazy===true) console.debug("LAZY mode detected !");
      
              if(pattern==undefined || pattern.length==0){
      Severity: Minor
      Found in src/Finder.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 _getTestFn has 76 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          _getTestFn(dataModel, pattern, caseSensitive, lazy=false){
              
              //if(lazy===true) console.debug("LAZY mode detected !");
      
              if(pattern==undefined || pattern.length==0){
      Severity: Major
      Found in src/Finder.js - About 3 hrs to fix

        Function show has 63 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        FinderResult.prototype.show = function(){
            let sub = [];
            this.data.map((k,x)=>{
        
                if(x instanceof CLASS.Method){
        Severity: Major
        Found in src/Finder.js - About 2 hrs to fix

          Function SearchAPI has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

          function SearchAPI(data){
              
              // AnalyzerDatabase (specialize InMemoryDb)
              var _db = this._db = data;
              this._queryCache = [];
          Severity: Minor
          Found in src/Finder.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 sshow has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          FinderResult.prototype.sshow = function(){
              let sub = [];
              this.data.map((k,x)=>{
                  if(x instanceof CLASS.Method){
                      sub.push({ 
          Severity: Minor
          Found in src/Finder.js - About 1 hr to fix

            Function caller has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            FinderResult.prototype.caller = function(){
                let meth = new MemoryDb.Index(), obj=null;
                this.data.map((k,v)=>{
                    obj=this.data[i];
            
            
            Severity: Minor
            Found in src/Finder.js - About 1 hr to fix

              Function __checkDeepField has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  __checkDeepField(object,search, offset=0){
                      let ref=object, i=offset;
              
                      if(object == null) return false;
              
              
              Severity: Minor
              Found in src/Finder.js - About 1 hr to fix

                Function _find has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    _find(index, model, pattern, caseSensitive, lazy=false, includeMissing=false){
                        if(pattern === null || pattern === undefined) return new FinderResult(index,this);
                
                        this.cache.push({ index:index, model:model, case:caseSensitive, lazy:lazy });
                
                
                Severity: Minor
                Found in src/Finder.js - About 55 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

                Avoid deeply nested control flow statements.
                Open

                                        if(ref[search.field[i]][k] instanceof CLASS.ObjectType){
                                            //console.log(search.field[i], ref[search.field[i]][k].name, search.field[i+1]);
                                            return this.__checkDeepField( this.__DB.classes.getEntry(ref[search.field[i]][k].name), search, i+1);
                                        }
                                        else if(ref[search.field[i]][k] instanceof CLASS.BasicType){
                Severity: Major
                Found in src/Finder.js - About 45 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              return null;
                  Severity: Major
                  Found in src/Finder.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                return new SearchPattern({ 
                                    pattern: pattern.substr(4),  
                                    isModifier: false, 
                                    hasTag: true, 
                                    fn:this._test.hasTag
                    Severity: Major
                    Found in src/Finder.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                              return this.__checkDeepField( this.__DB.classes.getEntry(ref[search.field[i]].name), search, i+1);
                      Severity: Major
                      Found in src/Finder.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                return new SearchPattern({ 
                                    pattern: pattern, 
                                    field: token, 
                                    isStructField: struct,
                                    isDeepSearch: isDeepSearch,
                        Severity: Major
                        Found in src/Finder.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                      return false;
                          Severity: Major
                          Found in src/Finder.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                        return new FinderResult(new MemoryDb.Index(), this); 
                            Severity: Major
                            Found in src/Finder.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                                  return this.__checkDeepField(ref[search.field[i]], search, i+1);
                              Severity: Major
                              Found in src/Finder.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                            return search.fn(ref);
                                Severity: Major
                                Found in src/Finder.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                                          return false;
                                  Severity: Major
                                  Found in src/Finder.js - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                                            return this.__checkDeepField(ref[search.field[i]], search, i+1);
                                    Severity: Major
                                    Found in src/Finder.js - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                                      return new FinderResult(this._findObject(index, spatt, includeMissing), this);
                                      Severity: Major
                                      Found in src/Finder.js - About 30 mins to fix

                                        Function union has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                        FinderResult.prototype.union = function(resultSet){
                                        
                                            if(typeof resultSet === 'string' || resultSet instanceof String){
                                                let res = this._finder._find(resultSet);
                                                res.data.map((k,v)=>{
                                        Severity: Minor
                                        Found in src/Finder.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 2 locations. Consider refactoring.
                                        Open

                                            this.getter = function(pattern=null){
                                                let res = null;
                                                if(pattern != null){
                                                    res = finder._find(
                                                        _db.call, DataModel.call, 
                                        Severity: Major
                                        Found in src/Finder.js and 1 other location - About 4 hrs to fix
                                        src/Finder.js on lines 1081..1096

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

                                        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

                                            this.setter = function(pattern=null){
                                                let res = null;
                                                if(pattern != null){
                                                    res = finder._find(
                                                        _db.call, DataModel.call, 
                                        Severity: Major
                                        Found in src/Finder.js and 1 other location - About 4 hrs to fix
                                        src/Finder.js on lines 1109..1124

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

                                        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

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

                                                else if(x instanceof CLASS.XRef){
                                                    sub.push({ Subject: x.calleed.signature() });
                                                    if(x.empty)
                                                        sub.push({ Subject: "\t  No reference found" });
                                                    else
                                        Severity: Major
                                        Found in src/Finder.js and 1 other location - About 2 hrs to fix
                                        src/Finder.js on lines 451..457

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

                                        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

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

                                                else if(x instanceof CLASS.XRef){
                                                    sub.push({ Subject: x.calleed.signature() });
                                                    if(x.empty)
                                                        sub.push({ Subject: "\t  No reference found" });
                                                    else
                                        Severity: Major
                                        Found in src/Finder.js and 1 other location - About 2 hrs to fix
                                        src/Finder.js on lines 502..526

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

                                        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

                                        MissingObjectAPI.prototype.method = function(pattern){
                                            let db = this.search("_log_tag:METHOD");
                                            return this._search._finder._find(db.data, DataModel.method, pattern, this._search._caseSensitive, true, true);     
                                        }
                                        Severity: Major
                                        Found in src/Finder.js and 1 other location - About 1 hr to fix
                                        src/Finder.js on lines 957..960

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

                                        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

                                        MissingObjectAPI.prototype.field = function(pattern){
                                            let db = this.search("_log_tag:FIELD");
                                            return this._search._finder._find(db.data, DataModel.field, pattern, this._search._caseSensitive, true, true);     
                                        }
                                        Severity: Major
                                        Found in src/Finder.js and 1 other location - About 1 hr to fix
                                        src/Finder.js on lines 953..956

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

                                        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