divio/django-cms

View on GitHub
cms/static/cms/js/select2/select2.js

Summary

Maintainability
F
2 wks
Test Coverage

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

/*
Copyright 2012 Igor Vaynberg

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

Severity: Major
Found in cms/static/cms/js/select2/select2.js - About 1 wk to fix

    Function initContainer has 143 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 cms/static/cms/js/select2/select2.js - About 5 hrs to fix

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

              initContainer: function () {
      
                  var selection,
                      container = this.container,
                      dropdown = this.dropdown,
      Severity: Major
      Found in cms/static/cms/js/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 cms/static/cms/js/select2/select2.js - About 5 hrs to fix

          Function updateResults has 109 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 cms/static/cms/js/select2/select2.js - About 4 hrs to fix

            Function init has 104 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 cms/static/cms/js/select2/select2.js - About 4 hrs to fix

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

                      positionDropdown: function() {
                          var $dropdown = this.dropdown,
                              offset = this.container.offset(),
                              height = this.container.outerHeight(false),
                              width = this.container.outerWidth(false),
              Severity: Major
              Found in cms/static/cms/js/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 cms/static/cms/js/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 cms/static/cms/js/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 cms/static/cms/js/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 cms/static/cms/js/select2/select2.js - About 1 hr to fix

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

                                addSelectedChoice: function (data) {
                                    var enableChoice = !data.locked,
                                        enabledItem = $(
                                            "<li class='select2-search-choice'>" +
                                            "    <div></div>" +
                        Severity: Minor
                        Found in cms/static/cms/js/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 cms/static/cms/js/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 cms/static/cms/js/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 cms/static/cms/js/select2/select2.js - About 1 hr to fix

                                Function callback has 37 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 cms/static/cms/js/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 cms/static/cms/js/select2/select2.js - About 1 hr to fix

                                    Function destroy has 35 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 cms/static/cms/js/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 cms/static/cms/js/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 cms/static/cms/js/select2/select2.js - About 1 hr to fix

                                          Function onSelect has 32 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 cms/static/cms/js/select2/select2.js - About 1 hr to fix

                                            Function monitorSource has 31 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 cms/static/cms/js/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 cms/static/cms/js/select2/select2.js - About 1 hr to fix

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

                                                        opening: function () {
                                                            var el, range, len;
                                                
                                                            if (this.opts.minimumResultsForSearch >= 0) {
                                                                this.showSearch(true);
                                                Severity: Minor
                                                Found in cms/static/cms/js/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);
                                                                      //search in data by array of ids, storing matching items in a list
                                                                      var matches = [];
                                                                      opts.query({
                                                  Severity: Minor
                                                  Found in cms/static/cms/js/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 cms/static/cms/js/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 cms/static/cms/js/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 cms/static/cms/js/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 cms/static/cms/js/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 cms/static/cms/js/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)).each(function () {
                                                                                                  var obj = { id: this, text: this },
                                                              Severity: Major
                                                              Found in cms/static/cms/js/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 cms/static/cms/js/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 cms/static/cms/js/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 cms/static/cms/js/select2/select2.js - About 40 mins to fix

                                                                      Avoid too many return statements within this function.
                                                                      Open

                                                                                          return;
                                                                      Severity: Major
                                                                      Found in cms/static/cms/js/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 cms/static/cms/js/select2/select2.js - About 30 mins to fix

                                                                          Avoid too many return statements within this function.
                                                                          Open

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

                                                                            Avoid too many return statements within this function.
                                                                            Open

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

                                                                              Avoid too many return statements within this function.
                                                                              Open

                                                                                              return;
                                                                              Severity: Major
                                                                              Found in cms/static/cms/js/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 cms/static/cms/js/select2/select2.js - About 30 mins to fix

                                                                                  Avoid too many return statements within this function.
                                                                                  Open

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

                                                                                    Avoid too many return statements within this function.
                                                                                    Open

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

                                                                                      Avoid too many return statements within this function.
                                                                                      Open

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

                                                                                        Avoid too many return statements within this function.
                                                                                        Open

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

                                                                                          Avoid too many return statements within this function.
                                                                                          Open

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

                                                                                            Avoid too many return statements within this function.
                                                                                            Open

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

                                                                                              Avoid too many return statements within this function.
                                                                                              Open

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

                                                                                                Avoid too many return statements within this function.
                                                                                                Open

                                                                                                                    return;
                                                                                                Severity: Major
                                                                                                Found in cms/static/cms/js/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 cms/static/cms/js/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 cms/static/cms/js/select2/select2.js - About 30 mins to fix

                                                                                                      Avoid too many return statements within this function.
                                                                                                      Open

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

                                                                                                        Avoid too many return statements within this function.
                                                                                                        Open

                                                                                                                                return;
                                                                                                        Severity: Major
                                                                                                        Found in cms/static/cms/js/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 cms/static/cms/js/select2/select2.js and 1 other location - About 3 hrs to fix
                                                                                                          cms/static/cms/js/select2/select2.js on lines 2059..2068

                                                                                                          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 cms/static/cms/js/select2/select2.js and 1 other location - About 3 hrs to fix
                                                                                                          cms/static/cms/js/select2/select2.js on lines 2657..2666

                                                                                                          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 cms/static/cms/js/select2/select2.js and 1 other location - About 2 hrs to fix
                                                                                                          cms/static/cms/js/select2/select2.js on lines 2237..2242

                                                                                                          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 cms/static/cms/js/select2/select2.js and 1 other location - About 2 hrs to fix
                                                                                                          cms/static/cms/js/select2/select2.js on lines 2248..2253

                                                                                                          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

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

                                                                                                                      if(this.search.val() === "") {
                                                                                                                          if(this.nextSearchTerm != undefined){
                                                                                                                              this.search.val(this.nextSearchTerm);
                                                                                                                              this.search.select();
                                                                                                                          }
                                                                                                          Severity: Major
                                                                                                          Found in cms/static/cms/js/select2/select2.js and 1 other location - About 1 hr to fix
                                                                                                          cms/static/cms/js/select2/select2.js on lines 2908..2913

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

                                                                                                          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(this.search.val() === "") {
                                                                                                                          if(this.nextSearchTerm != undefined){
                                                                                                                              this.search.val(this.nextSearchTerm);
                                                                                                                              this.search.select();
                                                                                                                          }
                                                                                                          Severity: Major
                                                                                                          Found in cms/static/cms/js/select2/select2.js and 1 other location - About 1 hr to fix
                                                                                                          cms/static/cms/js/select2/select2.js on lines 2007..2012

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

                                                                                                          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 cms/static/cms/js/select2/select2.js and 1 other location - About 1 hr to fix
                                                                                                          cms/static/cms/js/select2/select2.js on lines 1735..1739

                                                                                                          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 cms/static/cms/js/select2/select2.js and 1 other location - About 1 hr to fix
                                                                                                          cms/static/cms/js/select2/select2.js on lines 1725..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 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.search.prop("disabled", !this.isInterfaceEnabled());
                                                                                                                      }
                                                                                                                  },
                                                                                                          Severity: Major
                                                                                                          Found in cms/static/cms/js/select2/select2.js and 1 other location - About 1 hr to fix
                                                                                                          cms/static/cms/js/select2/select2.js on lines 1968..1972

                                                                                                          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.focusser.prop("disabled", !this.isInterfaceEnabled());
                                                                                                                      }
                                                                                                                  },
                                                                                                          Severity: Major
                                                                                                          Found in cms/static/cms/js/select2/select2.js and 1 other location - About 1 hr to fix
                                                                                                          cms/static/cms/js/select2/select2.js on lines 2847..2851

                                                                                                          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.BACKSPACE || e.which === KEY.ESC) {
                                                                                                          Severity: Minor
                                                                                                          Found in cms/static/cms/js/select2/select2.js and 1 other location - About 55 mins to fix
                                                                                                          cms/static/cms/js/select2/select2.js on lines 2164..2164

                                                                                                          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.ESC) {
                                                                                                          Severity: Minor
                                                                                                          Found in cms/static/cms/js/select2/select2.js and 1 other location - About 55 mins to fix
                                                                                                          cms/static/cms/js/select2/select2.js on lines 2771..2772

                                                                                                          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 cms/static/cms/js/select2/select2.js and 1 other location - About 40 mins to fix
                                                                                                          cms/static/cms/js/select2/select2.js on lines 1923..1923

                                                                                                          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 cms/static/cms/js/select2/select2.js and 1 other location - About 40 mins to fix
                                                                                                          cms/static/cms/js/select2/select2.js on lines 1902..1902

                                                                                                          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 cms/static/cms/js/select2/select2.js and 1 other location - About 35 mins to fix
                                                                                                          cms/static/cms/js/select2/select2.js on lines 2131..2134

                                                                                                          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 cms/static/cms/js/select2/select2.js and 1 other location - About 35 mins to fix
                                                                                                          cms/static/cms/js/select2/select2.js on lines 2752..2755

                                                                                                          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 cms/static/cms/js/select2/select2.js and 1 other location - About 35 mins to fix
                                                                                                          cms/static/cms/js/select2/select2.js on lines 1790..1797

                                                                                                          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 cms/static/cms/js/select2/select2.js and 1 other location - About 35 mins to fix
                                                                                                          cms/static/cms/js/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

                                                                                                          There are no issues that match your filters.

                                                                                                          Category
                                                                                                          Status