eliace/ergo-js

View on GitHub
js/core/events.js

Summary

Maintainability
F
3 days
Test Coverage

Function _bindEvents has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
Open

    _bindEvents: function(targetProperty) {

        var o = this.options;

        var target = targetProperty ? this[targetProperty] : this;
Severity: Minor
Found in js/core/events.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

Function _postConstruct has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

    _postConstruct: function(o) {


        if('events' in o){
            for(var i in o.events){
Severity: Minor
Found in js/core/events.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

Function _bindEvents has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    _bindEvents: function(targetProperty) {

        var o = this.options;

        var target = targetProperty ? this[targetProperty] : this;
Severity: Major
Found in js/core/events.js - About 2 hrs to fix

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

        fire: function(type, _event, baseEvent) {
    
            // "ленивая" генерация базового события
            // var _event = {
            //     base: baseEvent,
    Severity: Minor
    Found in js/core/events.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 _postConstruct has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        _postConstruct: function(o) {
    
    
            if('events' in o){
                for(var i in o.events){
    Severity: Minor
    Found in js/core/events.js - About 1 hr to fix

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

          fire: function(type, _event, baseEvent) {
      
              // "ленивая" генерация базового события
              // var _event = {
              //     base: baseEvent,
      Severity: Minor
      Found in js/core/events.js - About 1 hr to fix

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

            off: function(arg, arg2) {
        
                var events = this.events;
        
                if(arguments.length == 0) {
        Severity: Minor
        Found in js/core/events.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( action ==  null ) {
                                    //TODO missed action
                                    callback = this._missedAction.bind(this, callback);
                                }
                                else {
        Severity: Major
        Found in js/core/events.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if( typeof callback == 'string' ) {
                                      var a = callback.split(':');
          //                            callback = (a.length == 1) ? this[callback].bind(this, null) : this[a[0]]/*.rcurry(a[1])*/.bind(this, a[1]);
                                      // action
                                      var action = $ergo.alias('actions:'+a[0]) || this[a[0]];
          Severity: Major
          Found in js/core/events.js - About 45 mins to fix

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

                                if( $.isString(callback) ) {
                                    var a = callback.split(':');
                                    callback = (a.length == 1) ? this[callback] : this[a[0]].rcurry(a[1]).bind(this);
                                }
            Severity: Major
            Found in js/core/events.js and 1 other location - About 1 hr to fix
            js/core/events.js on lines 569..572

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

            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( $.isString(callback) ) {
                                    var a = callback.split(':');
                                    callback = (a.length == 1) ? this[callback] : this[a[0]].rcurry(a[1]).bind(this);
                                }
            Severity: Major
            Found in js/core/events.js and 1 other location - About 1 hr to fix
            js/core/events.js on lines 606..609

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

            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

                    else if( $.isFunction(arg) ){
                        // удаляем указанный обработчик
            //            for(var i = 0; i < events.length; i++) {
                        for(var i in events) {
                            events[i] = events[i].filter( function(h) { return h.callback != arg; } );
            Severity: Major
            Found in js/core/events.js and 1 other location - About 1 hr to fix
            js/core/events.js on lines 211..217

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

            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

                    else {
                        // удаляем все обработчики для указанного объекта
            //            for(var i = 0; i < e.length; i++) {
                        for(var i in events) {
                            events[i] = events[i].filter( function(h) { return h.target != arg; } );
            Severity: Major
            Found in js/core/events.js and 1 other location - About 1 hr to fix
            js/core/events.js on lines 204..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 59.

            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 events() {
                    if(!this.__evt) {
                        this.__evt = new Ergo.core.Observer(this);
                    }
                    return this.__evt;
            Severity: Minor
            Found in js/core/events.js and 2 other locations - About 35 mins to fix
            js/core/states.js on lines 658..663
            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