eliace/ergo-js

View on GitHub
js/core/states.js

Summary

Maintainability
F
4 days
Test Coverage

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

    set: function(to, data) {

        if(!to || (typeof to !== 'string')) {
            console.warn('State key ['+$ergo.print(to)+'] must be of type string');
            return false;
Severity: Minor
Found in js/core/states.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 set has 82 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    set: function(to, data) {

        if(!to || (typeof to !== 'string')) {
            console.warn('State key ['+$ergo.print(to)+'] must be of type string');
            return false;
Severity: Major
Found in js/core/states.js - About 3 hrs to fix

    File states.js has 300 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    
    //= require events
    
    
    
    Severity: Minor
    Found in js/core/states.js - About 3 hrs to fix

      Function _bindStates has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          _bindStates: function() {
              var o = this.options;
      
              if('states' in o){
                  for(var i in o.states) {
      Severity: Minor
      Found in js/core/states.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 state has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          state: function(name, value) {
      
              if(arguments.length == 1) {
                  return this._current[name];
              }
      Severity: Minor
      Found in js/core/states.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 _state_on has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          _state_on: function(s, data) {
      
              var self = this;
              var states = this._states;//this._widget.options.states;
      
      Severity: Minor
      Found in js/core/states.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 unset has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          unset: function(from, data) {
      
              // Если состояние не установлено, то ничего не делаем
              if(from && !(from in this._current)) {
                  return false;//$.when({});
      Severity: Minor
      Found in js/core/states.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 unset has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          unset: function(from, data) {
      
              // Если состояние не установлено, то ничего не делаем
              if(from && !(from in this._current)) {
                  return false;//$.when({});
      Severity: Minor
      Found in js/core/states.js - About 1 hr to fix

        Function _state_on has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            _state_on: function(s, data) {
        
                var self = this;
                var states = this._states;//this._widget.options.states;
        
        Severity: Minor
        Found in js/core/states.js - About 1 hr to fix

          Function _state_off has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              _state_off: function(s, data) {
          
                  var self = this;
                  var states = this._states;//this._widget.options.states;
          
          Severity: Minor
          Found in js/core/states.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 _state_off has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              _state_off: function(s, data) {
          
                  var self = this;
                  var states = this._states;//this._widget.options.states;
          
          Severity: Minor
          Found in js/core/states.js - About 1 hr to fix

            Function state has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                state: function(name, value) {
            
                    if(arguments.length == 1) {
                        return this._current[name];
                    }
            Severity: Minor
            Found in js/core/states.js - About 1 hr to fix

              Avoid deeply nested control flow statements.
              Open

                                      if( this._groups[i][stt] ) {
                                          g = i;
                                          break;
                                      }
              Severity: Major
              Found in js/core/states.js - About 45 mins to fix

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

                            if(typeof val == 'string') {
                                // action
                                var a = val.split(':');
                                var action = $ergo.alias('actions:'+a[0]) || this._widget[a[0]];
                                if(action == null) {
                Severity: Major
                Found in js/core/states.js and 1 other location - About 3 hrs to fix
                js/core/states.js on lines 379..390

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

                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(typeof val == 'string') {
                                // action
                                var a = val.split(':');
                                var action = $ergo.alias('actions:'+a[0]) || this._widget[a[0]];
                                if(action == null) {
                Severity: Major
                Found in js/core/states.js and 1 other location - About 3 hrs to fix
                js/core/states.js on lines 319..330

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

                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

                    get states() {
                        if( !this.__stt ) {
                            this.__stt = new Ergo.core.StateManager(this);
                        }
                        return this.__stt;
                Severity: Minor
                Found in js/core/states.js and 2 other locations - About 35 mins to fix
                js/core/events.js on lines 377..382
                js/core/widget.js on lines 685..690

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

                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