vendor/assets/javascripts/typeahead.bundle.js

Summary

Maintainability
F
2 wks
Test Coverage

File typeahead.bundle.js has 1772 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*!
 * typeahead.js 0.10.4
 * https://github.com/twitter/typeahead.js
 * Copyright 2013-2014 Twitter, Inc. and other contributors; Licensed MIT
 */
Severity: Major
Found in vendor/assets/javascripts/typeahead.bundle.js - About 4 days to fix

    Function Typeahead has 244 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        var Typeahead = function() {
            "use strict";
            var attrsKey = "ttAttrs";
            function Typeahead(o) {
                var $menu, $input, $hint;
    Severity: Major
    Found in vendor/assets/javascripts/typeahead.bundle.js - About 1 day to fix

      Function Input has 188 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          var Input = function() {
              "use strict";
              var specialKeyCodeMap;
              specialKeyCodeMap = {
                  9: "tab",
      Severity: Major
      Found in vendor/assets/javascripts/typeahead.bundle.js - About 7 hrs to fix

        Function Dropdown has 157 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            var Dropdown = function() {
                "use strict";
                function Dropdown(o) {
                    var that = this, onSuggestionClick, onSuggestionMouseEnter, onSuggestionMouseLeave;
                    o = o || {};
        Severity: Major
        Found in vendor/assets/javascripts/typeahead.bundle.js - About 6 hrs to fix

          Function Dataset has 131 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              var Dataset = function() {
                  "use strict";
                  var datasetKey = "ttDataset", valueKey = "ttValue", datumKey = "ttDatum";
                  function Dataset(o) {
                      o = o || {};
          Severity: Major
          Found in vendor/assets/javascripts/typeahead.bundle.js - About 5 hrs to fix

            Function _ has 118 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                var _ = function() {
                    "use strict";
                    return {
                        isMsie: function() {
                            return /(msie|trident)/i.test(navigator.userAgent) ? navigator.userAgent.match(/(msie |rv:)(\d+(.\d+)?)/i)[2] : false;
            Severity: Major
            Found in vendor/assets/javascripts/typeahead.bundle.js - About 4 hrs to fix

              Function SearchIndex has 115 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  var SearchIndex = function() {
                      "use strict";
                      function SearchIndex(o) {
                          o = o || {};
                          if (!o.datumTokenizer || !o.queryTokenizer) {
              Severity: Major
              Found in vendor/assets/javascripts/typeahead.bundle.js - About 4 hrs to fix

                Function EventEmitter has 87 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    var EventEmitter = function() {
                        "use strict";
                        var splitter = /\s+/, nextTick = getNextTick();
                        return {
                            onSync: onSync,
                Severity: Major
                Found in vendor/assets/javascripts/typeahead.bundle.js - About 3 hrs to fix

                  Function Transport has 84 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      var Transport = function() {
                          "use strict";
                          var pendingRequestsCount = 0, pendingRequests = {}, maxPendingRequests = 6, sharedCache = new LruCache(10);
                          function Transport(o) {
                              o = o || {};
                  Severity: Major
                  Found in vendor/assets/javascripts/typeahead.bundle.js - About 3 hrs to fix

                    Function PersistentStorage has 77 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        var PersistentStorage = function() {
                            "use strict";
                            var ls, methods;
                            try {
                                ls = window.localStorage;
                    Severity: Major
                    Found in vendor/assets/javascripts/typeahead.bundle.js - About 3 hrs to fix

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

                          var oParser = function() {
                              "use strict";
                              return {
                                  local: getLocal,
                                  prefetch: getPrefetch,
                      Severity: Major
                      Found in vendor/assets/javascripts/typeahead.bundle.js - About 2 hrs to fix

                        Function LruCache has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            var LruCache = function() {
                                "use strict";
                                function LruCache(maxSize) {
                                    this.maxSize = _.isNumber(maxSize) ? maxSize : 100;
                                    this.reset();
                        Severity: Major
                        Found in vendor/assets/javascripts/typeahead.bundle.js - About 2 hrs to fix

                          Function css has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              var css = function() {
                                  "use strict";
                                  var css = {
                                      wrapper: {
                                          position: "relative",
                          Severity: Major
                          Found in vendor/assets/javascripts/typeahead.bundle.js - About 2 hrs to fix

                            Function render has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                        _render: function render(query, suggestions) {
                                            if (!this.$el) {
                                                return;
                                            }
                                            var that = this, hasSuggestions;
                            Severity: Minor
                            Found in vendor/assets/javascripts/typeahead.bundle.js - About 2 hrs to fix

                              Function highlight has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  var highlight = function(doc) {
                                      "use strict";
                                      var defaults = {
                                          node: null,
                                          pattern: null,
                              Severity: Minor
                              Found in vendor/assets/javascripts/typeahead.bundle.js - About 1 hr to fix

                                Function Typeahead has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                        function Typeahead(o) {
                                            var $menu, $input, $hint;
                                            o = o || {};
                                            if (!o.input) {
                                                $.error("missing input");
                                Severity: Minor
                                Found in vendor/assets/javascripts/typeahead.bundle.js - About 1 hr to fix

                                  Function getRemote has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                          function getRemote(o) {
                                              var remote, defaults;
                                              defaults = {
                                                  url: null,
                                                  cache: true,
                                  Severity: Minor
                                  Found in vendor/assets/javascripts/typeahead.bundle.js - About 1 hr to fix

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

                                            return function hightlight(o) {
                                                var regex;
                                                o = _.mixin({}, defaults, o);
                                                if (!o.node || !o.pattern) {
                                                    return;
                                    Severity: Minor
                                    Found in vendor/assets/javascripts/typeahead.bundle.js - About 1 hr to fix

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

                                          var tokenizers = function() {
                                              "use strict";
                                              return {
                                                  nonword: nonword,
                                                  whitespace: whitespace,
                                      Severity: Minor
                                      Found in vendor/assets/javascripts/typeahead.bundle.js - About 1 hr to fix

                                        Function _get has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                        Open

                                                    _get: function(url, o, cb) {
                                                        var that = this, jqXhr;
                                                        if (this.cancelled || url !== this.lastUrl) {
                                                            return;
                                                        }
                                        Severity: Minor
                                        Found in vendor/assets/javascripts/typeahead.bundle.js - About 1 hr to fix

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

                                                  function Input(o) {
                                                      var that = this, onBlur, onFocus, onKeydown, onInput;
                                                      o = o || {};
                                                      if (!o.input) {
                                                          $.error("input is missing");
                                          Severity: Minor
                                          Found in vendor/assets/javascripts/typeahead.bundle.js - About 1 hr to fix

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

                                                        _onUpKeyed: function onUpKeyed() {
                                                            var query = this.input.getQuery();
                                                            this.dropdown.isEmpty && query.length >= this.minLength ? this.dropdown.update(query) : this.dropdown.moveCursorUp();
                                                            this.dropdown.open();
                                                        },
                                            Severity: Major
                                            Found in vendor/assets/javascripts/typeahead.bundle.js and 1 other location - About 3 hrs to fix
                                            vendor/assets/javascripts/typeahead.bundle.js on lines 1557..1561

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

                                            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

                                                        _onDownKeyed: function onDownKeyed() {
                                                            var query = this.input.getQuery();
                                                            this.dropdown.isEmpty && query.length >= this.minLength ? this.dropdown.update(query) : this.dropdown.moveCursorDown();
                                                            this.dropdown.open();
                                                        },
                                            Severity: Major
                                            Found in vendor/assets/javascripts/typeahead.bundle.js and 1 other location - About 3 hrs to fix
                                            vendor/assets/javascripts/typeahead.bundle.js on lines 1552..1556

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

                                            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

                                                        close: function close() {
                                                            return this.each(closeTypeahead);
                                                            function closeTypeahead() {
                                                                var $input = $(this), typeahead;
                                                                if (typeahead = $input.data(typeaheadKey)) {
                                            Severity: Major
                                            Found in vendor/assets/javascripts/typeahead.bundle.js and 1 other location - About 1 hr to fix
                                            vendor/assets/javascripts/typeahead.bundle.js on lines 1721..1729

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

                                            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

                                                        open: function open() {
                                                            return this.each(openTypeahead);
                                                            function openTypeahead() {
                                                                var $input = $(this), typeahead;
                                                                if (typeahead = $input.data(typeaheadKey)) {
                                            Severity: Major
                                            Found in vendor/assets/javascripts/typeahead.bundle.js and 1 other location - About 1 hr to fix
                                            vendor/assets/javascripts/typeahead.bundle.js on lines 1730..1738

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

                                            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 (!hasSuggestions && this.templates.empty) {
                                                                this.$el.html(getEmptyHtml()).prepend(that.templates.header ? getHeaderHtml() : null).append(that.templates.footer ? getFooterHtml() : null);
                                                            } else if (hasSuggestions) {
                                                                this.$el.html(getSuggestionsHtml()).prepend(that.templates.header ? getHeaderHtml() : null).append(that.templates.footer ? getFooterHtml() : null);
                                                            }
                                            Severity: Major
                                            Found in vendor/assets/javascripts/typeahead.bundle.js and 1 other location - About 1 hr to fix
                                            vendor/assets/javascripts/typeahead.bundle.js on lines 1191..1193

                                            Duplicated Code

                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                            Tuning

                                            This issue has a mass of 72.

                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                            Refactorings

                                            Further Reading

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

                                                            } else if (hasSuggestions) {
                                                                this.$el.html(getSuggestionsHtml()).prepend(that.templates.header ? getHeaderHtml() : null).append(that.templates.footer ? getFooterHtml() : null);
                                                            }
                                            Severity: Major
                                            Found in vendor/assets/javascripts/typeahead.bundle.js and 1 other location - About 1 hr to fix
                                            vendor/assets/javascripts/typeahead.bundle.js on lines 1189..1193

                                            Duplicated Code

                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                            Tuning

                                            This issue has a mass of 72.

                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                            Refactorings

                                            Further Reading

                                            There are no issues that match your filters.

                                            Category
                                            Status