zammad/zammad

View on GitHub
app/assets/javascripts/app/lib/base/jquery.textmodule.js

Summary

Maintainability
F
4 days
Test Coverage

File jquery.textmodule.js has 580 lines of code (exceeds 250 allowed). Consider refactoring.
Open

(function ($, window, undefined) {

/*
# mode: textonly/richtext / disable b/i/u/enter + strip on paste
# pasteOnlyText: true
Severity: Major
Found in app/assets/javascripts/app/lib/base/jquery.textmodule.js - About 1 day to fix

    Function onKeydown has 66 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      Plugin.prototype.onKeydown = function (e) {
        // Saves the old element text for some special situations.
        this.oldElementText = this.$element.text()
    
        // navigate through item
    Severity: Major
    Found in app/assets/javascripts/app/lib/base/jquery.textmodule.js - About 2 hrs to fix

      Function renderResults has 60 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        KbAnswer.renderResults = function(textmodule, term) {
          textmodule.emptyResultsContainer()
      
          // skip in admin interface (ticket is needed)
          if (!textmodule.searchCondition) {
      Severity: Major
      Found in app/assets/javascripts/app/lib/base/jquery.textmodule.js - About 2 hrs to fix

        Function onKeypress has 52 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          Plugin.prototype.onKeypress = function (e) {
            this.log('BUFF', this.buffer, e.keyCode, String.fromCharCode(e.which))
            // gets the character and keycode from event
            // this event does not have keyCode and which value set
            // so we take char and set those values to not break the flow
        Severity: Major
        Found in app/assets/javascripts/app/lib/base/jquery.textmodule.js - About 2 hrs to fix

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

            Mention.renderResults = function(textmodule, term) {
              textmodule.emptyResultsContainer()
          
              // skip in admin interface (ticket is needed)
              if (!textmodule.searchCondition) {
          Severity: Minor
          Found in app/assets/javascripts/app/lib/base/jquery.textmodule.js - About 1 hr to fix

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

              Plugin.prototype.paste = function(string) {
                var isIE11 = !!window.MSInputMethodContext && !!document.documentMode;
            
                // IE <= 10
                if (document.selection && document.selection.createRange) {
            Severity: Minor
            Found in app/assets/javascripts/app/lib/base/jquery.textmodule.js - About 1 hr to fix

              Function renderValue has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                KbAnswer.renderValue = function(textmodule, elem, callback) {
                  textmodule.emptyResultsContainer()
              
                  var element = $('<li>').text(App.i18n.translateInline('Please wait…'))
                  textmodule.appendResults(element)
              Severity: Minor
              Found in app/assets/javascripts/app/lib/base/jquery.textmodule.js - About 1 hr to fix

                Function success has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        success: function(data, status, xhr) {
                          textmodule.emptyResultsContainer()
                
                          var items = data
                            .result
                Severity: Minor
                Found in app/assets/javascripts/app/lib/base/jquery.textmodule.js - About 1 hr to fix

                  Function renderResults has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    Collection.renderResults = function(textmodule, term) {
                      var reg     = new RegExp(term, 'i')
                      var regFull = new RegExp('\\b' + term + '\\b', 'i')
                      var result  = textmodule.collection.filter(function(item) {
                        return matchItemWithRegExp(item, reg) && !matchItemWithRegExp(item, regFull)
                  Severity: Minor
                  Found in app/assets/javascripts/app/lib/base/jquery.textmodule.js - About 1 hr to fix

                    Avoid deeply nested control flow statements.
                    Open

                                if (this.buffer.charAt(i) !== foundCurrentBuffer.charAt(i)) {
                                  existingLength = i
                                  break
                                }
                    Severity: Major
                    Found in app/assets/javascripts/app/lib/base/jquery.textmodule.js - About 45 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              return
                      Severity: Major
                      Found in app/assets/javascripts/app/lib/base/jquery.textmodule.js - About 30 mins to fix

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

                          $.fn[pluginName] = function (options) {
                            return this.each(function () {
                              if (!$.data(this, 'plugin_' + pluginName)) {
                                $.data(this, 'plugin_' + pluginName, new Plugin(this, options))
                              }
                        Severity: Major
                        Found in app/assets/javascripts/app/lib/base/jquery.textmodule.js and 1 other location - About 2 hrs to fix
                        app/assets/javascripts/app/lib/base/jquery.enableObjectResizingShim.js on lines 183..189

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

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

                            else if (isIE11 && document.getSelection) {
                              var range = document.getSelection().getRangeAt(0)
                              var nnode = document.createElement('div')
                                  range.surroundContents(nnode)
                                  nnode.innerHTML = string
                        Severity: Major
                        Found in app/assets/javascripts/app/lib/base/jquery.textmodule.js and 1 other location - About 1 hr to fix
                        app/assets/javascripts/app/lib/base/jquery.contenteditable.js on lines 599..607

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

                        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(!term) {
                              var element = $('<li>').text(App.i18n.translateInline('Start typing to search for users…'))
                              textmodule.appendResults(element)
                        
                              return
                        Severity: Minor
                        Found in app/assets/javascripts/app/lib/base/jquery.textmodule.js and 1 other location - About 50 mins to fix
                        app/assets/javascripts/app/lib/base/jquery.textmodule.js on lines 640..645

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

                        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(!term) {
                              var element = $('<li>').text(App.i18n.translateInline('Start typing to search in Knowledge Base…'))
                              textmodule.appendResults(element)
                        
                              return
                        Severity: Minor
                        Found in app/assets/javascripts/app/lib/base/jquery.textmodule.js and 1 other location - About 50 mins to fix
                        app/assets/javascripts/app/lib/base/jquery.textmodule.js on lines 744..749

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

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

                                  if(items.length == 0) {
                                    items.push($('<li>').text(App.i18n.translateInline('No results found')))
                                  }
                        Severity: Minor
                        Found in app/assets/javascripts/app/lib/base/jquery.textmodule.js and 1 other location - About 45 mins to fix
                        app/assets/javascripts/app/lib/base/jquery.textmodule.js on lines 697..699

                        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

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

                                  if(items.length == 0) {
                                    items.push($('<li>').text(App.i18n.translateInline('No results found')))
                                  }
                        Severity: Minor
                        Found in app/assets/javascripts/app/lib/base/jquery.textmodule.js and 1 other location - About 45 mins to fix
                        app/assets/javascripts/app/lib/base/jquery.textmodule.js on lines 779..781

                        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

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

                            if (document.selection && document.selection.createRange) {
                              var range = document.selection.createRange()
                              if (range.pasteHTML) {
                                range.pasteHTML(string)
                              }
                        Severity: Minor
                        Found in app/assets/javascripts/app/lib/base/jquery.textmodule.js and 1 other location - About 35 mins to fix
                        app/assets/javascripts/app/lib/base/jquery.contenteditable.js on lines 592..607

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

                        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