talho/openphin

View on GitHub
app/assets/javascripts/ext/src/widgets/form/HtmlEditor.js

Summary

Maintainability
F
1 wk
Test Coverage

File HtmlEditor.js has 799 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: Major
Found in app/assets/javascripts/ext/src/widgets/form/HtmlEditor.js - About 1 day to fix

    Function createToolbar has 145 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        createToolbar : function(editor){
            var items = [];
            var tipsEnabled = Ext.QuickTips && Ext.QuickTips.isEnabled();
    
    
    
    Severity: Major
    Found in app/assets/javascripts/ext/src/widgets/form/HtmlEditor.js - About 5 hrs to fix

      Function createToolbar has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
      Open

          createToolbar : function(editor){
              var items = [];
              var tipsEnabled = Ext.QuickTips && Ext.QuickTips.isEnabled();
      
      
      
      Severity: Minor
      Found in app/assets/javascripts/ext/src/widgets/form/HtmlEditor.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

      HtmlEditor has 41 functions (exceeds 20 allowed). Consider refactoring.
      Open

      Ext.form.HtmlEditor = Ext.extend(Ext.form.Field, {
          /**
           * @cfg {Boolean} enableFormat Enable the bold, italic and underline buttons (defaults to true)
           */
          enableFormat : true,
      Severity: Minor
      Found in app/assets/javascripts/ext/src/widgets/form/HtmlEditor.js - About 5 hrs to fix

        Function adjustFont has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            adjustFont: function(btn){
                var adjust = btn.getItemId() == 'increasefontsize' ? 1 : -1,
                    doc = this.getDoc(),
                    v = parseInt(doc.queryCommandValue('FontSize') || 2, 10);
                if((Ext.isSafari && !Ext.isSafari2) || Ext.isChrome || Ext.isAir){
        Severity: Minor
        Found in app/assets/javascripts/ext/src/widgets/form/HtmlEditor.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 fixKeys has 50 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            fixKeys : function(){ // load time branching for fastest keydown performance
                if(Ext.isIE){
                    return function(e){
                        var k = e.getKey(),
                            doc = this.getDoc(),
        Severity: Minor
        Found in app/assets/javascripts/ext/src/widgets/form/HtmlEditor.js - About 2 hrs to fix

          Function toggleSourceEdit has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              toggleSourceEdit : function(sourceEditMode){
                  var iframeHeight,
                      elHeight;
          
                  if (sourceEditMode === undefined) {
          Severity: Minor
          Found in app/assets/javascripts/ext/src/widgets/form/HtmlEditor.js - About 1 hr to fix

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

                beforeDestroy : function(){
                    if(this.monitorTask){
                        Ext.TaskMgr.stop(this.monitorTask);
                    }
                    if(this.rendered){
            Severity: Minor
            Found in app/assets/javascripts/ext/src/widgets/form/HtmlEditor.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 initEditor has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                initEditor : function(){
                    //Destroying the component during/before initEditor can cause issues.
                    try{
                        var dbody = this.getEditorBody(),
                            ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat', 'background-color', 'color'),
            Severity: Minor
            Found in app/assets/javascripts/ext/src/widgets/form/HtmlEditor.js - About 1 hr to fix

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

                  updateToolbar: function(){
              
                      if(this.readOnly){
                          return;
                      }
              Severity: Minor
              Found in app/assets/javascripts/ext/src/widgets/form/HtmlEditor.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 updateToolbar has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  updateToolbar: function(){
              
                      if(this.readOnly){
                          return;
                      }
              Severity: Minor
              Found in app/assets/javascripts/ext/src/widgets/form/HtmlEditor.js - About 1 hr to fix

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

                    setReadOnly: function(readOnly){
                
                        Ext.form.HtmlEditor.superclass.setReadOnly.call(this, readOnly);
                        if(this.initialized){
                            if(Ext.isIE){
                Severity: Minor
                Found in app/assets/javascripts/ext/src/widgets/form/HtmlEditor.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 applyCommand has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    applyCommand : function(e){
                        if(e.ctrlKey){
                            var c = e.getCharCode(), cmd;
                            if(c > 0){
                                c = String.fromCharCode(c);
                Severity: Minor
                Found in app/assets/javascripts/ext/src/widgets/form/HtmlEditor.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 onResize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    onResize : function(w, h){
                        Ext.form.HtmlEditor.superclass.onResize.apply(this, arguments);
                        if(this.el && this.iframe){
                            if(Ext.isNumber(w)){
                                var aw = w - this.wrap.getFrameWidth('lr');
                Severity: Minor
                Found in app/assets/javascripts/ext/src/widgets/form/HtmlEditor.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 toggleSourceEdit has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    toggleSourceEdit : function(sourceEditMode){
                        var iframeHeight,
                            elHeight;
                
                        if (sourceEditMode === undefined) {
                Severity: Minor
                Found in app/assets/javascripts/ext/src/widgets/form/HtmlEditor.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

                Avoid deeply nested control flow statements.
                Open

                                        if(!target || target.tagName.toLowerCase() != 'li'){
                                            e.stopEvent();
                                            r.pasteHTML('<br />');
                                            r.collapse(false);
                                            r.select();
                Severity: Major
                Found in app/assets/javascripts/ext/src/widgets/form/HtmlEditor.js - About 45 mins to fix

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

                      pushValue : function(){
                          if(this.initialized){
                              var v = this.el.dom.value;
                              if(!this.activated && v.length < 1){
                                  v = this.defaultValue;
                  Severity: Minor
                  Found in app/assets/javascripts/ext/src/widgets/form/HtmlEditor.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 syncValue has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      syncValue : function(){
                          if(this.initialized){
                              var bd = this.getEditorBody();
                              var html = bd.innerHTML;
                              if(Ext.isWebKit){
                  Severity: Minor
                  Found in app/assets/javascripts/ext/src/widgets/form/HtmlEditor.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 initEditor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      initEditor : function(){
                          //Destroying the component during/before initEditor can cause issues.
                          try{
                              var dbody = this.getEditorBody(),
                                  ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat', 'background-color', 'color'),
                  Severity: Minor
                  Found in app/assets/javascripts/ext/src/widgets/form/HtmlEditor.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 checkDesignMode has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      checkDesignMode : function(){
                          if(this.wrap && this.wrap.dom.offsetWidth){
                              var doc = this.getDoc();
                              if(!doc){
                                  return;
                  Severity: Minor
                  Found in app/assets/javascripts/ext/src/widgets/form/HtmlEditor.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 fixKeys has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      fixKeys : function(){ // load time branching for fastest keydown performance
                          if(Ext.isIE){
                              return function(e){
                                  var k = e.getKey(),
                                      doc = this.getDoc(),
                  Severity: Minor
                  Found in app/assets/javascripts/ext/src/widgets/form/HtmlEditor.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

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

                          if(this.enableFormat){
                              btns.bold.toggle(doc.queryCommandState('bold'));
                              btns.italic.toggle(doc.queryCommandState('italic'));
                              btns.underline.toggle(doc.queryCommandState('underline'));
                          }
                  Severity: Major
                  Found in app/assets/javascripts/ext/src/widgets/form/HtmlEditor.js and 1 other location - About 2 hrs to fix
                  app/assets/javascripts/ext/src/widgets/form/HtmlEditor.js on lines 896..900

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

                  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.enableAlignments){
                              btns.justifyleft.toggle(doc.queryCommandState('justifyleft'));
                              btns.justifycenter.toggle(doc.queryCommandState('justifycenter'));
                              btns.justifyright.toggle(doc.queryCommandState('justifyright'));
                          }
                  Severity: Major
                  Found in app/assets/javascripts/ext/src/widgets/form/HtmlEditor.js and 1 other location - About 2 hrs to fix
                  app/assets/javascripts/ext/src/widgets/form/HtmlEditor.js on lines 891..895

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

                  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

                      onDisable: function(){
                          this.wrap.mask();
                          Ext.form.HtmlEditor.superclass.onDisable.call(this);
                      },
                  Severity: Minor
                  Found in app/assets/javascripts/ext/src/widgets/form/HtmlEditor.js and 1 other location - About 50 mins to fix
                  app/assets/javascripts/ext/src/widgets/form/HtmlEditor.js on lines 373..376

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

                  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

                      onEnable: function(){
                          this.wrap.unmask();
                          Ext.form.HtmlEditor.superclass.onEnable.call(this);
                      },
                  Severity: Minor
                  Found in app/assets/javascripts/ext/src/widgets/form/HtmlEditor.js and 1 other location - About 50 mins to fix
                  app/assets/javascripts/ext/src/widgets/form/HtmlEditor.js on lines 368..371

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

                  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