talho/openphin

View on GitHub
app/assets/javascripts/ext/src/widgets/tree/TreeNodeUI.js

Summary

Maintainability
F
4 days
Test Coverage

TreeNodeUI has 55 functions (exceeds 20 allowed). Consider refactoring.
Open

Ext.tree.TreeNodeUI = Ext.extend(Object, {
    
    constructor : function(node){
        Ext.apply(this, {
            node: node,
Severity: Major
Found in app/assets/javascripts/ext/src/widgets/tree/TreeNodeUI.js - About 7 hrs to fix

    File TreeNodeUI.js has 489 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*!
     * Ext JS Library 3.3.0
     * Copyright(c) 2006-2010 Ext JS, Inc.
     * licensing@extjs.com
     * http://www.extjs.com/license
    Severity: Minor
    Found in app/assets/javascripts/ext/src/widgets/tree/TreeNodeUI.js - About 7 hrs to fix

      Function updateExpandIcon has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          updateExpandIcon : function(){
              if(this.rendered){
                  var n = this.node,
                      c1,
                      c2,
      Severity: Minor
      Found in app/assets/javascripts/ext/src/widgets/tree/TreeNodeUI.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 updateExpandIcon has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          updateExpandIcon : function(){
              if(this.rendered){
                  var n = this.node,
                      c1,
                      c2,
      Severity: Minor
      Found in app/assets/javascripts/ext/src/widgets/tree/TreeNodeUI.js - About 1 hr to fix

        Function getChildIndent has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            getChildIndent : function(){
                if(!this.childIndent){
                    var buf = [],
                        p = this.node;
                    while(p){
        Severity: Minor
        Found in app/assets/javascripts/ext/src/widgets/tree/TreeNodeUI.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 renderElements has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            renderElements : function(n, a, targetNode, bulkRender){
                // add some indent caching, this helps performance when rendering a large tree
                this.indentMarkup = n.parentNode ? n.parentNode.ui.getChildIndent() : '';
        
                var cb = Ext.isBoolean(a.checked),
        Severity: Minor
        Found in app/assets/javascripts/ext/src/widgets/tree/TreeNodeUI.js - About 1 hr to fix

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

              onClick : function(e){
                  if(this.dropping){
                      e.stopEvent();
                      return;
                  }
          Severity: Minor
          Found in app/assets/javascripts/ext/src/widgets/tree/TreeNodeUI.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 renderElements has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              renderElements : function(n, a, targetNode, bulkRender){
                  // add some indent caching, this helps performance when rendering a large tree
                  this.indentMarkup = n.parentNode ? n.parentNode.ui.getChildIndent() : '';
          
                  var cb = Ext.isBoolean(a.checked),
          Severity: Minor
          Found in app/assets/javascripts/ext/src/widgets/tree/TreeNodeUI.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 render has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              render : function(bulkRender){
                  var n = this.node, a = n.attributes;
                  var targetNode = n.parentNode ?
                        n.parentNode.ui.getContainer() : n.ownerTree.innerCt.dom;
          
          
          Severity: Minor
          Found in app/assets/javascripts/ext/src/widgets/tree/TreeNodeUI.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 onTipChange has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              onTipChange : function(node, tip, title){
                  if(this.rendered){
                      var hasTitle = Ext.isDefined(title);
                      if(this.textNode.setAttributeNS){
                          this.textNode.setAttributeNS("ext", "qtip", tip);
          Severity: Minor
          Found in app/assets/javascripts/ext/src/widgets/tree/TreeNodeUI.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 onMove has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              onMove : function(tree, node, oldParent, newParent, index, refNode){
          Severity: Minor
          Found in app/assets/javascripts/ext/src/widgets/tree/TreeNodeUI.js - About 45 mins to fix

            Function onMove has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                onMove : function(tree, node, oldParent, newParent, index, refNode){
                    this.childIndent = null;
                    if(this.rendered){
                        var targetNode = newParent.ui.getContainer();
                        if(!targetNode){//target not rendered
            Severity: Minor
            Found in app/assets/javascripts/ext/src/widgets/tree/TreeNodeUI.js - About 45 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 focus has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                focus : function(){
                    if(!this.node.preventHScroll){
                        try{this.anchor.focus();
                        }catch(e){}
                    }else{
            Severity: Minor
            Found in app/assets/javascripts/ext/src/widgets/tree/TreeNodeUI.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

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

                initEvents : function(){
                    this.node.on("move", this.onMove, this);
            
                    if(this.node.disabled){
                        this.onDisableChange(this.node, true);
            Severity: Minor
            Found in app/assets/javascripts/ext/src/widgets/tree/TreeNodeUI.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

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

                onDblClick : function(e){
                    e.preventDefault();
                    if(this.disabled){
                        return;
                    }
            Severity: Minor
            Found in app/assets/javascripts/ext/src/widgets/tree/TreeNodeUI.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

                    ct.slideIn('t', {
                       callback : function(){
                           this.animating = false;
                           Ext.callback(callback);
                        },
            Severity: Major
            Found in app/assets/javascripts/ext/src/widgets/tree/TreeNodeUI.js and 1 other location - About 1 hr to fix
            app/assets/javascripts/ext/src/widgets/tree/TreeNodeUI.js on lines 408..415

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

            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

                    ct.slideOut('t', {
                        callback : function(){
                           this.animating = false;
                           Ext.callback(callback);
                        },
            Severity: Major
            Found in app/assets/javascripts/ext/src/widgets/tree/TreeNodeUI.js and 1 other location - About 1 hr to fix
            app/assets/javascripts/ext/src/widgets/tree/TreeNodeUI.js on lines 374..381

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

            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

                show : function(){
                    this.node.hidden = false;
                    if(this.wrap){
                        this.wrap.style.display = "";
                    }
            Severity: Major
            Found in app/assets/javascripts/ext/src/widgets/tree/TreeNodeUI.js and 1 other location - About 1 hr to fix
            app/assets/javascripts/ext/src/widgets/tree/TreeNodeUI.js on lines 212..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 57.

            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

                hide : function(){
                    this.node.hidden = true;
                    if(this.wrap){
                        this.wrap.style.display = "none";
                    }
            Severity: Major
            Found in app/assets/javascripts/ext/src/widgets/tree/TreeNodeUI.js and 1 other location - About 1 hr to fix
            app/assets/javascripts/ext/src/widgets/tree/TreeNodeUI.js on lines 222..227

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

            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

                onClsChange : function(node, cls, oldCls){
                    if(this.rendered){
                        Ext.fly(this.elNode).replaceClass(oldCls, cls);
                    }    
                },
            Severity: Minor
            Found in app/assets/javascripts/ext/src/widgets/tree/TreeNodeUI.js and 1 other location - About 45 mins to fix
            app/assets/javascripts/ext/src/widgets/tree/TreeNodeUI.js on lines 58..62

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

            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

                onIconClsChange : function(node, cls, oldCls){
                    if(this.rendered){
                        Ext.fly(this.iconNode).replaceClass(oldCls, cls);
                    }
                },
            Severity: Minor
            Found in app/assets/javascripts/ext/src/widgets/tree/TreeNodeUI.js and 1 other location - About 45 mins to fix
            app/assets/javascripts/ext/src/widgets/tree/TreeNodeUI.js on lines 103..107

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

            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

                removeClass : function(cls){
                    if(this.elNode){
                        Ext.fly(this.elNode).removeClass(cls);
                    }
                },
            Severity: Minor
            Found in app/assets/javascripts/ext/src/widgets/tree/TreeNodeUI.js and 1 other location - About 35 mins to fix
            app/assets/javascripts/ext/src/widgets/tree/TreeNodeUI.js on lines 154..158

            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

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

                addClass : function(cls){
                    if(this.elNode){
                        Ext.fly(this.elNode).addClass(cls);
                    }
                },
            Severity: Minor
            Found in app/assets/javascripts/ext/src/widgets/tree/TreeNodeUI.js and 1 other location - About 35 mins to fix
            app/assets/javascripts/ext/src/widgets/tree/TreeNodeUI.js on lines 164..168

            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