talho/openphin

View on GitHub
app/assets/javascripts/ext/src/widgets/menu/Menu.js

Summary

Maintainability
F
4 days
Test Coverage

File Menu.js has 478 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/menu/Menu.js - About 7 hrs to fix

    Menu has 31 functions (exceeds 20 allowed). Consider refactoring.
    Open

    Ext.menu.Menu = Ext.extend(Ext.Container, {
        /**
         * @cfg {Object} defaults
         * A config object that will be applied to all items added to this container either via the {@link #items}
         * config or via the {@link #add} method.  The defaults config can contain any number of
    Severity: Minor
    Found in app/assets/javascripts/ext/src/widgets/menu/Menu.js - About 3 hrs to fix

      Function MenuNav has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

      Ext.menu.MenuNav = Ext.extend(Ext.KeyNav, function(){
          function up(e, m){
              if(!m.tryActivate(m.items.indexOf(m.activeItem)-1, -1)){
                  m.tryActivate(m.items.length-1, -1);
              }
      Severity: Minor
      Found in app/assets/javascripts/ext/src/widgets/menu/Menu.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

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

      Ext.menu.MenuNav = Ext.extend(Ext.KeyNav, function(){
          function up(e, m){
              if(!m.tryActivate(m.items.indexOf(m.activeItem)-1, -1)){
                  m.tryActivate(m.items.length-1, -1);
              }
      Severity: Major
      Found in app/assets/javascripts/ext/src/widgets/menu/Menu.js - About 2 hrs to fix

        Function onRender has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            onRender : function(ct, position){
                if(!ct){
                    ct = Ext.getBody();
                }
        
        
        Severity: Minor
        Found in app/assets/javascripts/ext/src/widgets/menu/Menu.js - About 1 hr to fix

          Function constrainScroll has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              constrainScroll : function(y){
                  var max, full = this.ul.setHeight('auto').getHeight(),
                      returnY = y, normalY, parentEl, scrollTop, viewHeight;
                  if(this.floating){
                      parentEl = Ext.fly(this.el.dom.parentNode);
          Severity: Minor
          Found in app/assets/javascripts/ext/src/widgets/menu/Menu.js - About 1 hr to fix

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

                showAt : function(xy, parentMenu){
                    if(this.fireEvent('beforeshow', this) !== false){
                        this.parentMenu = parentMenu;
                        if(!this.el){
                            this.render();
            Severity: Minor
            Found in app/assets/javascripts/ext/src/widgets/menu/Menu.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 constrainScroll has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                constrainScroll : function(y){
                    var max, full = this.ul.setHeight('auto').getHeight(),
                        returnY = y, normalY, parentEl, scrollTop, viewHeight;
                    if(this.floating){
                        parentEl = Ext.fly(this.el.dom.parentNode);
            Severity: Minor
            Found in app/assets/javascripts/ext/src/widgets/menu/Menu.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 createScrollers has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                createScrollers : function(){
                    if(!this.scroller){
                        this.scroller = {
                            pos: 0,
                            top: this.el.insertFirst({
            Severity: Minor
            Found in app/assets/javascripts/ext/src/widgets/menu/Menu.js - About 1 hr to fix

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

                  initComponent : function(){
                      if(Ext.isArray(this.initialConfig)){
                          Ext.apply(this, {items:this.initialConfig});
                      }
                      this.addEvents(
              Severity: Minor
              Found in app/assets/javascripts/ext/src/widgets/menu/Menu.js - About 1 hr to fix

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

                    onRender : function(ct, position){
                        if(!ct){
                            ct = Ext.getBody();
                        }
                
                
                Severity: Minor
                Found in app/assets/javascripts/ext/src/widgets/menu/Menu.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

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

                    lookupComponent : function(c){
                         if(Ext.isString(c)){
                            c = (c == 'separator' || c == '-') ? new Ext.menu.Separator() : new Ext.menu.TextItem(c);
                             this.applyDefaults(c);
                         }else{
                Severity: Minor
                Found in app/assets/javascripts/ext/src/widgets/menu/Menu.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 onClick has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    onClick : function(e){
                        var t = this.findTargetItem(e);
                        if(t){
                            if(t.isFormField){
                                this.setActiveItem(t);
                Severity: Minor
                Found in app/assets/javascripts/ext/src/widgets/menu/Menu.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 applyDefaults has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    applyDefaults : function(c) {
                        if (!Ext.isString(c)) {
                            c = Ext.menu.Menu.superclass.applyDefaults.call(this, c);
                            var d = this.internalDefaults;
                            if(d){
                Severity: Minor
                Found in app/assets/javascripts/ext/src/widgets/menu/Menu.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 deactivateActive has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    deactivateActive : function(){
                        var a = this.activeItem;
                        if(a){
                            if(a.isFormField){
                                //Fields cannot deactivate, but Combos must collapse
                Severity: Minor
                Found in app/assets/javascripts/ext/src/widgets/menu/Menu.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 initComponent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    initComponent : function(){
                        if(Ext.isArray(this.initialConfig)){
                            Ext.apply(this, {items:this.initialConfig});
                        }
                        this.addEvents(
                Severity: Minor
                Found in app/assets/javascripts/ext/src/widgets/menu/Menu.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.scroller.bottomRepeater = new Ext.util.ClickRepeater(this.scroller.bottom, {
                                listeners: {
                                    click: this.onScroll.createDelegate(this, [null, this.scroller.bottom], false)
                                }
                            });
                Severity: Major
                Found in app/assets/javascripts/ext/src/widgets/menu/Menu.js and 1 other location - About 1 hr to fix
                app/assets/javascripts/ext/src/widgets/menu/Menu.js on lines 469..473

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

                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.scroller.topRepeater = new Ext.util.ClickRepeater(this.scroller.top, {
                                listeners: {
                                    click: this.onScroll.createDelegate(this, [null, this.scroller.top], false)
                                }
                            });
                Severity: Major
                Found in app/assets/javascripts/ext/src/widgets/menu/Menu.js and 1 other location - About 1 hr to fix
                app/assets/javascripts/ext/src/widgets/menu/Menu.js on lines 475..479

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

                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 3 locations. Consider refactoring.
                Open

                                if(c.events){
                                    Ext.applyIf(c.initialConfig, d);
                                    Ext.apply(c, d);
                                }else{
                                    Ext.applyIf(c, d);
                Severity: Major
                Found in app/assets/javascripts/ext/src/widgets/menu/Menu.js and 2 other locations - About 1 hr to fix
                app/assets/javascripts/ext/src/widgets/ButtonGroup.js on lines 87..92
                app/assets/javascripts/ext/src/widgets/Toolbar.js on lines 228..233

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

                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

                        this.mon(this.ul, {
                            scope: this,
                            click: this.onClick,
                            mouseover: this.onMouseOver,
                            mouseout: this.onMouseOut
                Severity: Major
                Found in app/assets/javascripts/ext/src/widgets/menu/Menu.js and 2 other locations - About 40 mins to fix
                app/assets/javascripts/ext/src/widgets/form/TextField.js on lines 231..236
                app/assets/javascripts/ext/src/widgets/menu/BaseItem.js on lines 93..98

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

                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