eliace/ergo-js

View on GitHub
js/core/data.js

Summary

Maintainability
F
1 wk
Test Coverage

Function _val has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
Open

    _val: function(v) {
//        if('_cached' in this) return this._cached;
//        var v = undefined;

        if(arguments.length == 0) {
Severity: Minor
Found in js/core/data.js - About 1 day 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 data.js has 404 lines of code (exceeds 250 allowed). Consider refactoring.
Open


//= require events



Severity: Minor
Found in js/core/data.js - About 5 hrs to fix

    Function sync has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

        sync: function(newData) {
    
            var self = this;
    
            var valueUid = (this.options.valueUid || this._valueUid);
    Severity: Minor
    Found in js/core/data.js - About 5 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 del has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

        del: function(i) {
            if(arguments.length == 1) {
                this.entry(i).del();
            }
            else {
    Severity: Minor
    Found in js/core/data.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 sync has 85 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        sync: function(newData) {
    
            var self = this;
    
            var valueUid = (this.options.valueUid || this._valueUid);
    Severity: Major
    Found in js/core/data.js - About 3 hrs to fix

      Function _val has 58 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          _val: function(v) {
      //        if('_cached' in this) return this._cached;
      //        var v = undefined;
      
              if(arguments.length == 0) {
      Severity: Major
      Found in js/core/data.js - About 2 hrs to fix

        Function set has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            set: function(i, newValue) {
                if(arguments.length == 1) {
                    newValue = i;
        
                    var oldValue = this.get();
        Severity: Minor
        Found in js/core/data.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

        `` has 21 functions (exceeds 20 allowed). Consider refactoring.
        Open

        Ergo.defineClass('Ergo.core.DataSource', /** @lends Ergo.core.DataSource.prototype */{
        
            extends: 'Ergo.core.Object',
        
            mixins: ['observable'],
        Severity: Minor
        Found in js/core/data.js - About 2 hrs to fix

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

              add: function(value, index) {
          
                  var values = this.get();
          
                  var isLast = false;
          Severity: Minor
          Found in js/core/data.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 del has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              del: function(i) {
                  if(arguments.length == 1) {
                      this.entry(i).del();
                  }
                  else {
          Severity: Minor
          Found in js/core/data.js - About 1 hr to fix

            Function _initialize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                _initialize: function(src, id, o) {
            
            
                    /**
                     * Источник данных
            Severity: Minor
            Found in js/core/data.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 set has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                set: function(i, newValue) {
                    if(arguments.length == 1) {
                        newValue = i;
            
                        var oldValue = this.get();
            Severity: Minor
            Found in js/core/data.js - About 1 hr to fix

              Function add has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  add: function(value, index) {
              
                      var values = this.get();
              
                      var isLast = false;
              Severity: Minor
              Found in js/core/data.js - About 1 hr to fix

                Avoid deeply nested control flow statements.
                Open

                                        for(var i = 0; i < this._id.length; i++) {
                                            var key = this._id[i];
                                            if(key in v)
                                                src[key] = v[key];
                                        }
                Severity: Major
                Found in js/core/data.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          for(var i = 0; i < this._id.length; i++) {
                                              var key = this._id[i];
                                              if(key in v)
                                                  src[key] = v[key];
                                          }
                  Severity: Major
                  Found in js/core/data.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if(e)
                                                e._id[0] = j
                    Severity: Major
                    Found in js/core/data.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              for(var i = 0; i < this._id.length; i++)
                                                  mv[this._id[i]] = v[this._id[i]];
                      Severity: Major
                      Found in js/core/data.js - About 45 mins to fix

                        Function stream has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            stream: function(filter, sorter, pager, callback) {
                        
                                var ds = this;
                        
                                var values = ds.get();
                        Severity: Minor
                        Found in js/core/data.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 entry has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                            entry: function(i) {
                        
                        //        console.log('-- data entry --');
                        
                                var ds = this;
                        Severity: Minor
                        Found in js/core/data.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

                                            if(this._id.length == 1) {
                                                src[this._id[0]] = v
                                            }
                                            // multi key
                                            else {
                        Severity: Major
                        Found in js/core/data.js and 1 other location - About 4 hrs to fix
                        js/core/data.js on lines 279..292

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

                        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

                                            if(this._id.length == 1) {
                                                src[this._id[0]] = v
                                            }
                                            // multi key
                                            else {
                        Severity: Major
                        Found in js/core/data.js and 1 other location - About 4 hrs to fix
                        js/core/data.js on lines 256..269

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

                        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

                                    Object.keys(value_m)
                                        .map(function(k) { return value_m[k] })
                                        .sort(function(a,b) { return a.index-b.index; })
                                        .forEach(function(val) {
                        
                        
                        Severity: Major
                        Found in js/core/data.js and 1 other location - About 1 hr to fix
                        js/core/data.js on lines 842..852

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

                        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

                                    Object.keys(value_m)
                                        .map(function(k) { return value_m[k] })
                                        .forEach(function(val) {
                        
                                            var v = val.value;
                        Severity: Major
                        Found in js/core/data.js and 1 other location - About 1 hr to fix
                        js/core/data.js on lines 783..794

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

                        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.entries = Array.isArray(val) ? new Ergo.core.Array() : new Ergo.core.Collection();
                        Severity: Minor
                        Found in js/core/data.js and 1 other location - About 35 mins to fix
                        js/core/data.js on lines 398..398

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

                        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.entries = Array.isArray(newValue) ? new Ergo.core.Array() : new Ergo.core.Collection();
                        Severity: Minor
                        Found in js/core/data.js and 1 other location - About 35 mins to fix
                        js/core/data.js on lines 89..89

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

                        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