IBM-Swift/Kitura

View on GitHub
docs/docsets/Kitura.docset/Contents/Resources/Documents/js/typeahead.jquery.js

Summary

Maintainability
F
4 mos
Test Coverage

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

/*!
 * typeahead.js 1.3.1
 * https://github.com/corejavascript/typeahead.js
 * Copyright 2013-2020 Twitter, Inc. and other contributors; Licensed MIT
 */

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

        var Typeahead = function() {
            "use strict";
            function Typeahead(o, www) {
                var onFocused, onBlurred, onEnterKeyed, onTabKeyed, onEscKeyed, onUpKeyed, onDownKeyed, onLeftKeyed, onRightKeyed, onQueryChanged, onWhitespaceChanged;
                o = o || {};

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

          var Input = function() {
              "use strict";
              var specialKeyCodeMap;
              specialKeyCodeMap = {
                  9: "tab",

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

            var Dataset = function() {
                "use strict";
                var keys, nameGenerator;
                keys = {
                    dataset: "tt-selectable-dataset",

          Function Menu has 144 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              var Menu = function() {
                  "use strict";
                  function Menu(o, www) {
                      var that = this;
                      o = o || {};

            Function _ has 140 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;

              Function WWW has 92 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  var WWW = function() {
                      "use strict";
                      var defaultClassNames = {
                          wrapper: "twitter-typeahead",
                          input: "tt-input",

                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,

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

                      var highlight = function(doc) {
                          "use strict";
                          var defaults = {
                              node: null,
                              pattern: null,

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

                                initialize: function initialize(o, datasets) {
                                    var www;
                                    datasets = _.isArray(datasets) ? datasets : [].slice.call(arguments, 1);
                                    o = o || {};
                                    www = WWW(o.classNames);

                      Function Status has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          var Status = function() {
                              "use strict";
                              function Status(options) {
                                  this.$el = $("<span></span>", {
                                      role: "status",

                        Function attach has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                                        function attach() {
                                            var $input, $wrapper, $hint, $menu, defaultHint, defaultMenu, eventBus, input, menu, status, typeahead, MenuConstructor;
                                            _.each(datasets, function(d) {
                                                d.highlight = !!o.highlight;
                                            });

                          Function buildCss has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                  function buildCss() {
                                      var css = {
                                          wrapper: {
                                              position: "relative",
                                              display: "inline-block"

                            Function DefaultMenu has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                var DefaultMenu = function() {
                                    "use strict";
                                    var s = Menu.prototype;
                                    function DefaultMenu() {
                                        Menu.apply(this, [].slice.call(arguments, 0));

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

                                  var EventBus = function() {
                                      "use strict";
                                      var namespace, deprecationMap;
                                      namespace = "typeahead:";
                                      deprecationMap = {

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

                                        function Typeahead(o, www) {
                                            var onFocused, onBlurred, onEnterKeyed, onTabKeyed, onEscKeyed, onUpKeyed, onDownKeyed, onLeftKeyed, onRightKeyed, onQueryChanged, onWhitespaceChanged;
                                            o = o || {};
                                            if (!o.input) {
                                                $.error("missing input");

                                  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;

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

                                                update: function update(query) {
                                                    var that = this, canceled = false, syncCalled = false, rendered = 0;
                                                    this.cancel();
                                                    this.cancel = function cancel() {
                                                        canceled = true;

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

                                              function Input(o, www) {
                                                  var id;
                                                  o = o || {};
                                                  if (!o.input) {
                                                      $.error("input is missing");

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

                                        (function(root, factory) {
                                            if (typeof define === "function" && define.amd) {
                                                define([ "jquery" ], function(a0) {
                                                    return factory(a0);
                                                });
                                        docs/js/typeahead.jquery.js on lines 8..1694

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

                                        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