smartinmedia/cunity

View on GitHub
lib/plugins/select2/select2.js

Summary

Maintainability
F
2 wks
Test Coverage

File select2.js has 2604 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
Copyright 2012 Igor Vaynberg

Version: @@ver@@ Timestamp: @@timestamp@@

Severity: Major
Found in lib/plugins/select2/select2.js - About 1 wk to fix

Function initContainer has 147 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        initContainer: function () {

            var selection,
                container = this.container,
                dropdown = this.dropdown,
Severity: Major
Found in lib/plugins/select2/select2.js - About 5 hrs to fix

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

        initContainer: function () {

            var selector = ".select2-choices", selection;

            this.searchContainer = this.container.find(".select2-search-field");
Severity: Major
Found in lib/plugins/select2/select2.js - About 5 hrs to fix

Function prepareOpts has 140 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        prepareOpts: function (opts) {
            var element, select, idKey, ajaxUrl, self = this;

            element = opts.element;

Severity: Major
Found in lib/plugins/select2/select2.js - About 5 hrs to fix

Function updateResults has 110 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        updateResults: function (initial) {
            var search = this.search,
                results = this.results,
                opts = this.opts,
                data,
Severity: Major
Found in lib/plugins/select2/select2.js - About 4 hrs to fix

Function init has 107 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        init: function (opts) {
            var results, search, resultsSelector = ".select2-results";

            // prepare options
            this.opts = opts = this.prepareOpts(opts);
Severity: Major
Found in lib/plugins/select2/select2.js - About 4 hrs to fix

Function positionDropdown has 93 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        positionDropdown: function() {
            var $dropdown = this.dropdown,
                container = this.container,
                offset = container.offset(),
                height = container.outerHeight(false),
Severity: Major
Found in lib/plugins/select2/select2.js - About 3 hrs to fix

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

    function ajax(options) {
        var timeout, // current scheduled but not yet executed request
            handler = null,
            quietMillis = options.quietMillis || 100,
            ajaxUrl = options.url,
Severity: Minor
Found in lib/plugins/select2/select2.js - About 1 hr to fix

Function local has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function local(options) {
        var data = options, // data elements
            dataText,
            tmp,
            text = function (item) { return ""+item.text; }; // function used to retrieve the text portion of a data item that is matched against the search
Severity: Minor
Found in lib/plugins/select2/select2.js - About 1 hr to fix

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

        opening: function() {
            var cid = this.containerEventName,
                scroll = "scroll." + cid,
                resize = "resize."+cid,
                orient = "orientationchange."+cid,
Severity: Minor
Found in lib/plugins/select2/select2.js - About 1 hr to fix

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

    $.fn.select2 = function () {

        var args = Array.prototype.slice.call(arguments, 0),
            opts,
            select2,
Severity: Minor
Found in lib/plugins/select2/select2.js - About 1 hr to fix

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

        prepareOpts: function () {
            var opts = this.parent.prepareOpts.apply(this, arguments),
                self=this;

            // TODO validate placeholder is a string if specified
Severity: Minor
Found in lib/plugins/select2/select2.js - About 1 hr to fix

Function val has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        val: function () {
            var val,
                triggerChange = false,
                data = null,
                self = this,
Severity: Minor
Found in lib/plugins/select2/select2.js - About 1 hr to fix

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

        createChoice: function (data) {
            var enableChoice = !data.locked,
                enabledItem = $(
                    "<li class='select2-search-choice'>" +
                    "    <div></div>" +
Severity: Minor
Found in lib/plugins/select2/select2.js - About 1 hr to fix

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

        destroy: function () {
            var element=this.opts.element, select2 = element.data("select2"), self = this;

            this.close();

Severity: Minor
Found in lib/plugins/select2/select2.js - About 1 hr to fix

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

                populateResults: function(container, results, query) {
                    var populate, id=this.opts.id, liveRegion=this.liveRegion;

                    populate=function(results, container, depth) {

Severity: Minor
Found in lib/plugins/select2/select2.js - About 1 hr to fix

Function callback has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

                    callback: this.bind(function (data) {
                var def; // default choice

                // ignore old responses
                if (queryNumber != this.queryCount) {
Severity: Minor
Found in lib/plugins/select2/select2.js - About 1 hr to fix

Function val has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        val: function (val, triggerChange) {
            var oldData, self=this;

            if (arguments.length === 0) {
                return this.getVal();
Severity: Minor
Found in lib/plugins/select2/select2.js - About 1 hr to fix

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

        monitorSource: function () {
            var el = this.opts.element, observer, self = this;

            el.on("change.select2", this.bind(function (e) {
                if (this.opts.element.data("select2-change-triggered") !== true) {
Severity: Minor
Found in lib/plugins/select2/select2.js - About 1 hr to fix

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

        loadMoreIfNeeded: function () {
            var results = this.results,
                more = results.find("li.select2-more-results"),
                below, // pixels the element is below the scroll fold, below==0 is when the element is starting to be visible
                page = this.resultsPage + 1,
Severity: Minor
Found in lib/plugins/select2/select2.js - About 1 hr to fix

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

        initContainerWidth: function () {
            function resolveContainerWidth() {
                var style, attrs, matches, i, l, attr;

                if (this.opts.width === "off") {
Severity: Minor
Found in lib/plugins/select2/select2.js - About 1 hr to fix

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

    function defaultTokenizer(input, selection, selectCallback, opts) {
        var original = input, // store the original so we can compare and know if we need to tell the search to update its text
            dupe = false, // check for whether a token we extracted represents a duplicate selected choice
            token, // token
            index, // position at which the separator was found
Severity: Minor
Found in lib/plugins/select2/select2.js - About 1 hr to fix

Function onSelect has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        onSelect: function (data, options) {

            if (!this.triggerSelect(data) || data.text === "") { return; }

            this.addSelectedChoice(data);
Severity: Minor
Found in lib/plugins/select2/select2.js - About 1 hr to fix

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

                opts.initSelection = opts.initSelection || function (element, callback) {
                    var ids = splitVal(element.val(), opts.separator, opts.transformVal);
                    //search in data by array of ids, storing matching items in a list
                    var matches = [];
                    opts.query({
Severity: Minor
Found in lib/plugins/select2/select2.js - About 1 hr to fix

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

        unselect: function (selected) {
            var val = this.getVal(),
                data,
                index;
            selected = selected.closest(".select2-search-choice");
Severity: Minor
Found in lib/plugins/select2/select2.js - About 1 hr to fix

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

            function resolveContainerWidth() {
                var style, attrs, matches, i, l, attr;

                if (this.opts.width === "off") {
                    return null;
Severity: Minor
Found in lib/plugins/select2/select2.js - About 1 hr to fix

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

        postprocessResults: function (data, initial, noHighlightUpdate) {
            var val = this.getVal(),
                choices = this.results.find(".select2-result"),
                compound = this.results.find(".select2-result-with-children"),
                self = this;
Severity: Minor
Found in lib/plugins/select2/select2.js - About 1 hr to fix

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

                opts.query = this.bind(function (query) {
                    var data = { results: [], more: false },
                        term = query.term,
                        children, placeholderOption, process;

Severity: Minor
Found in lib/plugins/select2/select2.js - About 1 hr to fix

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

        prepareOpts: function () {
            var opts = this.parent.prepareOpts.apply(this, arguments),
                self=this;

            if (opts.element.get(0).tagName.toLowerCase() === "select") {
Severity: Minor
Found in lib/plugins/select2/select2.js - About 1 hr to fix

Avoid deeply nested control flow statements.
Open

                        if (opts.initSelection === undefined) {
                            opts.initSelection = function (element, callback) {
                                var data = [];
                                $(splitVal(element.val(), opts.separator, opts.transformVal)).each(function () {
                                    var obj = { id: this, text: this },
Severity: Major
Found in lib/plugins/select2/select2.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        if (opts.createSearchChoice === undefined) {
                            opts.createSearchChoice = function (term) { return {id: $.trim(term), text: $.trim(term)}; };
                        }
Severity: Major
Found in lib/plugins/select2/select2.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        if (equal(opts.id(token), opts.id(selection[i]))) {
                            dupe = true; break;
                        }
Severity: Major
Found in lib/plugins/select2/select2.js - About 45 mins to fix

Consider simplifying this complex logical expression.
Open

                if (selected.length &&
                    (e.which == KEY.LEFT || e.which == KEY.RIGHT || e.which == KEY.BACKSPACE || e.which == KEY.DELETE || e.which == KEY.ENTER)) {
                    var selectedChoice = selected;
                    if (e.which == KEY.LEFT && prev.length) {
                        selectedChoice = prev;
Severity: Major
Found in lib/plugins/select2/select2.js - About 40 mins to fix

Avoid too many return statements within this function.
Open

                    return this.opts.width;
Severity: Major
Found in lib/plugins/select2/select2.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

                        return;
Severity: Major
Found in lib/plugins/select2/select2.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

                    return;
Severity: Major
Found in lib/plugins/select2/select2.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

                        return;
Severity: Major
Found in lib/plugins/select2/select2.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

        return false;
Severity: Major
Found in lib/plugins/select2/select2.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

                        return;
Severity: Major
Found in lib/plugins/select2/select2.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

                        return;
Severity: Major
Found in lib/plugins/select2/select2.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

                    return this.opts.width();
Severity: Major
Found in lib/plugins/select2/select2.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

        if (b.constructor === String) return b+'' === a+''; // b+'' - in case 'b' is a String object
Severity: Major
Found in lib/plugins/select2/select2.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

                        return;
Severity: Major
Found in lib/plugins/select2/select2.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

                return;
Severity: Major
Found in lib/plugins/select2/select2.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

                    return;
Severity: Major
Found in lib/plugins/select2/select2.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

                        return;
Severity: Major
Found in lib/plugins/select2/select2.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

                        return;
Severity: Major
Found in lib/plugins/select2/select2.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

                    return null;
Severity: Major
Found in lib/plugins/select2/select2.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

                        return (this.opts.element.outerWidth(false) === 0 ? 'auto' : this.opts.element.outerWidth(false) + 'px');
Severity: Major
Found in lib/plugins/select2/select2.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

                    return;
Severity: Major
Found in lib/plugins/select2/select2.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

                        return;
Severity: Major
Found in lib/plugins/select2/select2.js - About 30 mins to fix

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

        destroy: function() {
            $("label[for='" + this.search.attr('id') + "']")
                .attr('for', this.opts.element.attr("id"));
            this.parent.destroy.apply(this, arguments);

Severity: Major
Found in lib/plugins/select2/select2.js and 1 other location - About 3 hrs to fix
lib/plugins/select2/select2.js on lines 2095..2104

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

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

        destroy: function() {
            $("label[for='" + this.focusser.attr('id') + "']")
                .attr('for', this.opts.element.attr("id"));
            this.parent.destroy.apply(this, arguments);

Severity: Major
Found in lib/plugins/select2/select2.js and 1 other location - About 3 hrs to fix
lib/plugins/select2/select2.js on lines 2699..2708

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

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.search.on("focus", this.bind(function(){
                if (!this.container.hasClass("select2-container-active")) {
                    this.opts.element.trigger($.Event("select2-focus"));
                }
                this.container.addClass("select2-container-active");
Severity: Major
Found in lib/plugins/select2/select2.js and 1 other location - About 2 hrs to fix
lib/plugins/select2/select2.js on lines 2280..2285

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

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.focusser.on("focus", this.bind(function(){
                if (!this.container.hasClass("select2-container-active")) {
                    this.opts.element.trigger($.Event("select2-focus"));
                }
                this.container.addClass("select2-container-active");
Severity: Major
Found in lib/plugins/select2/select2.js and 1 other location - About 2 hrs to fix
lib/plugins/select2/select2.js on lines 2291..2296

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

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.dropdown) {
                    syncCssClasses(this.dropdown, this.opts.element, this.opts.adaptDropdownCssClass);
                    this.dropdown.addClass(evaluate(this.opts.dropdownCssClass, this.opts.element));
                }
Severity: Major
Found in lib/plugins/select2/select2.js and 1 other location - About 2 hrs to fix
lib/plugins/select2/select2.js on lines 1125..1128

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

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.container) {
                    syncCssClasses(this.container, this.opts.element, this.opts.adaptContainerCssClass);
                    this.container.addClass(evaluate(this.opts.containerCssClass, this.opts.element));
                }
Severity: Major
Found in lib/plugins/select2/select2.js and 1 other location - About 2 hrs to fix
lib/plugins/select2/select2.js on lines 1130..1133

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

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 (checkFormatter(opts.formatInputTooShort, "formatInputTooShort")) {
                    render("<li class='select2-no-results'>" + evaluate(opts.formatInputTooShort, opts.element, search.val(), opts.minimumInputLength) + "</li>");
                } else {
                    render("");
                }
Severity: Major
Found in lib/plugins/select2/select2.js and 1 other location - About 1 hr to fix
lib/plugins/select2/select2.js on lines 1777..1781

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

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 (checkFormatter(opts.formatInputTooLong, "formatInputTooLong")) {
                    render("<li class='select2-no-results'>" + evaluate(opts.formatInputTooLong, opts.element, search.val(), opts.maximumInputLength) + "</li>");
                } else {
                    render("");
                }
Severity: Major
Found in lib/plugins/select2/select2.js and 1 other location - About 1 hr to fix
lib/plugins/select2/select2.js on lines 1767..1771

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

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

        enableInterface: function() {
            if (this.parent.enableInterface.apply(this, arguments)) {
                this.focusser.prop("disabled", !this.isInterfaceEnabled());
            }
        },
Severity: Major
Found in lib/plugins/select2/select2.js and 1 other location - About 1 hr to fix
lib/plugins/select2/select2.js on lines 2889..2893

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

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

        enableInterface: function() {
            if (this.parent.enableInterface.apply(this, arguments)) {
                this.search.prop("disabled", !this.isInterfaceEnabled());
            }
        },
Severity: Major
Found in lib/plugins/select2/select2.js and 1 other location - About 1 hr to fix
lib/plugins/select2/select2.js on lines 2011..2015

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

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 (e.which === KEY.TAB || KEY.isControl(e) || KEY.isFunctionKey(e) || e.which === KEY.ESC) {
Severity: Minor
Found in lib/plugins/select2/select2.js and 1 other location - About 55 mins to fix
lib/plugins/select2/select2.js on lines 2813..2814

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

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 (e.which === KEY.TAB || KEY.isControl(e) || KEY.isFunctionKey(e)
                 || e.which === KEY.BACKSPACE || e.which === KEY.ESC) {
Severity: Minor
Found in lib/plugins/select2/select2.js and 1 other location - About 55 mins to fix
lib/plugins/select2/select2.js on lines 2201..2201

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

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

                    return this.opts.element.outerWidth(false) === 0 ? 'auto' : this.opts.element.outerWidth(false) + 'px';
Severity: Minor
Found in lib/plugins/select2/select2.js and 1 other location - About 40 mins to fix
lib/plugins/select2/select2.js on lines 1966..1966

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

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

                        return (this.opts.element.outerWidth(false) === 0 ? 'auto' : this.opts.element.outerWidth(false) + 'px');
Severity: Minor
Found in lib/plugins/select2/select2.js and 1 other location - About 40 mins to fix
lib/plugins/select2/select2.js on lines 1945..1945

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

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

                    case KEY.DOWN:
                        this.moveHighlight((e.which === KEY.UP) ? -1 : 1);
                        killEvent(e);
                        return;
Severity: Minor
Found in lib/plugins/select2/select2.js and 1 other location - About 35 mins to fix
lib/plugins/select2/select2.js on lines 2794..2797

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

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

                    case KEY.DOWN:
                        this.moveHighlight((e.which === KEY.UP) ? -1 : 1);
                        killEvent(e);
                        return;
Severity: Minor
Found in lib/plugins/select2/select2.js and 1 other location - About 35 mins to fix
lib/plugins/select2/select2.js on lines 2168..2171

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

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 (token !== undefined && token !== null && opts.id(token) !== undefined && opts.id(token) !== null) {
                    dupe = false;
                    for (i = 0, l = selection.length; i < l; i++) {
                        if (equal(opts.id(token), opts.id(selection[i]))) {
                            dupe = true; break;
Severity: Minor
Found in lib/plugins/select2/select2.js and 1 other location - About 35 mins to fix
lib/plugins/select2/select2.js on lines 1832..1839

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

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

                    if (def !== undefined && def !== null && self.id(def) !== undefined && self.id(def) !== null) {
                        if ($(data.results).filter(
                            function () {
                                return equal(self.id(this), self.id(def));
                            }).length === 0) {
Severity: Minor
Found in lib/plugins/select2/select2.js and 1 other location - About 35 mins to fix
lib/plugins/select2/select2.js on lines 635..644

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

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

                    (e.which == KEY.LEFT || e.which == KEY.RIGHT || e.which == KEY.BACKSPACE || e.which == KEY.DELETE || e.which == KEY.ENTER)) {
Severity: Minor
Found in lib/plugins/select2/select2.js and 1 other location - About 30 mins to fix
lib/plugins/plupload/js/plupload.full.min.js on lines 3476..3476

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

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